Skip to content

Add a welcome flow to Draupnir4All #568

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

Merged
merged 3 commits into from
Sep 20, 2024

Conversation

MTRNord
Copy link
Collaborator

@MTRNord MTRNord commented Sep 19, 2024

This ports

await this.bridge.getBot().getClient().joinRoom(mxEvent.room_id);
await this.bridge.getBot().getClient().sendText(mxEvent.room_id, "Your Draupnir is currently being provisioned. Please wait while we set up the rooms.");
try {
await this.mjolnirManager.provisionNewMjolnir(mxEvent.sender)
log.debug("Setting attribute on span 1")
api.trace.getSpan(api.context.active())?.setAttribute(DRAUPNIR_TRACING_ATTRIBUTES.PROVISION_OUTCOME, DRAUPNIR_RESULT.SUCCESS)
// Send a notice that the invite must be accepted
await this.bridge.getBot().getClient().sendText(mxEvent.room_id, "Please accept the invites to the newly provisioned rooms. These will be the home of your Draupnir Instance. This room will not be used in the future.");
} catch (e: any) {
log.error(`Failed to provision a mjolnir for ${mxEvent.sender} after they invited ${this.bridge.botUserId}:`, e, { traceId: api.trace.getSpan(api.context.active())?.spanContext().traceId });
log.debug("Setting attribute on span 2")
api.trace.getSpan(api.context.active())?.setAttribute(DRAUPNIR_TRACING_ATTRIBUTES.PROVISION_OUTCOME, DRAUPNIR_RESULT.FAILURE);
// continue, we still want to reject this invitation.
// Send a notive that the invite must be accepted
await this.bridge.getBot().getClient().sendText(mxEvent.room_id, "Please make sure you are allowed to provision a bot. Otherwise notify the admin please. The provisioning request was rejected.");
}
try {
// reject the invite to keep the room clean and make sure the invetee doesn't get confused and think this is their mjolnir.
await this.bridge.getBot().getClient().leaveRoom(mxEvent.room_id);
} catch (e: any) {
log.warn("Unable to reject an invite to a room", e, { traceId: api.trace.getSpan(api.context.active())?.spanContext().traceId });
}
to main. I hope the try/catch makes sense like this. meow

@MTRNord MTRNord requested a review from Gnuxie September 19, 2024 19:32
MTRNord and others added 2 commits September 20, 2024 00:12
Co-authored-by: Gnuxie <50846879+Gnuxie@users.noreply.github.com>
@Gnuxie
Copy link
Member

Gnuxie commented Sep 19, 2024

hmm one of the ci failures is genuinely an intermittent failure, worrying.

@MTRNord MTRNord merged commit 4658ba2 into main Sep 20, 2024
6 checks passed
@MTRNord MTRNord deleted the MTRNord/upstream-provisioning-welcome branch September 20, 2024 07:45
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