You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The whereIn('user_id', $participants) part narrows it down so each grouped result will have at most two entries, the cause of the bug.
I extended the class and wrote my own method, which omits some of the table-name/model-name-fetching aspects of the source code, but could be adapted back to the style of the original source. I had also included soft-deleted participants for my own purposes; you can omit that as appropriate:
SELECT*FROM messenger_threads
INNER JOIN (
SELECT thread_id
FROM messenger_participants
WHERE user_id IN (1429, 1507)
GROUP BY thread_id
HAVINGCOUNT(*)=2
) party ONmessenger_threads.id=party.thread_idWHERE EXISTS (
SELECT thread_id
FROM messenger_participants
WHEREparty.thread_id=messenger_participants.thread_idGROUP BY thread_id
HAVINGCOUNT(*)=2
)
Again, that would need adaptation to fit the source code, but I just leave it here as an extra resource to see the approach in use.
The text was updated successfully, but these errors were encountered:
The
scopeBetweenOnly
scope for Threads does not exclude threads that include more participants than those given in the argument.laravel-messenger/src/Models/Thread.php
Lines 216 to 226 in 765aa2d
The
whereIn('user_id', $participants)
part narrows it down so each grouped result will have at most two entries, the cause of the bug.I extended the class and wrote my own method, which omits some of the table-name/model-name-fetching aspects of the source code, but could be adapted back to the style of the original source. I had also included soft-deleted participants for my own purposes; you can omit that as appropriate:
The SQL query I modeled this after is as follows:
Again, that would need adaptation to fit the source code, but I just leave it here as an extra resource to see the approach in use.
The text was updated successfully, but these errors were encountered: