@@ -102,10 +102,32 @@ enum Kind {
102102 ESCALATED_REPORT ,
103103}
104104
105+ export interface ReportManager {
106+ handleTimelineEvent ( roomID : StringRoomID , event : RoomEvent ) : void ;
107+ handleServerAbuseReport ( {
108+ roomID,
109+ reporterId,
110+ event,
111+ reason,
112+ } : {
113+ roomID : StringRoomID ;
114+ reporterId : string ;
115+ event : RoomEvent ;
116+ reason ?: string ;
117+ } ) : Promise < void > ;
118+ handleReaction ( {
119+ roomID,
120+ event,
121+ } : {
122+ roomID : StringRoomID ;
123+ event : RoomEvent ;
124+ } ) : Promise < void > ;
125+ }
126+
105127/**
106128 * A class designed to respond to abuse reports.
107129 */
108- export class ReportManager {
130+ export class StandardReportManager {
109131 private displayManager : DisplayManager ;
110132 constructor ( public draupnir : Draupnir ) {
111133 this . displayManager = new DisplayManager ( this ) ;
@@ -580,7 +602,7 @@ interface IUIAction {
580602 * @param report Details on the abuse report.
581603 */
582604 canExecute (
583- manager : ReportManager ,
605+ manager : StandardReportManager ,
584606 report : IReport ,
585607 moderationroomID : string
586608 ) : Promise < boolean > ;
@@ -590,20 +612,20 @@ interface IUIAction {
590612 *
591613 * @param report Details on the abuse report.
592614 */
593- title ( manager : ReportManager , report : IReport ) : Promise < string > ;
615+ title ( manager : StandardReportManager , report : IReport ) : Promise < string > ;
594616
595617 /**
596618 * A human-readable help message to display for the end-user.
597619 *
598620 * @param report Details on the abuse report.
599621 */
600- help ( manager : ReportManager , report : IReport ) : Promise < string > ;
622+ help ( manager : StandardReportManager , report : IReport ) : Promise < string > ;
601623
602624 /**
603625 * Attempt to execute the action.
604626 */
605627 execute (
606- manager : ReportManager ,
628+ manager : StandardReportManager ,
607629 report : IReport ,
608630 moderationroomID : string ,
609631 displayManager : DisplayManager
@@ -618,25 +640,25 @@ class IgnoreBadReport implements IUIAction {
618640 public emoji = "🚯" ;
619641 public needsConfirmation = true ;
620642 public async canExecute (
621- _manager : ReportManager ,
643+ _manager : StandardReportManager ,
622644 _report : IReport
623645 ) : Promise < boolean > {
624646 return true ;
625647 }
626648 public async title (
627- _manager : ReportManager ,
649+ _manager : StandardReportManager ,
628650 _report : IReport
629651 ) : Promise < string > {
630652 return "Ignore" ;
631653 }
632654 public async help (
633- _manager : ReportManager ,
655+ _manager : StandardReportManager ,
634656 _report : IReport
635657 ) : Promise < string > {
636658 return "Ignore bad report" ;
637659 }
638660 public async execute (
639- manager : ReportManager ,
661+ manager : StandardReportManager ,
640662 report : IReportWithAction
641663 ) : Promise < string | undefined > {
642664 await manager . draupnir . client . sendEvent (
@@ -667,7 +689,7 @@ class RedactMessage implements IUIAction {
667689 public emoji = "🗍" ;
668690 public needsConfirmation = true ;
669691 public async canExecute (
670- manager : ReportManager ,
692+ manager : StandardReportManager ,
671693 report : IReport
672694 ) : Promise < boolean > {
673695 try {
@@ -681,16 +703,19 @@ class RedactMessage implements IUIAction {
681703 }
682704 }
683705 public async title (
684- _manager : ReportManager ,
706+ _manager : StandardReportManager ,
685707 _report : IReport
686708 ) : Promise < string > {
687709 return "Redact" ;
688710 }
689- public async help ( _manager : ReportManager , report : IReport ) : Promise < string > {
711+ public async help (
712+ _manager : StandardReportManager ,
713+ report : IReport
714+ ) : Promise < string > {
690715 return `Redact event ${ report . event_id } ` ;
691716 }
692717 public async execute (
693- manager : ReportManager ,
718+ manager : StandardReportManager ,
694719 report : IReport ,
695720 _moderationroomID : string
696721 ) : Promise < string | undefined > {
@@ -707,7 +732,7 @@ class KickAccused implements IUIAction {
707732 public emoji = "⚽" ;
708733 public needsConfirmation = true ;
709734 public async canExecute (
710- manager : ReportManager ,
735+ manager : StandardReportManager ,
711736 report : IReport
712737 ) : Promise < boolean > {
713738 try {
@@ -721,16 +746,19 @@ class KickAccused implements IUIAction {
721746 }
722747 }
723748 public async title (
724- _manager : ReportManager ,
749+ _manager : StandardReportManager ,
725750 _report : IReport
726751 ) : Promise < string > {
727752 return "Kick" ;
728753 }
729- public async help ( _manager : ReportManager , report : IReport ) : Promise < string > {
754+ public async help (
755+ _manager : StandardReportManager ,
756+ report : IReport
757+ ) : Promise < string > {
730758 return `Kick ${ htmlEscape ( report . accused_id ) } from room ${ htmlEscape ( report . room_alias_or_id ) } ` ;
731759 }
732760 public async execute (
733- manager : ReportManager ,
761+ manager : StandardReportManager ,
734762 report : IReport
735763 ) : Promise < string | undefined > {
736764 await manager . draupnir . client . kickUser ( report . accused_id , report . room_id ) ;
@@ -746,7 +774,7 @@ class MuteAccused implements IUIAction {
746774 public emoji = "🤐" ;
747775 public needsConfirmation = true ;
748776 public async canExecute (
749- manager : ReportManager ,
777+ manager : StandardReportManager ,
750778 report : IReport
751779 ) : Promise < boolean > {
752780 try {
@@ -761,16 +789,19 @@ class MuteAccused implements IUIAction {
761789 }
762790 }
763791 public async title (
764- _manager : ReportManager ,
792+ _manager : StandardReportManager ,
765793 _report : IReport
766794 ) : Promise < string > {
767795 return "Mute" ;
768796 }
769- public async help ( _manager : ReportManager , report : IReport ) : Promise < string > {
797+ public async help (
798+ _manager : StandardReportManager ,
799+ report : IReport
800+ ) : Promise < string > {
770801 return `Mute ${ htmlEscape ( report . accused_id ) } in room ${ htmlEscape ( report . room_alias_or_id ) } ` ;
771802 }
772803 public async execute (
773- manager : ReportManager ,
804+ manager : StandardReportManager ,
774805 report : IReport
775806 ) : Promise < string | undefined > {
776807 await manager . draupnir . client . setUserPowerLevel (
@@ -790,7 +821,7 @@ class BanAccused implements IUIAction {
790821 public emoji = "🚫" ;
791822 public needsConfirmation = true ;
792823 public async canExecute (
793- manager : ReportManager ,
824+ manager : StandardReportManager ,
794825 report : IReport
795826 ) : Promise < boolean > {
796827 try {
@@ -804,16 +835,19 @@ class BanAccused implements IUIAction {
804835 }
805836 }
806837 public async title (
807- _manager : ReportManager ,
838+ _manager : StandardReportManager ,
808839 _report : IReport
809840 ) : Promise < string > {
810841 return "Ban" ;
811842 }
812- public async help ( _manager : ReportManager , report : IReport ) : Promise < string > {
843+ public async help (
844+ _manager : StandardReportManager ,
845+ report : IReport
846+ ) : Promise < string > {
813847 return `Ban ${ htmlEscape ( report . accused_id ) } from room ${ htmlEscape ( report . room_alias_or_id ) } ` ;
814848 }
815849 public async execute (
816- manager : ReportManager ,
850+ manager : StandardReportManager ,
817851 report : IReport
818852 ) : Promise < string | undefined > {
819853 await manager . draupnir . client . banUser ( report . accused_id , report . room_id ) ;
@@ -829,25 +863,25 @@ class Help implements IUIAction {
829863 public emoji = "❓" ;
830864 public needsConfirmation = false ;
831865 public async canExecute (
832- _manager : ReportManager ,
866+ _manager : StandardReportManager ,
833867 _report : IReport
834868 ) : Promise < boolean > {
835869 return true ;
836870 }
837871 public async title (
838- _manager : ReportManager ,
872+ _manager : StandardReportManager ,
839873 _report : IReport
840874 ) : Promise < string > {
841875 return "Help" ;
842876 }
843877 public async help (
844- _manager : ReportManager ,
878+ _manager : StandardReportManager ,
845879 _report : IReport
846880 ) : Promise < string > {
847881 return "This help" ;
848882 }
849883 public async execute (
850- manager : ReportManager ,
884+ manager : StandardReportManager ,
851885 report : IReport ,
852886 moderationroomID : string
853887 ) : Promise < string | undefined > {
@@ -884,7 +918,7 @@ class EscalateToServerModerationRoom implements IUIAction {
884918 public emoji = "⏫" ;
885919 public needsConfirmation = true ;
886920 public async canExecute (
887- manager : ReportManager ,
921+ manager : StandardReportManager ,
888922 report : IReport ,
889923 moderationroomID : string
890924 ) : Promise < boolean > {
@@ -901,16 +935,19 @@ class EscalateToServerModerationRoom implements IUIAction {
901935 return true ;
902936 }
903937 public async title (
904- _manager : ReportManager ,
938+ _manager : StandardReportManager ,
905939 _report : IReport
906940 ) : Promise < string > {
907941 return "Escalate" ;
908942 }
909- public async help ( manager : ReportManager , _report : IReport ) : Promise < string > {
943+ public async help (
944+ manager : StandardReportManager ,
945+ _report : IReport
946+ ) : Promise < string > {
910947 return `Escalate report to ${ getHomeserver ( await manager . draupnir . client . getUserId ( ) ) } server moderators` ;
911948 }
912949 public async execute (
913- manager : ReportManager ,
950+ manager : StandardReportManager ,
914951 report : IReport ,
915952 _moderationroomID : string ,
916953 displayManager : DisplayManager
@@ -939,7 +976,7 @@ class EscalateToServerModerationRoom implements IUIAction {
939976}
940977
941978class DisplayManager {
942- constructor ( private owner : ReportManager ) { }
979+ constructor ( private owner : StandardReportManager ) { }
943980
944981 /**
945982 * Display the report and any UI button.
0 commit comments