-
Notifications
You must be signed in to change notification settings - Fork 190
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
We need a way to rename homeservers (SYN-28) #1209
Comments
So, this has been open for 10 years; at this rate I'm sure it will never be implemented. |
I found this script called matrix-copy-room-history, it's not meant to migrate between different databases/homeservers, but with some minor changes it does work. Specifically you need to add a mapping between old and new user IDs and some tweaking to handle threads, the rest works okish: diff --git a/index.js b/index.js
index 8c221d1..76c5220 100644
--- a/index.js
+++ b/index.js
@@ -13,6 +13,7 @@ async function asyncForEach(array, callback) {
}
const ROOMS = require('./mapped_rooms.json');
+const USERS = require('./mapped_users.json');
let bridge;
@@ -56,6 +57,7 @@ new Cli({
bridge.run(port, config).then(async () => {
let importFolders = fs.readdirSync(ELEMENT_EXPORT_FOLDER).sort();
await asyncForEach(importFolders, async (jsonFile) => {
+ console.log('copying ' + jsonFile + '...')
let hasJoined = {}
let isInvited = {}
@@ -84,38 +86,53 @@ new Cli({
return 0;
});
+ console.log('sorted messages');
+
await asyncForEach(messages, async (msg) => {
+
if (!msg.hasOwnProperty('type') || msg.type !== "m.room.message") {
+ console.log('no type');
return;
}
if (!msg.hasOwnProperty('room_id')) {
+ console.log('no room id');
return;
}
let originalRoomId = msg.room_id;
if (!ROOMS.hasOwnProperty(originalRoomId)) {
+ console.log('room not in mapped_rooms');
return;
}
if (!msg.hasOwnProperty('content')) {
+ console.log('no content');
return;
}
if (!msg.content.hasOwnProperty('body')) {
+ console.log('no body');
return;
}
let content = msg.content;
if (!msg.hasOwnProperty('sender')) {
+ console.log('no sender');
return;
}
- let userID = msg.sender;
+ let userID;
+ if (USERS.hasOwnProperty(msg.sender)) {
+ userID = USERS[msg.sender];
+ } else {
+ userID = msg.sender.split(":")[0] + ":new_domain_here";
+ }
if (!msg.hasOwnProperty('event_id')) {
+ console.log('no event_id');
return;
}
@@ -130,6 +147,9 @@ new Cli({
let newEventID = mappedEvents[oldEventID];
content["m.relates_to"]["m.in_reply_to"]["event_id"] = newEventID;
+ content["m.relates_to"]["event_id"] = newEventID;
+ } else {
+ delete content["m.relates_to"];
}
}
@@ -146,14 +166,24 @@ new Cli({
let roomID = ROOMS[originalRoomId];
if (!isInvited.hasOwnProperty(userID) && userID !== INVITER) {
- await ownerIntent.invite(roomID, userID);
+ try {
+ await ownerIntent.invite(roomID, userID);
+ }
+ catch(e) {
+ console.log('already invited ' + userID)
+ }
isInvited[userID] = true;
}
let intent = bridge.getIntent(userID);
if (!hasJoined.hasOwnProperty(userID) && userID !== INVITER) {
- await intent.join(roomID);
+ try {
+ await intent.join(roomID);
+ }
+ catch(e) {
+ console.log('already joined ' + roomID)
+ }
hasJoined[userID] = true;
} So, the steps are:
|
This issue has been migrated from #1209.
The current common use case for Synapse is that people install it running as localhost - have a play with it; see that it's good.
They then want to expose the same server to run as --server-name foo.net - except there isn't (as far as I know) an easy way to change the server-name without vaping the whole HS DB. We need one.
(Imported from https://matrix.org/jira/browse/SYN-28)
(Reported by @ara4n)
The text was updated successfully, but these errors were encountered: