[PLUGIN][ActivityPub][Model][Note] Replace our directMessage extension with LitePub's
This commit is contained in:
parent
bc3d5245f5
commit
af02bc7b32
@ -52,15 +52,15 @@ class ActivityCreate extends Activity
|
||||
protected static function handle_core_activity(\App\Entity\Actor $actor, AbstractObject $type_activity, mixed $type_object, ?ActivitypubActivity &$ap_act): ActivitypubActivity
|
||||
{
|
||||
if ($type_object instanceof AbstractObject) {
|
||||
if ($type_object->get('type') === 'Note' || $type_object->get('type') === 'Page') {
|
||||
$actual_to = array_flip(is_string($type_object->get('to')) ? [$type_object->get('to')] : $type_object->get('to'));
|
||||
$actual_cc = array_flip(is_string($type_object->get('cc')) ? [$type_object->get('cc')] : $type_object->get('cc'));
|
||||
foreach (is_string($type_activity->get('to')) ? [$type_activity->get('to')] : ($type_activity->get('to') ?? []) as $to) {
|
||||
if ($type_object->get('type') === 'Note' || $type_object->get('type') === 'ChatMessage' || $type_object->get('type') === 'Page') {
|
||||
$actual_to = array_flip(\is_string($type_object->get('to')) ? [$type_object->get('to')] : $type_object->get('to'));
|
||||
$actual_cc = array_flip(\is_string($type_object->get('cc')) ? [$type_object->get('cc')] : $type_object->get('cc'));
|
||||
foreach (\is_string($type_activity->get('to')) ? [$type_activity->get('to')] : ($type_activity->get('to') ?? []) as $to) {
|
||||
if ($to !== 'https://www.w3.org/ns/activitystreams#Public') {
|
||||
$actual_to[$to] = true;
|
||||
}
|
||||
}
|
||||
foreach (is_string($type_activity->get('cc')) ? [$type_activity->get('cc')] : ($type_activity->get('cc') ?? []) as $cc) {
|
||||
foreach (\is_string($type_activity->get('cc')) ? [$type_activity->get('cc')] : ($type_activity->get('cc') ?? []) as $cc) {
|
||||
if ($cc !== 'https://www.w3.org/ns/activitystreams#Public') {
|
||||
$actual_cc[$cc] = true;
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ class Note extends Model
|
||||
$map['scope'] = 'unlisted';
|
||||
} else {
|
||||
// Either Followers-only or Direct
|
||||
if ($type_note->get('directMessage') ?? false // Is DM explicitly?
|
||||
if ($type_note->get('type') === 'ChatMessage' // Is DM explicitly?
|
||||
|| (empty($type_note->get('cc')))) { // Only has TO targets
|
||||
$map['scope'] = VisibilityScope::MESSAGE;
|
||||
} else { // Then is collection
|
||||
@ -328,9 +328,9 @@ class Note extends Model
|
||||
|
||||
$attr = [
|
||||
'@context' => ActivityPub::$activity_streams_two_context,
|
||||
'type' => match ($object->getType()) {
|
||||
'type' => $object->getScope() === VisibilityScope::MESSAGE ? 'ChatMessage' : (match ($object->getType()) {
|
||||
NoteType::NOTE => 'Note', NoteType::PAGE => 'Page'
|
||||
},
|
||||
}),
|
||||
'id' => $object->getUrl(),
|
||||
'published' => $object->getCreated()->format(DateTimeInterface::RFC3339),
|
||||
'attributedTo' => $object->getActor()->getUri(Router::ABSOLUTE_URL),
|
||||
@ -342,7 +342,6 @@ class Note extends Model
|
||||
'tag' => [],
|
||||
'inReplyTo' => \is_null($object->getReplyTo()) ? null : ActivityPub::getUriByObject(GSNote::getById($object->getReplyTo())),
|
||||
'inConversation' => $object->getConversationUri(),
|
||||
'directMessage' => $object->getScope() === VisibilityScope::MESSAGE,
|
||||
];
|
||||
|
||||
// Target scope
|
||||
|
@ -80,7 +80,6 @@ class Favourite extends NoteHandlerPlugin
|
||||
'source' => $source,
|
||||
]);
|
||||
DB::persist($activity);
|
||||
|
||||
}
|
||||
return $activity;
|
||||
}
|
||||
@ -283,7 +282,7 @@ class Favourite extends NoteHandlerPlugin
|
||||
}
|
||||
if ($type_activity->get('type') === 'Like') { // Favourite
|
||||
if ($type_object instanceof \ActivityPhp\Type\AbstractObject) {
|
||||
if ($type_object->get('type') === 'Note' || $type_object->get('type') === 'Page') {
|
||||
if ($type_object->get('type') === 'Note' || $type_object->get('type') === 'ChatMessage' || $type_object->get('type') === 'Page') {
|
||||
$note = \Plugin\ActivityPub\Util\Model\Note::fromJson($type_object);
|
||||
$note_id = $note->getId();
|
||||
} else {
|
||||
|
@ -357,7 +357,7 @@ class RepeatNote extends NoteHandlerPlugin
|
||||
}
|
||||
if ($type_activity->get('type') === 'Announce') { // Repeat
|
||||
if ($type_object instanceof \ActivityPhp\Type\AbstractObject) {
|
||||
if ($type_object->get('type') === 'Note' || $type_object->get('type') === 'Page') {
|
||||
if ($type_object->get('type') === 'Note' || $type_object->get('type') === 'ChatMessage' || $type_object->get('type') === 'Page') {
|
||||
$note = \Plugin\ActivityPub\Util\Model\Note::fromJson($type_object);
|
||||
$note_id = $note->getId();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user