Navigation Menu

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

Unable to leave chat room #11239

Closed
uplift opened this issue Jan 30, 2023 · 9 comments
Closed

Unable to leave chat room #11239

uplift opened this issue Jan 30, 2023 · 9 comments
Assignees
Milestone

Comments

@uplift
Copy link
Contributor

uplift commented Jan 30, 2023

The below caller.uid needs a parseInt wrapped around it for the equality check to be true otherwise it falls into the else and errors if you arent the owner of the chat room

NodeBB/src/api/chats.js

Lines 112 to 116 in 24e58c2

if (data.uids.length === 1 && parseInt(data.uids[0], 10) === caller.uid) {
await messaging.leaveRoom([caller.uid], data.roomId);
} else {
await messaging.removeUsersFromRoom(caller.uid, data.uids, data.roomId);
}

@barisusakli
Copy link
Member

What version of nodebb? And how do you reproduce? I tried to leave a room that I am not the owner of and it worked fine. caller.uid is either req.uid or socket.uid both are numbers. 🤔

@uplift
Copy link
Contributor Author

uplift commented Jan 30, 2023

v2.8.1

I forgot to add this is through the API.

The caller.uid is definitely a string if I typeof the value.

Also using Session Sharing plugin if that impacts it

@barisusakli
Copy link
Member

Can you share how you are calling the api? I want to find out how req.uid is becoming a string. Maybe add a console.log(new Error('a').stack) right before the if check

@uplift
Copy link
Contributor Author

uplift commented Jan 30, 2023

The api url is

setupApiRoute(router, 'delete', '/:roomId/users/:uid', [...middlewares, middleware.assert.room, middleware.assert.user], controllers.write.chats.kickUser);

Stack trace:-

Chats.kickUser (\src\controllers\write\chats.js:83:16)
at async \src\routes\helpers.js:73:5

@barisusakli
Copy link
Member

I meant how are you making the request to the API? via curl or something else etc?

@uplift
Copy link
Contributor Author

uplift commented Jan 30, 2023

Through our web app using Master token and ?_uid=XXX for the forum id

@barisusakli
Copy link
Member

👍🏼 I will take a look, we will probably parseInt the _uid when we get it on our side so we don't have to parseInt all the caller.uid variables everywhere.

@barisusakli
Copy link
Member

Can you test the above change?

@uplift
Copy link
Contributor Author

uplift commented Jan 30, 2023

That works great 👍

@barisusakli barisusakli modified the milestones: 2.9.0, 2.8.6 Jan 30, 2023
@barisusakli barisusakli self-assigned this Jan 30, 2023
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

2 participants