-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(models): Use Messages Raw model (5/N) (#28590)
- Loading branch information
1 parent
4dfe071
commit a791efa
Showing
17 changed files
with
145 additions
and
159 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
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
18 changes: 0 additions & 18 deletions
18
apps/meteor/app/channel-settings/server/functions/saveRoomReadOnly.js
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
apps/meteor/app/channel-settings/server/functions/saveRoomReadOnly.ts
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,30 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { Match } from 'meteor/check'; | ||
import { Rooms, Messages } from '@rocket.chat/models'; | ||
import type { IUser } from '@rocket.chat/core-typings'; | ||
|
||
import { settings } from '../../../settings/server'; | ||
|
||
export async function saveRoomReadOnly( | ||
rid: string, | ||
readOnly: boolean, | ||
user: Required<Pick<IUser, '_id' | 'username' | 'name'>>, | ||
sendMessage = true, | ||
) { | ||
if (!Match.test(rid, String)) { | ||
throw new Meteor.Error('invalid-room', 'Invalid room', { | ||
function: 'RocketChat.saveRoomReadOnly', | ||
}); | ||
} | ||
|
||
const result = await Rooms.setReadOnlyById(rid, readOnly); | ||
|
||
if (result && sendMessage) { | ||
if (readOnly) { | ||
await Messages.createRoomSetReadOnlyByRoomIdAndUser(rid, user, settings.get('Message_Read_Receipt_Enabled')); | ||
} else { | ||
await Messages.createRoomRemovedReadOnlyByRoomIdAndUser(rid, user, settings.get('Message_Read_Receipt_Enabled')); | ||
} | ||
} | ||
return result; | ||
} |
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
Oops, something went wrong.