-
Notifications
You must be signed in to change notification settings - Fork 56
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
base: main
Are you sure you want to change the base?
Conversation
This will let us later use the GUI code for the Trashcan.
|
||
/// 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-]*)\]$/; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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."); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 }> { |
There was a problem hiding this comment.
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"], |
There was a problem hiding this comment.
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?
This will let us later use the GUI code for the Trashcan.