Skip to content

Commit c3a7e25

Browse files
committed
syn2mas: import the admin flag on users
1 parent ad891a0 commit c3a7e25

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

tools/syn2mas/src/advisor.mts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,6 @@ export async function advisor(): Promise<void> {
8282
return res["count(*)"] as number;
8383
}
8484

85-
const adminUsers = await count(
86-
synapse.count("*").from<SUser>("users").where({ admin: 1 }),
87-
);
88-
if (adminUsers > 0) {
89-
warn(
90-
`Synapse database contains ${adminUsers} admin users which will need to be added to the MAS configuration.`,
91-
);
92-
}
93-
9485
const guestUsers = await count(
9586
synapse.count("*").from<SUser>("users").where({ is_guest: 1 }),
9687
);

tools/syn2mas/src/migrate.mts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type { MCompatRefreshToken } from "./types/MCompatRefreshToken.d.ts";
1919
import type { MCompatSession } from "./types/MCompatSession.d.ts";
2020
import type { MUpstreamOauthLink } from "./types/MUpstreamOauthLink.d.ts";
2121
import type { MUpstreamOauthProvider } from "./types/MUpstreamOauthProvider.d.ts";
22+
import type { MUser } from "./types/MUser.js";
2223
import type { MUserEmail } from "./types/MUserEmail.d.ts";
2324
import type { MUserPassword } from "./types/MUserPassword.d.ts";
2425
import type { SAccessToken } from "./types/SAccessToken.d.ts";
@@ -207,11 +208,13 @@ export async function migrate(): Promise<void> {
207208
const userCreatedAt = new Date(
208209
Number.parseInt(`${user.creation_ts}`) * 1000,
209210
);
210-
const masUser = {
211+
const masUser: MUser = {
211212
user_id: makeUuid(userCreatedAt),
212213
username: localpart,
213214
created_at: userCreatedAt,
214215
locked_at: user.deactivated === 1 ? userCreatedAt : null,
216+
primary_user_email_id: null,
217+
can_request_admin: user.admin === 1,
215218
};
216219
executions.push(() => mas.insert(masUser).into("users"));
217220
log.debug(`${stringifyAndRedact(user)} => ${stringifyAndRedact(masUser)}`);

tools/syn2mas/src/types/MUser.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ export interface MUser {
1212
user_id: UUID<MUser>;
1313
username: string; // localpart only without @
1414
created_at: Date;
15-
primary_user_email_id?: UUID<MUserEmail>;
15+
locked_at: Date | null;
16+
primary_user_email_id: UUID<MUserEmail> | null;
17+
can_request_admin: boolean;
1618
}

0 commit comments

Comments
 (0)