mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
Update NotificationTransformer, handle tagged deletes
This commit is contained in:
parent
28f6fc5936
commit
881fa86573
3 changed files with 22 additions and 2 deletions
|
@ -4,6 +4,7 @@ namespace App\Jobs\StatusPipeline;
|
|||
|
||||
use DB;
|
||||
use App\{
|
||||
MediaTag,
|
||||
Notification,
|
||||
Report,
|
||||
Status,
|
||||
|
@ -104,6 +105,18 @@ class StatusDelete implements ShouldQueue
|
|||
Report::whereObjectType('App\Status')
|
||||
->whereObjectId($status->id)
|
||||
->delete();
|
||||
|
||||
MediaTag::where('status_id', $status->id)
|
||||
->cursor()
|
||||
->each(function($tag) {
|
||||
Notification::where('item_type', 'App\MediaTag')
|
||||
->where('item_id', $tag->id)
|
||||
->forceDelete();
|
||||
$tag->delete();
|
||||
});
|
||||
|
||||
MediaTag::whereStatusId($status->id)
|
||||
->get();
|
||||
$status->forceDelete();
|
||||
});
|
||||
|
||||
|
|
|
@ -37,4 +37,10 @@ class Notification extends Model
|
|||
{
|
||||
return $this->belongsTo(Status::class, 'item_id', 'id');
|
||||
}
|
||||
|
||||
public function tag()
|
||||
{
|
||||
return $this->hasOne(MediaTag::class, 'item_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\{
|
|||
Notification,
|
||||
Status
|
||||
};
|
||||
use App\Services\HashidService;
|
||||
use League\Fractal;
|
||||
|
||||
class NotificationTransformer extends Fractal\TransformerAbstract
|
||||
|
@ -97,8 +98,8 @@ class NotificationTransformer extends Fractal\TransformerAbstract
|
|||
$ml = $n->item;
|
||||
$res = $this->item($ml, function($ml) {
|
||||
return [
|
||||
'username' => $ml->status->profile->username,
|
||||
'post_url' => $ml->status->url()
|
||||
'username' => $ml->tagged_username,
|
||||
'post_url' => '/p/'.HashidService::encode($ml->status_id)
|
||||
];
|
||||
});
|
||||
return $res;
|
||||
|
|
Loading…
Reference in a new issue