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

Refactoring GUI out of the ReportManager. #188

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Refactoring GUI out of the ReportManager. #188

wants to merge 1 commit into from

Conversation

Yoric
Copy link
Contributor

@Yoric Yoric commented Jan 14, 2022

This will let us later use the GUI code for the Trashcan.

This will let us later use the GUI code for the Trashcan.
@Yoric Yoric requested a review from Gnuxie January 14, 2022 16:57

/// Regexp, used to extract the action label from an action reaction
/// such as `⚽ Kick user @foobar:localhost from room [kick-user]`.
const REACTION_ACTION = /\[([a-z-]*)\]$/;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we look at #137 (comment) again? seems like it's been merged into spec now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. That would definitely be nicer.

This means that the feature will only work with recent versions of Synapse, though.

if (interactionRoomId === this.interactionRoomId) {
// Always accept actions executed from the interaction room.
} else {
throw new Error("Security error: Cannot execute this action.");
Copy link
Contributor

Choose a reason for hiding this comment

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

are we going to be able to see which action this is?

}
response = await action.execute(this.owner, report, interactionRoomId, this);
} catch (ex) {
error = ex;
Copy link
Contributor

Choose a reason for hiding this comment

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

do we ever log this exception or is the thinking that the Action should do that? Might be a little risky leaving it to the action

export type Actions<Owner extends { mjolnir: Mjolnir }> = [string /* label */, IUIAction<Owner>][];

export class GUIManager<Owner extends { mjolnir: Mjolnir }> {
private readonly owner: Owner;
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the owner for?

* Note: These reports end up embedded in Matrix messages, behind key `ABUSE_ACTION_CONFIRMATION_KEY`,
* so we're using Matrix naming conventions rather than JS/TS naming conventions.
*/
export interface IReportWithAction extends IReport {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this supposed to generalise the reaction based UI? then why would we have report stuff in this file?

}

export function getHomeserver(userId: string): string {
return new UserID(userId).domain
Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, that's nice that matrix-bot-sdk has that 😺

/**
* A user action displayed in the UI as a Matrix reaction.
*/
export interface IUIAction<Manager extends { mjolnir: Mjolnir }> {
Copy link
Contributor

Choose a reason for hiding this comment

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

So is the manager a GuiManager or is it one of these owners or something else?

const REACTION_CONFIRMATION = /\[([a-z-]*)\]\[([a-z-]*)\]$/;

export const NATURE_DESCRIPTIONS_LIST: readonly [string, string][] = Object.freeze([
["org.matrix.msc3215.abuse.nature.disagreement", "disagreement"],
Copy link
Contributor

Choose a reason for hiding this comment

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

this is good, are we keeping that MSC alive?

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