-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/integrations-script-engine
- Loading branch information
Showing
26 changed files
with
370 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/meteor": patch | ||
--- | ||
|
||
Fixed message disappearing from room after erased even if "Show Deleted Status" is enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
apps/meteor/app/discussion/server/hooks/joinDiscussionOnMessage.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,31 @@ | ||
import type { IRoom, IRoomWithJoinCode, IUser } from '@rocket.chat/core-typings'; | ||
import { Rooms, Users } from '@rocket.chat/models'; | ||
import { Room } from '@rocket.chat/core-services'; | ||
import type { IRoom } from '@rocket.chat/core-typings'; | ||
import { Rooms } from '@rocket.chat/models'; | ||
import type { ServerMethods } from '@rocket.chat/ui-contexts'; | ||
import { check } from 'meteor/check'; | ||
import { Meteor } from 'meteor/meteor'; | ||
|
||
import { RoomMemberActions } from '../../../../definition/IRoomTypeConfig'; | ||
import { roomCoordinator } from '../../../../server/lib/rooms/roomCoordinator'; | ||
import { canAccessRoomAsync } from '../../../authorization/server'; | ||
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; | ||
import { addUserToRoom } from '../functions/addUserToRoom'; | ||
|
||
declare module '@rocket.chat/ui-contexts' { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
interface ServerMethods { | ||
joinRoom(rid: IRoom['_id'], code?: unknown): boolean | undefined; | ||
joinRoom(rid: IRoom['_id'], code?: string): boolean | undefined; | ||
} | ||
} | ||
|
||
export const joinRoomMethod = async (userId: IUser['_id'], rid: IRoom['_id'], code?: unknown): Promise<boolean | undefined> => { | ||
check(rid, String); | ||
|
||
const user = await Users.findOneById(userId); | ||
|
||
if (!user) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'joinRoom' }); | ||
} | ||
|
||
const room = await Rooms.findOneById<IRoomWithJoinCode>(rid); | ||
|
||
if (!room) { | ||
throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'joinRoom' }); | ||
} | ||
|
||
if (!(await roomCoordinator.getRoomDirectives(room.t)?.allowMemberAction(room, RoomMemberActions.JOIN, user._id))) { | ||
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'joinRoom' }); | ||
} | ||
|
||
if (!(await canAccessRoomAsync(room, user))) { | ||
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'joinRoom' }); | ||
} | ||
if (room.joinCodeRequired === true && code !== room.joinCode && !(await hasPermissionAsync(user._id, 'join-without-join-code'))) { | ||
throw new Meteor.Error('error-code-invalid', 'Invalid Room Password', { | ||
method: 'joinRoom', | ||
}); | ||
} | ||
|
||
return addUserToRoom(rid, user); | ||
}; | ||
|
||
Meteor.methods<ServerMethods>({ | ||
async joinRoom(rid, code) { | ||
check(rid, String); | ||
|
||
const userId = await Meteor.userId(); | ||
|
||
if (!userId) { | ||
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'joinRoom' }); | ||
} | ||
|
||
return joinRoomMethod(userId, rid, code); | ||
const room = await Rooms.findOneById(rid); | ||
if (!room) { | ||
throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'joinRoom' }); | ||
} | ||
|
||
return Room.join({ room, user: { _id: userId }, ...(code ? { joinCode: code } : {}) }); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.