+ /**
+ * @brief sends a participation (Used to get all further updates)
+ *
+ * @param array $contact Target of the communication
+ * @param array $item Item array
+ *
+ * @return int The result of the transmission
+ */
+ private static function sendParticipation($contact, $item)
+ {
+ // Don't send notifications for private postings
+ if ($item['private']) {
+ return;
+ }
+
+ $cachekey = "diaspora:sendParticipation:".$item['guid'];
+
+ $result = Cache::get($cachekey);
+ if (!is_null($result)) {
+ return;
+ }
+
+ // Fetch some user id to have a valid handle to transmit the participation.
+ // In fact it doesn't matter which user sends this - but it is needed by the protocol.
+ // If the item belongs to a user, we take this user id.
+ if ($item['uid'] == 0) {
+ $condition = ['verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false];
+ $first_user = dba::selectFirst('user', ['uid'], $condition);
+ $owner = User::getOwnerDataById($first_user['uid']);
+ } else {
+ $owner = User::getOwnerDataById($item['uid']);
+ }
+
+ $author = self::myHandle($owner);
+
+ $message = ["author" => $author,
+ "guid" => get_guid(32),
+ "parent_type" => "Post",
+ "parent_guid" => $item["guid"]];
+
+ logger("Send participation for ".$item["guid"]." by ".$author, LOGGER_DEBUG);
+
+ // It doesn't matter what we store, we only want to avoid sending repeated notifications for the same item
+ Cache::set($cachekey, $item["guid"], CACHE_QUARTER_HOUR);
+
+ return self::buildAndTransmit($owner, $contact, "participation", $message);
+ }
+