mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-22 07:42:41 +00:00
Update DirectMessageController, fix ordering bug
This commit is contained in:
parent
8c58d20700
commit
bcc8b8842f
1 changed files with 9 additions and 6 deletions
|
@ -372,7 +372,7 @@ class DirectMessageController extends Controller
|
||||||
->exists();
|
->exists();
|
||||||
|
|
||||||
if ($recipient->domain == null && $hidden == false && ! $nf) {
|
if ($recipient->domain == null && $hidden == false && ! $nf) {
|
||||||
$notification = new Notification();
|
$notification = new Notification;
|
||||||
$notification->profile_id = $recipient->id;
|
$notification->profile_id = $recipient->id;
|
||||||
$notification->actor_id = $profile->id;
|
$notification->actor_id = $profile->id;
|
||||||
$notification->action = 'dm';
|
$notification->action = 'dm';
|
||||||
|
@ -405,6 +405,8 @@ class DirectMessageController extends Controller
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'pid' => 'required',
|
'pid' => 'required',
|
||||||
|
'max_id' => 'sometimes|integer',
|
||||||
|
'min_id' => 'sometimes|integer',
|
||||||
]);
|
]);
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
abort_if($user->has_roles && ! UserRoleService::can('can-direct-message', $user->id), 403, 'Invalid permissions for this action');
|
abort_if($user->has_roles && ! UserRoleService::can('can-direct-message', $user->id), 403, 'Invalid permissions for this action');
|
||||||
|
@ -423,9 +425,10 @@ class DirectMessageController extends Controller
|
||||||
return $q->where([['from_id', $pid], ['to_id', $uid],
|
return $q->where([['from_id', $pid], ['to_id', $uid],
|
||||||
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
||||||
})
|
})
|
||||||
->latest()
|
->orderBy('id', 'asc')
|
||||||
->take(8)
|
->take(8)
|
||||||
->get();
|
->get()
|
||||||
|
->reverse();
|
||||||
} elseif ($max_id) {
|
} elseif ($max_id) {
|
||||||
$res = DirectMessage::select('*')
|
$res = DirectMessage::select('*')
|
||||||
->where('id', '<', $max_id)
|
->where('id', '<', $max_id)
|
||||||
|
@ -433,7 +436,7 @@ class DirectMessageController extends Controller
|
||||||
return $q->where([['from_id', $pid], ['to_id', $uid],
|
return $q->where([['from_id', $pid], ['to_id', $uid],
|
||||||
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
||||||
})
|
})
|
||||||
->latest()
|
->orderBy('id', 'desc')
|
||||||
->take(8)
|
->take(8)
|
||||||
->get();
|
->get();
|
||||||
} else {
|
} else {
|
||||||
|
@ -441,7 +444,7 @@ class DirectMessageController extends Controller
|
||||||
return $q->where([['from_id', $pid], ['to_id', $uid],
|
return $q->where([['from_id', $pid], ['to_id', $uid],
|
||||||
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
||||||
})
|
})
|
||||||
->latest()
|
->orderBy('id', 'desc')
|
||||||
->take(8)
|
->take(8)
|
||||||
->get();
|
->get();
|
||||||
}
|
}
|
||||||
|
@ -636,7 +639,7 @@ class DirectMessageController extends Controller
|
||||||
$status->in_reply_to_profile_id = $recipient->id;
|
$status->in_reply_to_profile_id = $recipient->id;
|
||||||
$status->save();
|
$status->save();
|
||||||
|
|
||||||
$media = new Media();
|
$media = new Media;
|
||||||
$media->status_id = $status->id;
|
$media->status_id = $status->id;
|
||||||
$media->profile_id = $profile->id;
|
$media->profile_id = $profile->id;
|
||||||
$media->user_id = $user->id;
|
$media->user_id = $user->id;
|
||||||
|
|
Loading…
Reference in a new issue