@@ -18,6 +18,7 @@ import { Mjolnir, STATE_CHECKING_PERMISSIONS, STATE_NOT_STARTED, STATE_RUNNING,
1818import { RichReply } from "matrix-bot-sdk" ;
1919import { htmlEscape , parseDuration } from "../utils" ;
2020import { HumanizeDurationLanguage , HumanizeDuration } from "humanize-duration-ts" ;
21+ import PolicyList from "../models/PolicyList" ;
2122
2223const HUMANIZE_LAG_SERVICE : HumanizeDurationLanguage = new HumanizeDurationLanguage ( ) ;
2324const HUMANIZER : HumanizeDuration = new HumanizeDuration ( HUMANIZE_LAG_SERVICE ) ;
@@ -67,22 +68,28 @@ async function showMjolnirStatus(roomId: string, event: any, mjolnir: Mjolnir) {
6768 break ;
6869 }
6970
70- html += `<b>Protected rooms: </b> ${ Object . keys ( mjolnir . protectedRooms ) . length } <br/>` ;
71- text += `Protected rooms: ${ Object . keys ( mjolnir . protectedRooms ) . length } \n` ;
71+ html += `<b>Protected rooms: </b> ${ mjolnir . protectedRoomsTracker . getProtectedRooms ( ) . length } <br/>` ;
72+ text += `Protected rooms: ${ mjolnir . protectedRoomsTracker . getProtectedRooms ( ) . length } \n` ;
7273
7374 // Append list information
74- html += "<b>Subscribed ban lists:</b><br><ul>" ;
75- text += "Subscribed ban lists:\n" ;
76- for ( const list of mjolnir . lists ) {
77- const ruleInfo = `rules: ${ list . serverRules . length } servers, ${ list . userRules . length } users, ${ list . roomRules . length } rooms` ;
78- html += `<li>${ htmlEscape ( list . listShortcode ) } @ <a href="${ list . roomRef } ">${ list . roomId } </a> (${ ruleInfo } )</li>` ;
79- text += `* ${ list . listShortcode } @ ${ list . roomRef } (${ ruleInfo } )\n` ;
80- }
81- if ( mjolnir . lists . length === 0 ) {
82- html += "<li><i>None</i></li>" ;
83- text += "* None\n" ;
75+ const renderPolicyLists = ( header : string , lists : PolicyList [ ] ) => {
76+ html += `<b>${ header } :</b><br><ul>` ;
77+ text += `${ header } :\n` ;
78+ for ( const list of lists ) {
79+ const ruleInfo = `rules: ${ list . serverRules . length } servers, ${ list . userRules . length } users, ${ list . roomRules . length } rooms` ;
80+ html += `<li>${ htmlEscape ( list . listShortcode ) } @ <a href="${ list . roomRef } ">${ list . roomId } </a> (${ ruleInfo } )</li>` ;
81+ text += `* ${ list . listShortcode } @ ${ list . roomRef } (${ ruleInfo } )\n` ;
82+ }
83+ if ( lists . length === 0 ) {
84+ html += "<li><i>None</i></li>" ;
85+ text += "* None\n" ;
86+ }
87+ html += "</ul>" ;
8488 }
85- html += "</ul>" ;
89+ const subscribedLists = mjolnir . lists . filter ( list => ! mjolnir . explicitlyProtectedRooms . includes ( list . roomId ) ) ;
90+ renderPolicyLists ( "Subscribed policy lists" , subscribedLists ) ;
91+ const subscribedAndProtectedLists = mjolnir . lists . filter ( list => mjolnir . explicitlyProtectedRooms . includes ( list . roomId ) ) ;
92+ renderPolicyLists ( "Subscribed and protected policy lists" , subscribedAndProtectedLists ) ;
8693
8794 const reply = RichReply . createFor ( roomId , event , text , html ) ;
8895 reply [ "msgtype" ] = "m.notice" ;
0 commit comments