[AP] Handle unlisted/followers-only notices
Note that this commit isn't intended to add support for sending such notes in GS. Instead, we handle the reception, storage and direct reply to this type of notices, in AP. ActivityPubPlugin: - Subscribe the event StartNoticeSave to hack answering non-public notes Activitypub_create: - Add 'directMessage' attribute to the Create activity, defaulting to false for now - Update validation method: validate 'directMessage' and add debug Activitypub_notice: - Handle incoming unlisted/followers-only notes - Add support for unlisted-replies - Add method to verify private (direct) notices inbox_handler: - Add handler for CREATE Note - Prepare logic for private-messaging - Overall refactor: Class members were continuously being passed as function arguments without need SharePlugin: - Stop showing the announce button in non public posts
This commit is contained in:
@@ -256,6 +256,36 @@ class ActivityPubPlugin extends Plugin
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update notice before saving.
|
||||
* We'll use this as a hack to maintain replies to unlisted/followers-only
|
||||
* notices away from the public timelines.
|
||||
*
|
||||
* @param Notice &$notice notice to be saved
|
||||
* @return bool event hook return
|
||||
*/
|
||||
public function onStartNoticeSave(Notice &$notice): bool {
|
||||
if ($notice->reply_to) {
|
||||
try {
|
||||
$parent = $notice->getParent();
|
||||
$is_local = (int)$parent->is_local;
|
||||
|
||||
// if we're replying unlisted/followers-only notices received by AP
|
||||
// or replying to replies of such notices, then we make sure to set
|
||||
// the correct type flag.
|
||||
if ( ($parent->source === 'ActivityPub' && $is_local === Notice::GATEWAY) ||
|
||||
($parent->source === 'web' && $is_local === Notice::LOCAL_NONPUBLIC) ) {
|
||||
$this->log(LOG_INFO, "Enforcing type flag LOCAL_NONPUBLIC for new notice");
|
||||
$notice->is_local = Notice::LOCAL_NONPUBLIC;
|
||||
}
|
||||
} catch (NoParentNoticeException $e) {
|
||||
// This is not a reply to something (has no parent)
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin Nodeinfo information
|
||||
*
|
||||
|
Reference in New Issue
Block a user