RocketChat / Rocket.Chat.Apps-engine

The Rocket.Chat Apps engine and definitions.
https://rocketchat.github.io/Rocket.Chat.Apps-engine/
MIT License
114 stars 119 forks source link

feat: Apps-Engine method to read multiple messages from a room by roomId #770

Open Dnouv opened 3 weeks ago

Dnouv commented 3 weeks ago

What? :boat:

Why? :thinking:

Links :earth_americas:

JIRA

PS :eyes:

Package to test the bridge: test-rmsgbridge-app_0.0.1.zip

PostMessageSent sample code for testing the bridge ```ts async executePostMessageSent( message: IMessage, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify ): Promise { this.getLogger().log("Message Sent", this.sampleData); // Helper function to test getMessages with different parameters const testGetMessages = async (params: any, description: string) => { try { const messages = await read .getRoomReader() .getMessages(message.room.id, params); console.log( `${description}:---------------\n`, messages, `--------------\nTotal Messages: ${messages.length}\n\n\n` ); } catch (error) { console.error( `Error fetching messages with ${description}:`, error ); } }; // Test cases await testGetMessages({}, "All Messages"); await testGetMessages({ limit: NaN }, "Messages with NaN Limit"); await testGetMessages( { limit: 2, skip: 1 }, "Messages with Limit and Skip" ); await testGetMessages( { skip: 1, sort: { createdAt: "asc" }, limit: 2 }, "Messages with Sort" ); return Promise.resolve(); } ```