Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Comments

feat: onUpdate hook for apps#778

Merged
d-gubert merged 7 commits intoalphafrom
feat/onupdate-app
Jul 11, 2024
Merged

feat: onUpdate hook for apps#778
d-gubert merged 7 commits intoalphafrom
feat/onupdate-app

Conversation

@KevLehman
Copy link
Member

@KevLehman KevLehman commented Jul 3, 2024

What? ⛵

https://rocketchat.atlassian.net/browse/CONN-289
Added hook to be called when an app is updated

Why? 🤔

Because why not 🤷🏽‍♂️
Serious: allows apps to do stuff only when an update happens, like sending messages or create cron jobs.

Links 🌎

Related PR to get user on context: RocketChat/Rocket.Chat#32719

PS 👀

@KevLehman KevLehman requested a review from d-gubert July 3, 2024 16:58
@d-gubert
Copy link
Member

d-gubert commented Jul 3, 2024

Thanks for this!

I just think we're missing here the signature for the method in the App class, like the onInstall event here for example. Regarding contextual information about the event, I'd say it would be cool to know the user who triggered the update and maybe what the previous version was? I'm open to ideas :)

@d-gubert
Copy link
Member

d-gubert commented Jul 11, 2024

Example usage:

export class ExampleApp extends App {
    public async onUpdate(context: IAppUpdateContext, read: IRead, http: IHttp, persistence: IPersistence, modify: IModify): Promise<void> {
        console.log("Hello from update", context);

        const message = modify.getCreator().startMessage();

        const room = await read.getRoomReader().getById("GENERAL");

        if (!room) {
            throw new Error('oh no');
        }

        message.setText("Hello, thank you for updating!").setRoom(room);

        await modify.getCreator().finish(message);
    }
}

@d-gubert d-gubert marked this pull request as ready for review July 11, 2024 20:45
@d-gubert d-gubert merged commit c15cfeb into alpha Jul 11, 2024
@d-gubert d-gubert deleted the feat/onupdate-app branch July 11, 2024 21:16
@d-gubert d-gubert mentioned this pull request Aug 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants