Skip to content

Commit e75a030

Browse files
committed
Switch from deprecated mattermost-redux to @mattermost/client
1 parent ab589cd commit e75a030

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

paperbot/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "isocpp-mattermost-paperbot",
3-
"version": "2.0.1",
3+
"version": "2.1.0",
44
"description": "",
55
"main": "src/index.js",
66
"scripts": {
@@ -11,10 +11,12 @@
1111
"dependencies": {
1212
"babel-polyfill": "^6.26.0",
1313
"isomorphic-fetch": "^3.0.0",
14-
"mattermost-redux": "^5.33.1",
14+
"@mattermost/client": "^8.1.1",
15+
"@mattermost/types": "^8.1.1",
1516
"tslib": "^2.5.0",
1617
"express": "^4.18.2",
1718
"dotenv": "^16.0.3",
18-
"moment": "2.29.4"
19+
"moment": "2.29.4",
20+
"ws": "8.14.1"
1921
}
2022
}

paperbot/src/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ const moment = require('moment')
44
if (!global.WebSocket) {
55
global.WebSocket = require('ws');
66
}
7+
client = require('@mattermost/client');
8+
const Client4 = client.Client4;
9+
const WebSocketClient = client.WebSocketClient;
710

811
if (!String.prototype.format) {
912
String.prototype.format = function() {
@@ -302,22 +305,19 @@ class PaperBot {
302305
}
303306

304307
initChatConnection(config) {
305-
const Client4 = require('../node_modules/mattermost-redux/client/client4.js').default;
306308
this.client = new Client4;
307-
this.wsClient = require('../node_modules/mattermost-redux/client/websocket_client.js').default;
309+
this.wsClient = new WebSocketClient();
308310
const {
309311
Post,
310312
PostList,
311313
PostSearchResults,
312314
OpenGraphMetadata
313-
} = require("../node_modules/mattermost-redux/types/posts");
315+
} = require("@mattermost/types/posts");
314316

315317
this.client.setUrl(config.apiUrl);
316318
this.client.setToken(config.token);
317319
this.client.setIncludeCookies(false);
318-
this.wsClient.initialize(config.token, {
319-
connectionUrl: config.websocketUrl
320-
});
320+
this.wsClient.initialize(config.websocketUrl, config.token);
321321

322322
this.stats.api.requests_sent += 1;
323323
this.client.getMe().then((profile) => {
@@ -550,7 +550,7 @@ class PaperBot {
550550
this.stats.paper_requests_handled += 1;
551551

552552
const paper_request_regex = /(?:(C|E|LE?)WG|FS|SD|N|P|D|EDIT) ?\d+(R\d+)?/gi;
553-
const papers_requested = [...post.message.matchAll(paper_request_regex)].map(m => m[1]);
553+
const papers_requested = [...post.message.matchAll(paper_request_regex)].map(m => m[0]);
554554
this.handlePaperRequest(post, papers_requested, true);
555555
}
556556

0 commit comments

Comments
 (0)