RocketChat/Rocket.Chat

View on GitHub
apps/meteor/app/federation/server/lib/context.ts

Summary

Maintainability
A
0 mins
Test Coverage
export const contextDefinitions = {
    ROOM: {
        type: 'room' as const,
        isRoom(event: { context: { roomId?: string } }): boolean {
            return !!event.context.roomId;
        },
        contextQuery(roomId: string) {
            return { roomId };
        },
    },

    defineType(event: { context: { roomId?: string } }): 'room' | 'undefined' {
        if (this.ROOM.isRoom(event)) {
            return this.ROOM.type;
        }

        return 'undefined';
    },
};