mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-30 02:03:16 +00:00
Update DirectMessageController, fix ordering bug
This commit is contained in:
parent
bcc8b8842f
commit
044d410c49
1 changed files with 12 additions and 9 deletions
|
@ -421,9 +421,10 @@ class DirectMessageController extends Controller
|
||||||
if ($min_id) {
|
if ($min_id) {
|
||||||
$res = DirectMessage::select('*')
|
$res = DirectMessage::select('*')
|
||||||
->where('id', '>', $min_id)
|
->where('id', '>', $min_id)
|
||||||
->where(function ($q) use ($pid, $uid) {
|
->where(function ($query) use ($pid, $uid) {
|
||||||
return $q->where([['from_id', $pid], ['to_id', $uid],
|
$query->where('from_id', $pid)->where('to_id', $uid);
|
||||||
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
})->orWhere(function ($query) use ($pid, $uid) {
|
||||||
|
$query->where('from_id', $uid)->where('to_id', $pid);
|
||||||
})
|
})
|
||||||
->orderBy('id', 'asc')
|
->orderBy('id', 'asc')
|
||||||
->take(8)
|
->take(8)
|
||||||
|
@ -432,17 +433,19 @@ class DirectMessageController extends Controller
|
||||||
} elseif ($max_id) {
|
} elseif ($max_id) {
|
||||||
$res = DirectMessage::select('*')
|
$res = DirectMessage::select('*')
|
||||||
->where('id', '<', $max_id)
|
->where('id', '<', $max_id)
|
||||||
->where(function ($q) use ($pid, $uid) {
|
->where(function ($query) use ($pid, $uid) {
|
||||||
return $q->where([['from_id', $pid], ['to_id', $uid],
|
$query->where('from_id', $pid)->where('to_id', $uid);
|
||||||
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
})->orWhere(function ($query) use ($pid, $uid) {
|
||||||
|
$query->where('from_id', $uid)->where('to_id', $pid);
|
||||||
})
|
})
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
->take(8)
|
->take(8)
|
||||||
->get();
|
->get();
|
||||||
} else {
|
} else {
|
||||||
$res = DirectMessage::where(function ($q) use ($pid, $uid) {
|
$res = DirectMessage::where(function ($query) use ($pid, $uid) {
|
||||||
return $q->where([['from_id', $pid], ['to_id', $uid],
|
$query->where('from_id', $pid)->where('to_id', $uid);
|
||||||
])->orWhere([['from_id', $uid], ['to_id', $pid]]);
|
})->orWhere(function ($query) use ($pid, $uid) {
|
||||||
|
$query->where('from_id', $uid)->where('to_id', $pid);
|
||||||
})
|
})
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
->take(8)
|
->take(8)
|
||||||
|
|
Loading…
Reference in a new issue