Skip to content
Snippets Groups Projects
Unverified Commit f27092b9 authored by Kevin Aleman's avatar Kevin Aleman Committed by GitHub
Browse files

chore: Update typings on callbacks to accept less than a full room object (#33305)

parent 3a161c43
No related merge requests found
import type { IMessage, IRoom } from '@rocket.chat/core-typings';
import type { IMessage, IRoom, AtLeast } from '@rocket.chat/core-typings';
import { settings } from '../../../settings/server';
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export const isTheLastMessage = (room: IRoom, message: Pick<IMessage, '_id'>) =>
export const isTheLastMessage = (room: AtLeast<IRoom, 'lastMessage'>, message: Pick<IMessage, '_id'>) =>
settings.get('Store_Last_Message') && (!room.lastMessage || room.lastMessage._id === message._id);
import type { AtLeast } from '@rocket.chat/core-typings';
import { type IMessage, type IRoom, isMessageFromMatrixFederation, isRoomFederated } from '@rocket.chat/core-typings';
import { isFederationEnabled, isFederationReady } from '../../federation/utils';
export class FederationActions {
public static shouldPerformAction(message: IMessage, room: IRoom): boolean {
public static shouldPerformAction(message: IMessage, room: AtLeast<IRoom, 'federated'>): boolean {
if (isMessageFromMatrixFederation(message) || isRoomFederated(room)) {
return isFederationEnabled() && isFederationReady();
}
......
import type { IMessageService } from '@rocket.chat/core-services';
import { Authorization, ServiceClassInternal } from '@rocket.chat/core-services';
import { type IMessage, type MessageTypesValues, type IUser, type IRoom, isEditedMessage } from '@rocket.chat/core-typings';
import { type IMessage, type MessageTypesValues, type IUser, type IRoom, isEditedMessage, type AtLeast } from '@rocket.chat/core-typings';
import { Messages, Rooms } from '@rocket.chat/models';
import { deleteMessage } from '../../../app/lib/server/functions/deleteMessage';
......@@ -244,7 +244,7 @@ export class MessageService extends ServiceClassInternal implements IMessageServ
// await Room.join({ room, user });
// }
async beforeReacted(message: IMessage, room: IRoom) {
async beforeReacted(message: IMessage, room: AtLeast<IRoom, 'federated'>) {
if (!FederationActions.shouldPerformAction(message, room)) {
throw new FederationMatrixInvalidConfigurationError('Unable to react to message');
}
......
import type { IMessage, MessageTypesValues, IUser, IRoom } from '@rocket.chat/core-typings';
import type { IMessage, MessageTypesValues, IUser, IRoom, AtLeast } from '@rocket.chat/core-typings';
export interface IMessageService {
sendMessage({ fromId, rid, msg }: { fromId: string; rid: string; msg: string }): Promise<IMessage>;
......@@ -21,6 +21,6 @@ export interface IMessageService {
deleteMessage(user: IUser, message: IMessage): Promise<void>;
updateMessage(message: IMessage, user: IUser, originalMsg?: IMessage): Promise<void>;
reactToMessage(userId: string, reaction: string, messageId: IMessage['_id'], shouldReact?: boolean): Promise<void>;
beforeReacted(message: IMessage, room: IRoom): Promise<void>;
beforeReacted(message: IMessage, room: AtLeast<IRoom, 'federated'>): Promise<void>;
beforeDelete(message: IMessage, room: IRoom): Promise<void>;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment