1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-21 23:32:39 +00:00

Update DirectMessageController, fix ordering bug

This commit is contained in:
Daniel Supernault 2024-11-19 02:06:25 -07:00
parent bcc8b8842f
commit 044d410c49
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -421,9 +421,10 @@ class DirectMessageController extends Controller
if ($min_id) {
$res = DirectMessage::select('*')
->where('id', '>', $min_id)
->where(function ($q) use ($pid, $uid) {
return $q->where([['from_id', $pid], ['to_id', $uid],
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
->where(function ($query) use ($pid, $uid) {
$query->where('from_id', $pid)->where('to_id', $uid);
})->orWhere(function ($query) use ($pid, $uid) {
$query->where('from_id', $uid)->where('to_id', $pid);
})
->orderBy('id', 'asc')
->take(8)
@ -432,17 +433,19 @@ class DirectMessageController extends Controller
} elseif ($max_id) {
$res = DirectMessage::select('*')
->where('id', '<', $max_id)
->where(function ($q) use ($pid, $uid) {
return $q->where([['from_id', $pid], ['to_id', $uid],
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
->where(function ($query) use ($pid, $uid) {
$query->where('from_id', $pid)->where('to_id', $uid);
})->orWhere(function ($query) use ($pid, $uid) {
$query->where('from_id', $uid)->where('to_id', $pid);
})
->orderBy('id', 'desc')
->take(8)
->get();
} else {
$res = DirectMessage::where(function ($q) use ($pid, $uid) {
return $q->where([['from_id', $pid], ['to_id', $uid],
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
$res = DirectMessage::where(function ($query) use ($pid, $uid) {
$query->where('from_id', $pid)->where('to_id', $uid);
})->orWhere(function ($query) use ($pid, $uid) {
$query->where('from_id', $uid)->where('to_id', $pid);
})
->orderBy('id', 'desc')
->take(8)