@@ -14,8 +14,17 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import { ClientEvent , MatrixEvent , MatrixEventEvent , SyncStateData , SyncState } from "matrix-js-sdk/src/matrix" ;
17+ import {
18+ ClientEvent ,
19+ MatrixEvent ,
20+ MatrixEventEvent ,
21+ SyncStateData ,
22+ SyncState ,
23+ ToDeviceMessageId ,
24+ } from "matrix-js-sdk/src/matrix" ;
1825import { sleep } from "matrix-js-sdk/src/utils" ;
26+ import { v4 as uuidv4 } from "uuid" ;
27+ import { logger } from "matrix-js-sdk/src/logger" ;
1928
2029import SdkConfig from "../SdkConfig" ;
2130import sendBugReport from "../rageshake/submit-rageshake" ;
@@ -108,20 +117,28 @@ export default class AutoRageshakeStore extends AsyncStoreWithClient<IState> {
108117
109118 const now = new Date ( ) . getTime ( ) ;
110119 if ( now - this . state . lastRageshakeTime < RAGESHAKE_INTERVAL ) {
120+ logger . info (
121+ `Not sending recipient-side autorageshake for event ${ ev . getId ( ) } /session ${ sessionId } : last rageshake was too recent` ,
122+ ) ;
111123 return ;
112124 }
113125
114126 await this . updateState ( { lastRageshakeTime : now } ) ;
115127
128+ const senderUserId = ev . getSender ( ) ! ;
116129 const eventInfo = {
117130 event_id : ev . getId ( ) ,
118131 room_id : ev . getRoomId ( ) ,
119132 session_id : sessionId ,
120133 device_id : wireContent . device_id ,
121- user_id : ev . getSender ( ) ! ,
134+ user_id : senderUserId ,
122135 sender_key : wireContent . sender_key ,
123136 } ;
124137
138+ logger . info ( `Sending recipient-side autorageshake for event ${ ev . getId ( ) } /session ${ sessionId } ` ) ;
139+ // XXX: the rageshake server returns the URL for the github issue... which is typically absent for
140+ // auto-uisis, because we've disabled creation of GH issues for them. So the `recipient_rageshake`
141+ // field is broken.
125142 const rageshakeURL = await sendBugReport ( SdkConfig . get ( ) . bug_report_endpoint_url , {
126143 userText : "Auto-reporting decryption error (recipient)" ,
127144 sendLogs : true ,
@@ -133,10 +150,11 @@ export default class AutoRageshakeStore extends AsyncStoreWithClient<IState> {
133150 const messageContent = {
134151 ...eventInfo ,
135152 recipient_rageshake : rageshakeURL ,
153+ [ ToDeviceMessageId ] : uuidv4 ( ) ,
136154 } ;
137155 this . matrixClient ?. sendToDevice (
138156 AUTO_RS_REQUEST ,
139- new Map ( [ [ "messageContent.user_id" , new Map ( [ [ messageContent . device_id , messageContent ] ] ) ] ] ) ,
157+ new Map ( [ [ senderUserId , new Map ( [ [ messageContent . device_id , messageContent ] ] ) ] ] ) ,
140158 ) ;
141159 }
142160 }
@@ -158,6 +176,9 @@ export default class AutoRageshakeStore extends AsyncStoreWithClient<IState> {
158176 const now = new Date ( ) . getTime ( ) ;
159177 if ( now - this . state . lastRageshakeTime > RAGESHAKE_INTERVAL ) {
160178 await this . updateState ( { lastRageshakeTime : now } ) ;
179+ logger . info (
180+ `Sending sender-side autorageshake for event ${ messageContent [ "event_id" ] } /session ${ messageContent [ "session_id" ] } ` ,
181+ ) ;
161182 await sendBugReport ( SdkConfig . get ( ) . bug_report_endpoint_url , {
162183 userText : `Auto-reporting decryption error (sender)\nRecipient rageshake: ${ recipientRageshake } ` ,
163184 sendLogs : true ,
@@ -168,6 +189,10 @@ export default class AutoRageshakeStore extends AsyncStoreWithClient<IState> {
168189 auto_uisi : JSON . stringify ( messageContent ) ,
169190 } ,
170191 } ) ;
192+ } else {
193+ logger . info (
194+ `Not sending sender-side autorageshake for event ${ messageContent [ "event_id" ] } /session ${ messageContent [ "session_id" ] } : last rageshake was too recent` ,
195+ ) ;
171196 }
172197 }
173198
0 commit comments