@@ -12,10 +12,10 @@ import {
1212 ActionResult ,
1313 Capability ,
1414 DescriptionMeta ,
15- PolicyListRevisionIssuer ,
1615 RoomSetResult ,
17- ServerACLConsequencesContext ,
18- ServerConsequences ,
16+ ServerACLSynchronisationCapabilityContext ,
17+ ServerBanIntentProjection ,
18+ ServerBanSynchronisationCapability ,
1919 describeCapabilityContextGlue ,
2020 describeCapabilityRenderer ,
2121 isError ,
@@ -32,11 +32,13 @@ import {
3232 renderRoomSetResult ,
3333} from "@the-draupnir-project/mps-interface-adaptor" ;
3434
35- class StandardServerConsequencesRenderer implements ServerConsequences {
35+ class StandardServerBanSynchronisationCapabilityRenderer
36+ implements ServerBanSynchronisationCapability
37+ {
3638 constructor (
3739 private readonly description : DescriptionMeta ,
3840 private readonly messageCollector : RendererMessageCollector ,
39- private readonly capability : ServerConsequences
41+ private readonly capability : ServerBanSynchronisationCapability
4042 ) {
4143 // nothing to do.
4244 }
@@ -45,20 +47,21 @@ class StandardServerConsequencesRenderer implements ServerConsequences {
4547 public readonly requiredPermissions = this . capability . requiredPermissions ;
4648 public readonly requiredStatePermissions =
4749 this . capability . requiredStatePermissions ;
48- public async consequenceForServersInRoom (
50+ public async outcomeFromIntentInRoom (
4951 roomID : StringRoomID ,
50- issuer : PolicyListRevisionIssuer
52+ projection : ServerBanIntentProjection
5153 ) : Promise < ActionResult < boolean > > {
52- const capabilityResult = await this . capability . consequenceForServersInRoom (
54+ const capabilityResult = await this . capability . outcomeFromIntentInRoom (
5355 roomID ,
54- issuer
56+ projection
5557 ) ;
5658 const title = (
5759 < fragment >
5860 Setting server ACL in { Permalinks . forRoom ( roomID ) } as it is out of sync
5961 with watched policies.
6062 </ fragment >
6163 ) ;
64+ // only add the message if we failed, otherwise it's too spammy.
6265 if ( isError ( capabilityResult ) ) {
6366 this . messageCollector . addMessage (
6467 this . description ,
@@ -71,21 +74,13 @@ class StandardServerConsequencesRenderer implements ServerConsequences {
7174 ) ;
7275 return capabilityResult ;
7376 }
74- // only add the message if we changed anything in the room.
75- if ( capabilityResult . ok ) {
76- this . messageCollector . addOneliner (
77- this . description ,
78- this . capability ,
79- title
80- ) ;
81- }
8277 return capabilityResult ;
8378 }
84- public async consequenceForServersInRoomSet (
85- issuer : PolicyListRevisionIssuer
79+ public async outcomeFromIntentInRoomSet (
80+ projection : ServerBanIntentProjection
8681 ) : Promise < ActionResult < RoomSetResult > > {
8782 const capabilityResult =
88- await this . capability . consequenceForServersInRoomSet ( issuer ) ;
83+ await this . capability . outcomeFromIntentInRoomSet ( projection ) ;
8984 const title = < fragment > Updating server ACL in protected rooms.</ fragment > ;
9085 if ( isError ( capabilityResult ) ) {
9186 this . messageCollector . addMessage (
@@ -99,65 +94,31 @@ class StandardServerConsequencesRenderer implements ServerConsequences {
9994 ) ;
10095 return capabilityResult ;
10196 }
102- this . messageCollector . addMessage (
103- this . description ,
104- this . capability ,
105- renderRoomSetResult ( capabilityResult . ok , {
106- summary : (
107- < fragment >
108- < code > { this . description . name } </ code > : { title }
109- </ fragment >
110- ) ,
111- } )
112- ) ;
113- return capabilityResult ;
114- }
115- public async unbanServerFromRoomSet (
116- serverName : string ,
117- reason : string
118- ) : Promise < ActionResult < RoomSetResult > > {
119- const capabilityResult = await this . capability . unbanServerFromRoomSet (
120- serverName ,
121- reason
122- ) ;
123- const title = (
124- < fragment >
125- Removing { serverName } from denied servers in protected rooms.
126- </ fragment >
127- ) ;
128- if ( isError ( capabilityResult ) ) {
97+ // Only show this when results are failing.
98+ if ( ! capabilityResult . ok . isEveryResultOk ) {
12999 this . messageCollector . addMessage (
130100 this . description ,
131101 this . capability ,
132- renderFailedSingularConsequence (
133- this . description ,
134- title ,
135- capabilityResult . error
136- )
102+ renderRoomSetResult ( capabilityResult . ok , {
103+ summary : (
104+ < fragment >
105+ < code > { this . description . name } </ code > : { title }
106+ </ fragment >
107+ ) ,
108+ showOnlyFailed : true ,
109+ } )
137110 ) ;
138- return capabilityResult ;
139111 }
140- this . messageCollector . addMessage (
141- this . description ,
142- this . capability ,
143- renderRoomSetResult ( capabilityResult . ok , {
144- summary : (
145- < fragment >
146- < code > { this . description . name } </ code > : { title }
147- </ fragment >
148- ) ,
149- } )
150- ) ;
151112 return capabilityResult ;
152113 }
153114}
154115
155- describeCapabilityRenderer < ServerConsequences , Draupnir > ( {
156- name : "ServerACLConsequences " ,
157- description : "Render server consequences ." ,
158- interface : "ServerConsequences " ,
116+ describeCapabilityRenderer < ServerBanSynchronisationCapability , Draupnir > ( {
117+ name : "ServerACLSynchronisationCapability " ,
118+ description : "Render the server ban capability ." ,
119+ interface : "ServerBanSynchronisationCapability " ,
159120 factory ( description , draupnir , capability ) {
160- return new StandardServerConsequencesRenderer (
121+ return new StandardServerBanSynchronisationCapabilityRenderer (
161122 description ,
162123 draupnir . capabilityMessageRenderer ,
163124 capability
@@ -166,8 +127,11 @@ describeCapabilityRenderer<ServerConsequences, Draupnir>({
166127 isDefaultForInterface : true ,
167128} ) ;
168129
169- describeCapabilityContextGlue < Draupnir , ServerACLConsequencesContext > ( {
170- name : "ServerACLConsequences" ,
130+ describeCapabilityContextGlue <
131+ Draupnir ,
132+ ServerACLSynchronisationCapabilityContext
133+ > ( {
134+ name : "ServerACLSynchronisationCapability" ,
171135 glueMethod : function (
172136 protectionDescription ,
173137 draupnir ,
@@ -180,15 +144,18 @@ describeCapabilityContextGlue<Draupnir, ServerACLConsequencesContext>({
180144 } ,
181145} ) ;
182146
183- describeCapabilityContextGlue < Draupnir , ServerACLConsequencesContext > ( {
184- name : "SimulatedServerConsequences" ,
147+ describeCapabilityContextGlue <
148+ Draupnir ,
149+ ServerACLSynchronisationCapabilityContext
150+ > ( {
151+ name : "SimulatedServerBanSynchronisationCapability" ,
185152 glueMethod : function (
186153 protectionDescription ,
187154 draupnir ,
188155 capabilityProvider
189156 ) : Capability {
190157 return capabilityProvider . factory ( protectionDescription , {
191158 protectedRoomsSet : draupnir . protectedRoomsSet ,
192- } as ServerACLConsequencesContext ) ;
159+ } as ServerACLSynchronisationCapabilityContext ) ;
193160 } ,
194161} ) ;
0 commit comments