Update Notification logic, remove message and rendered fields

This commit is contained in:
Daniel Supernault 2023-05-12 23:15:41 -06:00
parent eb5bb9fede
commit 6cdb5bc672
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
12 changed files with 4 additions and 41 deletions

View file

@ -368,8 +368,6 @@ class DirectMessageController extends Controller
$notification->profile_id = $recipient->id;
$notification->actor_id = $profile->id;
$notification->action = 'dm';
$notification->message = $dm->toText();
$notification->rendered = $dm->toHtml();
$notification->item_id = $dm->id;
$notification->item_type = "App\DirectMessage";
$notification->save();

View file

@ -328,8 +328,6 @@ class StoryApiV1Controller extends Controller
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->action = 'story:comment';
$n->message = "{$request->user()->username} commented on story";
$n->rendered = "{$request->user()->username} commented on story";
$n->save();
} else {
StoryReplyDeliver::dispatch($story, $status)->onQueue('story');

View file

@ -442,8 +442,6 @@ class StoryComposeController extends Controller
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->action = 'story:react';
$n->message = "{$request->user()->username} reacted to your story";
$n->rendered = "{$request->user()->username} reacted to your story";
$n->save();
} else {
StoryReactionDeliver::dispatch($story, $status)->onQueue('story');
@ -516,8 +514,6 @@ class StoryComposeController extends Controller
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->action = 'story:comment';
$n->message = "{$request->user()->username} commented on story";
$n->rendered = "{$request->user()->username} commented on story";
$n->save();
} else {
StoryReplyDeliver::dispatch($story, $status)->onQueue('story');

View file

@ -94,8 +94,6 @@ class CommentPipeline implements ShouldQueue
$notification->profile_id = $target->id;
$notification->actor_id = $actor->id;
$notification->action = 'comment';
$notification->message = $comment->replyToText();
$notification->rendered = $comment->replyToHtml();
$notification->item_id = $comment->id;
$notification->item_type = "App\Status";
$notification->save();

View file

@ -97,8 +97,6 @@ class FollowPipeline implements ShouldQueue
$notification->profile_id = $target->id;
$notification->actor_id = $actor->id;
$notification->action = 'follow';
$notification->message = $follower->toText();
$notification->rendered = $follower->toHtml();
$notification->item_id = $target->id;
$notification->item_type = "App\Profile";
$notification->save();

View file

@ -84,8 +84,6 @@ class LikePipeline implements ShouldQueue
$notification->profile_id = $status->profile_id;
$notification->actor_id = $actor->id;
$notification->action = 'like';
$notification->message = $like->toText($status->in_reply_to_id ? 'comment' : 'post');
$notification->rendered = $like->toHtml($status->in_reply_to_id ? 'comment' : 'post');
$notification->item_id = $status->id;
$notification->item_type = "App\Status";
$notification->save();

View file

@ -67,10 +67,6 @@ class MentionPipeline implements ShouldQueue
'action' => 'mention',
'item_type' => 'App\Status',
'item_id' => $status->id,
],
[
'message' => $mention->toText(),
'rendered' => $mention->toHtml()
]
);

View file

@ -76,10 +76,6 @@ class SharePipeline implements ShouldQueue
'action' => 'share',
'item_type' => 'App\Status',
'item_id' => $status->reblog_of_id ?? $status->id,
],
[
'message' => $status->shareToText(),
'rendered' => $status->shareToHtml()
]
);

View file

@ -90,8 +90,6 @@ class StatusReplyPipeline implements ShouldQueue
$notification->profile_id = $target->id;
$notification->actor_id = $actor->id;
$notification->action = 'comment';
$notification->message = $status->replyToText();
$notification->rendered = $status->replyToHtml();
$notification->item_id = $status->id;
$notification->item_type = "App\Status";
$notification->save();

View file

@ -74,16 +74,13 @@ class MediaTagService
{
$p = $tag->status->profile;
$actor = $p->username;
$message = "{$actor} tagged you in a post.";
$rendered = "<a href='/{$actor}' class='profile-link'>{$actor}</a> tagged you in a post.";
$n = new Notification;
$n->profile_id = $tag->profile_id;
$n->actor_id = $p->id;
$n->item_id = $tag->id;
$n->item_type = 'App\MediaTag';
$n->action = 'tagged';
$n->message = $message;
$n->rendered = $rendered;
$n->save();
return;
}

View file

@ -23,8 +23,10 @@ class NotificationTransformer extends Fractal\TransformerAbstract
if($n->actor_id) {
$res['account'] = AccountService::get($n->actor_id);
if($n->profile_id != $n->actor_id) {
$res['relationship'] = RelationshipService::get($n->actor_id, $n->profile_id);
}
}
if($n->item_id && $n->item_type == 'App\Status') {
$res['status'] = StatusService::get($n->item_id, false);
@ -66,11 +68,8 @@ class NotificationTransformer extends Fractal\TransformerAbstract
'comment' => 'comment',
'admin.user.modlog.comment' => 'modlog',
'tagged' => 'tagged',
'group:comment' => 'group:comment',
'story:react' => 'story:react',
'story:comment' => 'story:comment',
'group:join:approved' => 'group:join:approved',
'group:join:rejected' => 'group:join:rejected'
];
if(!isset($verbs[$verb])) {

View file

@ -483,8 +483,6 @@ class Inbox
$notification->profile_id = $profile->id;
$notification->actor_id = $actor->id;
$notification->action = 'dm';
$notification->message = $dm->toText();
$notification->rendered = $dm->toHtml();
$notification->item_id = $dm->id;
$notification->item_type = "App\DirectMessage";
$notification->save();
@ -594,9 +592,6 @@ class Inbox
'action' => 'share',
'item_id' => $parent->id,
'item_type' => 'App\Status',
], [
'message' => $status->replyToText(),
'rendered' => $status->replyToHtml(),
]
);
@ -1023,8 +1018,6 @@ class Inbox
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->action = 'story:react';
$n->message = "{$actorProfile->username} reacted to your story";
$n->rendered = "{$actorProfile->username} reacted to your story";
$n->save();
return;
@ -1134,8 +1127,6 @@ class Inbox
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->action = 'story:comment';
$n->message = "{$actorProfile->username} commented on story";
$n->rendered = "{$actorProfile->username} commented on story";
$n->save();
return;