Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there is a way to check if a member already messaged another member? #455

Open
ranfen opened this issue Aug 15, 2022 · 9 comments
Open

Comments

@ranfen
Copy link

ranfen commented Aug 15, 2022

Using REST API endpoint Is there is a way to check if a member already messaged another member? Or they never messaged each other?

We already check the documentation, but we can't find a special endpoint for it

thanks

@renatonascalves
Copy link
Member

No endpoint performs this specific check, but I think you can use https://developer.buddypress.org/bp-rest-api/reference/private-messaging/#list-messages-threads to get a user list of thread messages and compare it against this other user.

@ranfen
Copy link
Author

ranfen commented Aug 17, 2022

No endpoint performs this specific check, but I think you can use https://developer.buddypress.org/bp-rest-api/reference/private-messaging/#list-messages-threads to get a user list of thread messages and compare it against this other user.

Thank you for the answer,
for now that what we are planning to do, but the problem is if the: get user list of threads only give last 10 threads and the thread with user we are trying to compare against is not returned in the last 10, this way we will not be able to make sure if there was a thread and I don't see a way to get second page for list of threads like we do in activities, even if there is a way it will be not good idea to keep calling the server again and again to compare against every page? Can you please plan to add an endpoint for it, it will be much faster, thank you

@renatonascalves
Copy link
Member

Could you elaborate more on ,what, and how, you are trying to do?

If you have an app, for example, that lists the threads of a user, why would you need to check if a thread/message was already created for another specific user unrelated to the current user?

Can you please plan to add an endpoint for it, it will be much faster, thank you

It'd be good to know what problem this is solving. We definitely can't add new endpoints to support specific features for everyone. A first look tells me this is something you should create yourself instead of bundling into BuddyPress but I'm curious about what and how you are trying to do it.

@ranfen
Copy link
Author

ranfen commented Aug 17, 2022

Could you elaborate more on ,what, and how, you are trying to do?

If you have an app, for example, that lists the threads of a user, why would you need to check if a thread/message was already created for another specific user unrelated to the current user?

Normal case
You are right, in the normal case we do not need to know if a user messaged another user, when I build a message's inbox ill just get all the threads and list them all in the inbox if there are any. That's works great.

It'd be good to know what problem this is solving. We definitely can't add new endpoints to support specific features for everyone. A first look tells me this is something you should create yourself instead of bundling into BuddyPress but I'm curious about what and how you are trying to do it.

Second case
The problem that will be solved is:
let's say I'm logged as a user and browsing the activities then I wanted to message someone privately, ill create a message button under that user profile it will open new layout with text field input where I can write my message to him

but before I load the messaging layout I would like to check if I messaged this person before or not, if never messaged him before ill show blank layout and a text field where I can write my first message
But if I messaged that user before, I would like to get the thread messages list the history of messages, so I can read all my previous messages to him then I can send more messages

I hope my explanation is clear

thank you

@renatonascalves
Copy link
Member

It looks like you want a new field on the member schema, similar to the friendship_status but checking if a user has a thread with the current logged in user.

@renatonascalves
Copy link
Member

Since you would: get the activities and the user related to the activity (including this new field with the "status" of the user, meaning if they have a thread with the current logged-in user.)

@imath
Copy link
Member

imath commented Aug 17, 2022

To my understanding it looks more like a "filter by recipient's user ID" messages need. This means, we'd need to edit BP_Messages_Thread::get_current_threads_for_user() to add an includes parameter to pass recipient ids and then add a "r.user_id IN {$includes)" clause there https://github.com/buddypress/buddypress/blob/master/src/bp-messages/classes/class-bp-messages-thread.php#L732

@ranfen
Copy link
Author

ranfen commented Aug 20, 2022

If you guys approved this and implement it please let us know, thanks

@renatonascalves
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants