Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement room reader method to get messages in a room #770

Merged
merged 8 commits into from
Jul 19, 2024

Conversation

Dnouv
Copy link
Member

@Dnouv Dnouv commented Jun 20, 2024

What? β›΅

  • Restore: cfc0a0b and 5284a5f; Implement room bridge getMessage
  • Add a map from Apps Engine's dev-friendly sort params to mongoDB sort params
  • Adds the limit check

Why? πŸ€”

Links 🌎

JIRA

PS πŸ‘€

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

PostMessageSent sample code for testing the bridge
async executePostMessageSent(
        message: IMessage,
        read: IRead,
        http: IHttp,
        persistence: IPersistence,
        modify: IModify
    ): Promise<void> {
        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();
    }

@d-gubert d-gubert changed the title feat: Apps-Engine method to read multiple messages from a room by roomId feat: implement room reader method to get messages in a room Jul 19, 2024
@d-gubert d-gubert merged commit aec2401 into alpha Jul 19, 2024
8 checks passed
@d-gubert d-gubert deleted the new/room_msg_bridge branch July 19, 2024 00:27
@d-gubert d-gubert mentioned this pull request Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants