Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/plugins/matrix/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,25 @@
room,
accessToken,
retries = 3,
backoff = 5000
backoff = 5000,
transactionId = undefined

Check failure on line 13 in lib/plugins/matrix/send.js

View workflow job for this annotation

GitHub Actions / build (22.x)

Do not use useless `undefined`

Check failure on line 13 in lib/plugins/matrix/send.js

View workflow job for this annotation

GitHub Actions / build (24.x)

Do not use useless `undefined`

Check failure on line 13 in lib/plugins/matrix/send.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Do not use useless `undefined`
Comment thread
tulir marked this conversation as resolved.
Outdated
) {
if (!transactionId) {
transactionId = `ssio-${Date.now()}`;
}
const retryCodes = new Set([408, 429, 500, 503]);
return new Promise((resolve, reject) => {
const request = _request(
{
host,
port: 443,
path: `/_matrix/client/r0/rooms/${room}/send/m.room.message?access_token=${accessToken}`,
path: `/_matrix/client/v3/rooms/${room}/send/m.room.message/${transactionId}`,
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(data), 'utf8')
},
method: 'POST'
method: 'PUT'
},
res => {
const { statusCode, statusMessage } = res;
Expand All @@ -36,7 +41,8 @@
room,
accessToken,
retries - 1,
backoff * 2
backoff * 2,
transactionId
);
}, backoff);
} else {
Expand Down
Loading