X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=src%2FProtocol%2FActivityPub%2FTransmitter.php;h=96c069e589c94d503845e77cff7dc4d44809eceb;hb=14e7686df4250169de91c4db2912b1934cc4800f;hp=9fad787b1b19586daa97d29f97c157a00745b80d;hpb=1551570b7f1b05e83fe966ee7d2e478691b9ddd4;p=friendica.git diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 9fad787b1b..96c069e589 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -29,6 +29,10 @@ use Friendica\Core\Cache; * * To-Do: * + * Missing object fields: + * - service (App) + * - location + * * Missing object types: * - Event * @@ -205,12 +209,17 @@ class Transmitter return []; } - $fields = ['name', 'url', 'location', 'about', 'avatar']; + $fields = ['name', 'url', 'location', 'about', 'avatar', 'photo']; $contact = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]); if (!DBA::isResult($contact)) { return []; } + // On old installations and never changed contacts this might not be filled + if (empty($contact['avatar'])) { + $contact['avatar'] = $contact['photo']; + } + $data = ['@context' => ActivityPub::CONTEXT]; $data['id'] = $contact['url']; $data['diaspora:guid'] = $user['guid']; @@ -769,7 +778,6 @@ class Transmitter $data['url'] = $item['plink']; $data['attributedTo'] = $item['author-link']; - $data['actor'] = $item['author-link']; $data['sensitive'] = self::isSensitive($item['id']); $data['context'] = self::fetchContextURLForItem($item); @@ -797,6 +805,36 @@ class Transmitter return $data; } + /** + * Transmits a contact suggestion to a given inbox + * + * @param integer $uid User ID + * @param string $inbox Target inbox + * @param integer $suggestion_id Suggestion ID + */ + public static function sendContactSuggestion($uid, $inbox, $suggestion_id) + { + $owner = User::getOwnerDataById($uid); + $profile = APContact::getByURL($owner['url']); + + $suggestion = DBA::selectFirst('fsuggest', ['url', 'note', 'created'], ['id' => $suggestion_id]); + + $data = ['@context' => 'https://www.w3.org/ns/activitystreams', + 'id' => System::baseUrl() . '/activity/' . System::createGUID(), + 'type' => 'Announce', + 'actor' => $owner['url'], + 'object' => $suggestion['url'], + 'content' => $suggestion['note'], + 'published' => DateTimeFormat::utc($suggestion['created'] . '+00:00', DateTimeFormat::ATOM), + 'to' => [ActivityPub::PUBLIC_COLLECTION], + 'cc' => []]; + + $signed = LDSignature::sign($data, $owner); + + logger('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG); + HTTPSignature::transmit($signed, $inbox, $uid); + } + /** * Transmits a profile deletion to a given inbox *