mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +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 DB;
|
||||||
use App\{
|
use App\{
|
||||||
|
MediaTag,
|
||||||
Notification,
|
Notification,
|
||||||
Report,
|
Report,
|
||||||
Status,
|
Status,
|
||||||
|
@ -104,6 +105,18 @@ class StatusDelete implements ShouldQueue
|
||||||
Report::whereObjectType('App\Status')
|
Report::whereObjectType('App\Status')
|
||||||
->whereObjectId($status->id)
|
->whereObjectId($status->id)
|
||||||
->delete();
|
->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();
|
$status->forceDelete();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -37,4 +37,10 @@ class Notification extends Model
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Status::class, 'item_id', 'id');
|
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,
|
Notification,
|
||||||
Status
|
Status
|
||||||
};
|
};
|
||||||
|
use App\Services\HashidService;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
|
|
||||||
class NotificationTransformer extends Fractal\TransformerAbstract
|
class NotificationTransformer extends Fractal\TransformerAbstract
|
||||||
|
@ -97,8 +98,8 @@ class NotificationTransformer extends Fractal\TransformerAbstract
|
||||||
$ml = $n->item;
|
$ml = $n->item;
|
||||||
$res = $this->item($ml, function($ml) {
|
$res = $this->item($ml, function($ml) {
|
||||||
return [
|
return [
|
||||||
'username' => $ml->status->profile->username,
|
'username' => $ml->tagged_username,
|
||||||
'post_url' => $ml->status->url()
|
'post_url' => '/p/'.HashidService::encode($ml->status_id)
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
return $res;
|
return $res;
|
||||||
|
|
Loading…
Reference in a new issue