Skip to content

Add support for fetching room messages #250

@tadzik

Description

@tadzik

Is your feature request related to a problem? Please describe.

There is currently no wrapper around https://spec.matrix.org/v1.3/client-server-api/#get_matrixclientv3roomsroomidmessages to be able to load messages from a room.

Describe the solution you'd like

A nicely typed wrapper for that endpoint.

Describe alternatives you've considered

I'm currently doing this manually with doRequest but it's a bit of extra legwork that I'd rather not do:

        let from: string|undefined;
        for (;;) {
            const events = await this.matrixClient.doRequest(
                'GET',
                `/_matrix/client/v3/rooms/${encodeURIComponent(roomId)}/messages`,
                { dir: 'b', limit: 100, from },
            );
            for (const ev of events.chunk) {
                if (ev.type === 'm.room.create') {
                    break;
                } else if (ev.type === interestingEventType) {
                    interestingEvents.push(ev.content);
                }
            }
            if (from === events.end) break;
            from = events.end;
        }
        // use interestingEvents

The above could serve as an inspiration for the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions