mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-26 09:46:49 +00:00
Update DirectMessageController to support new Metro 2.0 UI DMs
This commit is contained in:
parent
d43908780f
commit
a4659fd2ab
1 changed files with 61 additions and 11 deletions
|
@ -19,6 +19,8 @@ use App\Services\MediaBlocklistService;
|
|||
use App\Jobs\StatusPipeline\NewStatusPipeline;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
use App\Services\AccountService;
|
||||
use App\Services\StatusService;
|
||||
use App\Services\WebfingerService;
|
||||
use App\Models\Conversation;
|
||||
|
||||
|
@ -435,8 +437,10 @@ class DirectMessageController extends Controller
|
|||
->get();
|
||||
}
|
||||
|
||||
|
||||
$res = $res->map(function($s) use ($uid){
|
||||
$res = $res->filter(function($s) {
|
||||
return $s && $s->status;
|
||||
})
|
||||
->map(function($s) use ($uid) {
|
||||
return [
|
||||
'id' => (string) $s->id,
|
||||
'hidden' => (bool) $s->is_hidden,
|
||||
|
@ -449,7 +453,8 @@ class DirectMessageController extends Controller
|
|||
'reportId' => (string) $s->status_id,
|
||||
'meta' => json_decode($s->meta,true)
|
||||
];
|
||||
});
|
||||
})
|
||||
->values();
|
||||
|
||||
$w = [
|
||||
'id' => (string) $r->id,
|
||||
|
@ -488,11 +493,56 @@ class DirectMessageController extends Controller
|
|||
$status = Status::whereProfileId($pid)
|
||||
->findOrFail($dm->status_id);
|
||||
|
||||
if($dm->recipient->domain) {
|
||||
$recipient = AccountService::get($dm->to_id);
|
||||
|
||||
if(!$recipient) {
|
||||
return response('', 422);
|
||||
}
|
||||
|
||||
if($recipient['local'] == false) {
|
||||
$dmc = $dm;
|
||||
$this->remoteDelete($dmc);
|
||||
}
|
||||
|
||||
if(Conversation::whereStatusId($sid)->count()) {
|
||||
$latest = DirectMessage::where(['from_id' => $dm->from_id, 'to_id' => $dm->to_id])
|
||||
->orWhere(['to_id' => $dm->from_id, 'from_id' => $dm->to_id])
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if($latest->status_id == $sid) {
|
||||
Conversation::where(['to_id' => $dm->from_id, 'from_id' => $dm->to_id])
|
||||
->update([
|
||||
'updated_at' => $latest->updated_at,
|
||||
'status_id' => $latest->status_id,
|
||||
'type' => $latest->type,
|
||||
'is_hidden' => false
|
||||
]);
|
||||
|
||||
Conversation::where(['to_id' => $dm->to_id, 'from_id' => $dm->from_id])
|
||||
->update([
|
||||
'updated_at' => $latest->updated_at,
|
||||
'status_id' => $latest->status_id,
|
||||
'type' => $latest->type,
|
||||
'is_hidden' => false
|
||||
]);
|
||||
} else {
|
||||
Conversation::where([
|
||||
'status_id' => $sid,
|
||||
'to_id' => $dm->from_id,
|
||||
'from_id' => $dm->to_id
|
||||
])->delete();
|
||||
|
||||
Conversation::where([
|
||||
'status_id' => $sid,
|
||||
'from_id' => $dm->from_id,
|
||||
'to_id' => $dm->to_id
|
||||
])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
StatusService::del($status->id, true);
|
||||
|
||||
$status->delete();
|
||||
$dm->delete();
|
||||
|
||||
|
|
Loading…
Reference in a new issue