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

Add Service Room component #408

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open

Add Service Room component #408

wants to merge 12 commits into from

Conversation

Half-Shot
Copy link
Contributor

This component allows bridges to report issues with their configuration, service outages or other high level issues to a Matrix room which can then be used by other services to report issues to end users. This is intended strictly for server admins.

@Half-Shot Half-Shot marked this pull request as ready for review May 23, 2022 15:02
@Half-Shot Half-Shot requested a review from a team May 25, 2022 10:51
* a new notice with the same ID can be sent (to avoid room spam).
* Defaults to a hour.
*/
minimumUpdatePeriodMs?: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about making this non-optional and setting it to a default value in the constructor?

This would also ensure that callers won't have to handle falling back to a default value when checking this.

/**
* Any metadata to be included in all notice events.
*/
metadata: Record<string, unknown>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it help to define a type alias for this? It could be shared by both this and NotificationEventContent.metadata.

resolved: boolean;
}

const STATE_KEY_TYPE = "org.matrix.service-notice";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be named EVENT_TYPE instead?

Comment on lines +102 to +104
if (ex.body.errcode !== "M_NOT_FOUND") {
throw ex;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces -> tabs

);
}
catch (ex) {
if (ex.body.errcode !== "M_NOT_FOUND") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can getRoomStateEvent ever throw an object without a body?

public async clearServiceNotice(noticeId: string): Promise<boolean> {
const serviceNotice = await this.getServiceNotification(noticeId);
if (!serviceNotice || 'resolved' in serviceNotice) {
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about if serviceNotice.resolved is false?

(The code currently prevents that from ever happening, but maybe a future change will allow it.)

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.

None yet

2 participants