[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:
tenma
2019-08-13 00:05:51 +01:00
committed by Diogo Peralta Cordeiro
parent 0d9606ffbf
commit 83f179989e
5 changed files with 188 additions and 99 deletions

View File

@@ -230,22 +230,31 @@ class ShareModule extends ActivityVerbHandlerModule
*/
public function onEndShowNoticeOptionItems($nli)
{
$notice = $nli->notice;
// We shouldn't be restricting Shares for received unlisted notices,
// but without subscription_policy working we treat both this type
// and followers-only notices the same, so we also restrict both.
if (!$notice->isPublic()) {
return;
}
// FIXME: Use bitmasks (but be aware that PUBLIC_SCOPE is 0!)
// Also: AHHH, $scope and $scoped are scarily similar looking.
$scope = $nli->notice->getScope();
$scope = $notice->getScope();
if ($scope === Notice::PUBLIC_SCOPE || $scope === Notice::SITE_SCOPE) {
$scoped = Profile::current();
if ($scoped instanceof Profile &&
$scoped->getID() !== $nli->notice->getProfile()->getID()) {
$scoped->getID() !== $notice->getProfile()->getID()) {
if ($scoped->hasRepeated($nli->notice)) {
if ($scoped->hasRepeated($notice)) {
$nli->out->element('span', array('class' => 'repeated',
// TRANS: Title for repeat form status in notice list when a notice has been repeated.
'title' => _('Notice repeated.')),
// TRANS: Repeat form status in notice list when a notice has been repeated.
_('Repeated'));
} else {
$repeat = new RepeatForm($nli->out, $nli->notice);
$repeat = new RepeatForm($nli->out, $notice);
$repeat->show();
}
}