-
Notifications
You must be signed in to change notification settings - Fork 13.1k
[FIX] Invite links usage by channel owners/moderators #16176
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
Changes from all commits
3ee9700
3dd007c
5903f64
a0976a4
6d78012
cb72002
8109b31
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { Meteor } from 'meteor/meteor'; | ||
|
|
||
| import { Invites, Users } from '../../../models'; | ||
| import { Invites, Users } from '../../../models/server'; | ||
| import { validateInviteToken } from './validateInviteToken'; | ||
| import { addUserToRoom } from '../../../lib/server/functions/addUserToRoom'; | ||
|
|
||
|
|
@@ -16,18 +16,20 @@ export const useInviteToken = (userId, token) => { | |
| const { inviteData, room } = validateInviteToken(token); | ||
|
|
||
| const user = Users.findOneById(userId); | ||
| Users.updateInviteToken(user._id, token); | ||
|
|
||
| if (addUserToRoom(room._id, user)) { | ||
| Invites.update(inviteData._id, { | ||
| $inc: { | ||
| uses: 1, | ||
| }, | ||
| }); | ||
| Invites.increaseUsageById(inviteData._id); | ||
|
|
||
| // If the user already has an username, then join the invite room, | ||
| // If no username is set yet, then the the join will happen on the setUsername method | ||
| if (user.username) { | ||
| addUserToRoom(room._id, user); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only need to save the token in the user (or add a list of rooms to join as my previous suggestion) on else here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We thought this could be useful information for statistics at some point, so I'm storing the token to every registered user. |
||
| } | ||
|
|
||
| return { | ||
| room: { | ||
| rid: inviteData.rid, | ||
| prid: room.prid, | ||
| fname: room.fname, | ||
| name: room.name, | ||
| t: room.t, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.