From 7cf70b64b80be6ec06f4b68679ecf6995b0639f3 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 30 Dec 2016 22:31:21 +0000 Subject: [PATCH] We now send the participation message as well. --- include/delivery.php | 9 --------- include/diaspora.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/include/delivery.php b/include/delivery.php index f7245942a9..e9f4264641 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -518,15 +518,6 @@ function delivery_run(&$argv, &$argc){ if (!$contact['pubkey'] && !$public_message) break; - $unsupported_activities = array(ACTIVITY_DISLIKE, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE); - - //don't transmit activities which are not supported by diaspora - foreach($unsupported_activities as $act) { - if (activity_match($target_item['verb'],$act)) { - break 2; - } - } - if (($target_item['deleted']) && (($target_item['uri'] === $target_item['parent-uri']) || $followup)) { // top-level retraction logger('diaspora retract: '.$loc); diff --git a/include/diaspora.php b/include/diaspora.php index 72b9537416..a6e6e5cf76 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -3160,6 +3160,45 @@ class Diaspora { "diaspora_handle" => self::my_handle($owner))); } + /** + * @brief Creates an "EventParticipation" object + * + * @param array $item The item that will be exported + * @param array $owner the array of the item owner + * + * @return array The data for an "EventParticipation" + */ + private static function construct_attend($item, $owner) { + + $p = q("SELECT `guid`, `uri`, `parent-uri` FROM `item` WHERE `uri` = '%s' LIMIT 1", + dbesc($item["thr-parent"])); + if (!dbm::is_result($p)) + return false; + + $parent = $p[0]; + + switch ($item['verb']) { + case ACTIVITY_ATTEND: + $attend_answer = 'accepted'; + break; + case ACTIVITY_ATTENDNO: + $attend_answer = 'declined'; + break; + case ACTIVITY_ATTENDMAYBE: + $attend_answer = 'tentative'; + break; + default: + logger('Unknown verb '.$item['verb'].' in item '.$item['guid']); + return false; + } + + return(array("author" => self::my_handle($owner), + "guid" => $item["guid"], + "parent_guid" => $parent["guid"], + "status" => $attend_answer, + "author_signature" => "")); + } + /** * @brief Creates the object for a comment * @@ -3209,7 +3248,10 @@ class Diaspora { */ public static function send_followup($item,$owner,$contact,$public_batch = false) { - if($item['verb'] === ACTIVITY_LIKE) { + if (in_array($item['verb'], array(ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE))) { + $message = self::construct_attend($item, $owner); + $type = "event_participation"; + } elseif($item['verb'] === ACTIVITY_LIKE) { $message = self::construct_like($item, $owner); $type = "like"; } else { -- 2.39.5