From 52c4b8684bcbe9eea0b939a54ba7b142a7ee1308 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 15 Jul 2015 08:16:41 +0200 Subject: [PATCH 1/2] OStatus: Support for "Favorite" (like) --- include/ostatus.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/include/ostatus.php b/include/ostatus.php index 53887d535..181b9e297 100644 --- a/include/ostatus.php +++ b/include/ostatus.php @@ -239,11 +239,13 @@ function ostatus_import($xml,$importer,&$contact, &$hub) { // Delete a message if ($item["verb"] == "qvitter-delete-notice") { // ignore "Delete" messages (by now) + logger("Ignore delete message ".print_r($item, true)); continue; } if ($item["verb"] == ACTIVITY_JOIN) { // ignore "Join" messages + logger("Ignore join message ".print_r($item, true)); continue; } @@ -258,10 +260,25 @@ function ostatus_import($xml,$importer,&$contact, &$hub) { } if ($item["verb"] == ACTIVITY_FAVORITE) { - // ignore "Favorite" messages + $orig_uri = $xpath->query("activity:object/atom:id", $entry)->item(0)->nodeValue; + logger("Favorite ".$orig_uri." ".print_r($item, true)); + + $item["verb"] = ACTIVITY_LIKE; + $item["parent-uri"] = $orig_uri; + $item["gravity"] = GRAVITY_LIKE; + } + + if ($item["verb"] == NAMESPACE_OSTATUS."/unfavorite") { + // Ignore "Unfavorite" message + logger("Ignore unfavorite message ".print_r($item, true)); continue; } + // http://activitystrea.ms/schema/1.0/rsvp-yes + // http://activitystrea.ms/schema/1.0/share + if (!in_array($item["verb"], array(ACTIVITY_POST, ACTIVITY_LIKE))) + logger("Unhandled verb ".$item["verb"]." ".print_r($item, true)); + $item["created"] = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue; $item["edited"] = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue; $conversation = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue; From 05f8abcfa6e3fe62d14c151926c687a54074a74b Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 15 Jul 2015 18:27:44 +0200 Subject: [PATCH 2/2] OStatus: Handling of unsupported verbs --- boot.php | 1 + include/ostatus.php | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/boot.php b/boot.php index 0e50e8c0e..42498a6cc 100644 --- a/boot.php +++ b/boot.php @@ -274,6 +274,7 @@ define ( 'ACTIVITY_POST', NAMESPACE_ACTIVITY_SCHEMA . 'post' ); define ( 'ACTIVITY_UPDATE', NAMESPACE_ACTIVITY_SCHEMA . 'update' ); define ( 'ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag' ); define ( 'ACTIVITY_FAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'favorite' ); +define ( 'ACTIVITY_SHARE', NAMESPACE_ACTIVITY_SCHEMA . 'share' ); define ( 'ACTIVITY_POKE', NAMESPACE_ZOT . '/activity/poke' ); define ( 'ACTIVITY_MOOD', NAMESPACE_ZOT . '/activity/mood' ); diff --git a/include/ostatus.php b/include/ostatus.php index 181b9e297..369659f2d 100644 --- a/include/ostatus.php +++ b/include/ostatus.php @@ -275,8 +275,7 @@ function ostatus_import($xml,$importer,&$contact, &$hub) { } // http://activitystrea.ms/schema/1.0/rsvp-yes - // http://activitystrea.ms/schema/1.0/share - if (!in_array($item["verb"], array(ACTIVITY_POST, ACTIVITY_LIKE))) + if (!in_array($item["verb"], array(ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE))) logger("Unhandled verb ".$item["verb"]." ".print_r($item, true)); $item["created"] = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue;