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

[FR] get EventID details #125

Closed
wuast94 opened this issue Oct 16, 2024 · 1 comment
Closed

[FR] get EventID details #125

wuast94 opened this issue Oct 16, 2024 · 1 comment

Comments

@wuast94
Copy link

wuast94 commented Oct 16, 2024

Becouse i played around a bit with reactions and how to get the message from a reacted message i just wanted to leave my code here and hope it helps. would be nice to have a node that returns informations about an eventID

let matrixClient = global.get("matrixClient['@user:domain.tld']"),
    matrixOnline = global.get("matrixClientOnline['@user:domain.tld']");

if (!matrixOnline) {
    msg.error = 'Matrix client not connected.';
    return [null, msg];
}

const roomId = msg.roomId;
const eventId = msg.eventId;
const room = matrixClient.getRoom(roomId);

if (room) {
    const event = room.findEventById(eventId);
    if (event) {
        msg.eventDetails = {
            eventId: event.getId(),
            sender: event.getSender(),
            type: event.getType(),
            content: event.getContent(),
            timestamp: event.getTs()
        };
        node.send([msg, null]);
    } else {
        msg.error = 'Event not found.';
        node.send([null, msg]);
    }
} else {
    msg.error = 'Room not found.';
    node.send([null, msg]);
}
@skylord123
Copy link
Contributor

Next release will have a new Get Event node described here:
#117

Also I added another node for the next release called Fetch Event Relations that let you paginate all events that relate to a specific eventId (such as thread messages, reactions, etc). So this will probably be useful for you as well. That is done under #119

I'm going to close this as a duplicate of #117

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

No branches or pull requests

2 participants