Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ The following list contains such features - they are only available for [etke.cc
* 🛠️ [Server Commands panel](https://github.com/etkecc/synapse-admin/pull/365)
* 🚀 [Server Actions page](https://github.com/etkecc/synapse-admin/pull/457)
* 💳 [Billing page](https://github.com/etkecc/synapse-admin/pull/691)
* [Support 3pids in CSV users import (bulk registration)](https://github.com/etkecc/synapse-admin/pull/804)

### Development

Expand Down
6 changes: 3 additions & 3 deletions public/data/example.csv
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
id,displayname,password,is_guest,admin,deactivated
testuser22,Jane Doe,secretpassword,false,true,false
,John Doe,,false,false,false
id,displayname,password,is_guest,admin,deactivated,threepids
testuser22,Jane Doe,secretpassword,false,true,false,"email:test22@example.com,msisdn:1234567890"
,John Doe,,false,false,false,"email:john@example.com,email:doe@example.com"
1 change: 1 addition & 0 deletions src/components/user-import/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ImportLine {
is_admin?: boolean;
password?: string;
avatar_url?: string;
threepids?: string; // Comma-separated list of 3PIDs, example: "email:one@example.com,msisdn:+1234567890"
}

export interface ParsedStats {
Expand Down
20 changes: 20 additions & 0 deletions src/components/user-import/useImportFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,26 @@ const useImportFile = () => {
// we want to ensure that the ID is always full MXID, otherwise randomly-generated MXIDs will be in the full
// form, but the ones from the CSV will be localpart-only.
userRecord.id = returnMXID(userRecord.id);

// if there are 3PIDs, convert them to objects ("medium:address,..." -> [{medium,address},...])
if (userRecord.threepids !== undefined && userRecord.threepids !== "") {
const threepids = userRecord.threepids.split(",").map(m => m.trim());
const threepidObjs = [];
for (const threepid of threepids) {
const parts = threepid.split(":");
if (parts.length !== 2) {
continue;
}
const medium = parts[0].trim().toLowerCase();
const address = parts[1].trim();
if (address === "") {
continue;
}
threepidObjs.push({ medium, address });
}
userRecord.threepids = threepidObjs;
}

/* TODO record update stats (especially admin no -> yes, deactivated x -> !x, ... */

/* For these modes we will consider the ID that's in the record.
Expand Down