|
|
|
@ -3,9 +3,10 @@ import { Random } from 'meteor/random'; |
|
|
|
|
|
|
|
|
|
import { hasPermission } from '../../../authorization'; |
|
|
|
|
import { Notifications } from '../../../notifications'; |
|
|
|
|
import { Invites, Subscriptions } from '../../../models'; |
|
|
|
|
import { Invites, Subscriptions, Rooms } from '../../../models/server'; |
|
|
|
|
import { settings } from '../../../settings'; |
|
|
|
|
import { getURL } from '../../../utils/lib/getURL'; |
|
|
|
|
import { roomTypes, RoomMemberActions } from '../../../utils/server'; |
|
|
|
|
|
|
|
|
|
function getInviteUrl(invite) { |
|
|
|
|
const { _id } = invite; |
|
|
|
@ -40,6 +41,11 @@ export const findOrCreateInvite = (userId, invite) => { |
|
|
|
|
throw new Meteor.Error('error-invalid-room', 'The rid field is invalid', { method: 'findOrCreateInvite', field: 'rid' }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const room = Rooms.findOneById(invite.rid); |
|
|
|
|
if (!roomTypes.getConfig(room.t).allowMemberAction(room, RoomMemberActions.INVITE)) { |
|
|
|
|
throw new Meteor.Error('error-room-type-not-allowed', 'Cannot create invite links for this room type', { method: 'findOrCreateInvite' }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let { days, maxUses } = invite; |
|
|
|
|
|
|
|
|
|
if (!possibleDays.includes(days)) { |
|
|
|
|