Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update matrix-appservice-bridge #897

Merged
merged 4 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 16
node-version: 18
- run: yarn
- run: yarn lint
test:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [16, 18]
node_version: [18, 20]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node_version }}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:16-slim AS BUILD
FROM node:18-slim AS BUILD
COPY . /tmp/src
# install some dependencies needed for the build process
RUN apt update && apt install -y build-essential make gcc g++ python3 ca-certificates libc-dev wget git

RUN cd /tmp/src \
&& yarn

FROM node:16-slim
FROM node:18-slim
ENV NODE_ENV=production
COPY --from=BUILD /tmp/src/build /build
COPY --from=BUILD /tmp/src/config /config
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Please also be aware that this is an unoffical project worked on in our spare ti
The bridge has been tested against the [Synapse](https://github.com/matrix-org/synapse) homeserver, although any homeserver
that implements the [AS API](https://matrix.org/docs/spec/application_service/r0.1.0.html) should work with this bridge.

The bridge supports any version of Node.js between v14.X - v18.X. View the [releases](https://nodejs.org/en/about/releases/) for more details.
The bridge supports any version of Node.js between v18.X - v20.X. View the [releases](https://nodejs.org/en/about/releases/) for more details.

The bridge uses Yarn for dependency management and package scripts.
For the time being, **only Yarn Classic / v1 is supported.** To install it, follow [these instructions](https://classic.yarnpkg.com/en/docs/install).
Expand Down
1 change: 1 addition & 0 deletions changelog.d/897.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update matrix-appservice-bridge to use a non-deprecated method of authenticating to a homeserver. Fixes #896.
1 change: 1 addition & 0 deletions changelog.d/897.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Node.JS 16 is now unsupported, please upgrade to Node.JS 18 or later. Node.JS 18 is now used for Docker.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "discordas.js",
"engines": {
"npm": "please-use-yarn",
"node": ">=16 <=18"
"node": ">=18 <=20"
},
"scripts": {
"test": "mocha -r ts-node/register test/config.ts test/test_*.ts test/**/test_*.ts",
Expand Down Expand Up @@ -42,14 +42,14 @@
"dependencies": {
"@mx-puppet/matrix-discord-parser": "0.1.10",
"better-discord.js": "github:matrix-org/better-discord.js#5024781db755259e88abe915630b7d5b3ba5f48f",
"better-sqlite3": "^7.1.0",
"better-sqlite3": "^8.6.0",
"command-line-args": "^5.1.1",
"command-line-usage": "^6.1.0",
"escape-html": "^1.0.3",
"escape-string-regexp": "^4.0.0",
"js-yaml": "^3.14.0",
"marked": "^1.2.2",
"matrix-appservice-bridge": "^5.0.0",
"matrix-appservice-bridge": "^9.0.1",
"mime": "^2.4.6",
"p-queue": "^6.4.0",
"pg-promise": "^10.5.6",
Expand Down
5 changes: 4 additions & 1 deletion src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,10 @@ export class DiscordBot {

private async onUserActivityChanged(state: UserActivityState) {
for (const userId of state.changed) {
await this.store.storeUserActivity(userId, state.dataSet.users[userId]);
const activity = state.dataSet.get(userId);
if (activity) {
await this.store.storeUserActivity(userId, activity);
}
}
log.verbose(`Checking bridge limits (${state.activeUsers} active users)`);
this.bridgeBlocker?.checkLimits(state.activeUsers).catch(err => {
Expand Down
4 changes: 2 additions & 2 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,15 @@ export class DiscordStore implements IAppserviceStorageProvider {

public async getUserActivity(): Promise<UserActivitySet> {
const rows = await this.db.All('SELECT * FROM user_activity');
const users: {[mxid: string]: any} = {};
const users = new Map<string, UserActivity>();
for (const row of rows) {
let data = row.data as any;
if (typeof data === 'string') { // sqlite has no first-class JSON
data = JSON.parse(data);
}
users[row.user_id as string] = data;
}
return { users };
return users;
}

public async storeUserActivity(userId: string, activity: UserActivity): Promise<void> {
Expand Down
Loading
Loading