{"id":19682928,"url":"https://github.com/worteks/rc2matrix","last_synced_at":"2025-07-19T01:03:47.889Z","repository":{"id":186951618,"uuid":"675661322","full_name":"Worteks/RC2Matrix","owner":"Worteks","description":"Rocketchat to Matrix migration script","archived":false,"fork":false,"pushed_at":"2024-06-03T16:33:27.000Z","size":99,"stargazers_count":5,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-29T05:35:11.608Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Worteks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-08-07T12:38:56.000Z","updated_at":"2024-06-03T16:33:30.000Z","dependencies_parsed_at":"2024-01-05T10:52:59.326Z","dependency_job_id":"f62f69d3-1c0c-44d7-ad1f-11d9aea2d72c","html_url":"https://github.com/Worteks/RC2Matrix","commit_stats":null,"previous_names":["worteks/rc2matrix"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Worteks/RC2Matrix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Worteks%2FRC2Matrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Worteks%2FRC2Matrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Worteks%2FRC2Matrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Worteks%2FRC2Matrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Worteks","download_url":"https://codeload.github.com/Worteks/RC2Matrix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Worteks%2FRC2Matrix/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265866171,"owners_count":23840937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T18:13:14.677Z","updated_at":"2025-07-19T01:03:47.851Z","avatar_url":"https://github.com/Worteks.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RC2Matrix\n\nRocketchat to Matrix/Synapse migration script. Workflow is largely inspired by [https://git.verdigado.com/NB-Public/rocketchat2matrix](https://git.verdigado.com/NB-Public/rocketchat2matrix).\n\n*** WARNING : THIS IS WIP, USE AT YOUR OWN RISKS ***\n\n## Exporting RocketChat data\n\nCurrently, only public data should be exported. `./mongo_exportpublic.sh \u003cdbname\u003e \u003cdbuser\u003e \u003cdbpass\u003e` must be run on the mongo server and will use mongoexport, mongosh and mongofiles to extract necessary data (all users, public rooms, messages in these public rooms only, attachments mentionned in these messages only, avatars of rooms and users).\n\nExporting private data (private chats, DMs) can be manually done via mongodb. Run the following on the server:\n\n```shell\nmongoexport --collection=rocketchat_message --db=\u003cdbname\u003e --out=rocketchat_messages.json -u \u003cdbuser\u003e -p \u003cdbpass\u003e  --sort='{ts: 1}'\nmongoexport --collection=rocketchat_room --db=\u003cdbname\u003e --out=rocketchat_rooms.json -u \u003cdbuser\u003e -p \u003cdbpass\u003e\nmongoexport --collection=users --db=\u003cdbname\u003e --out=rocketchat_users.json -u \u003cdbuser\u003e -p \u003cdbpass\u003e\n```\n\nOptionnaly, if you manually extracted private data, you can run `./mongofiles_exportall.sh \u003cdbname\u003e \u003cdbuser\u003e \u003cdbpass\u003e` to export files and images. It will export files in a temporary directory, printed at the end of the script. This part is automatically done for public data during `mongo_exportpublic.sh`.\n\nPlease note that current features are only tested with the `mongo_exportpublic.sh` script focusing only on public data. Although most of the migration steps should also work with private data, it is currenlty not tested nor used.\n\n\n## Preparing Synapse server\n\nOn the Synapse server you need an admin account (user/pass) or directly its token.\n\nYou also need an application service. To register an application service, add the following to `homeserver.yaml` :\n```YAML\napp_service_config_files:\n- /your_path/rc2matrix.yaml\n\nrc_joins:\n  local:\n    per_second: 1024\n    burst_count: 2048\nrc_joins_per_room:\n  per_second: 1024\n  burst_count: 2048\nrc_message:\n  per_second: 1024\n  burst_count: 2048\nrc_invites:\n  per_room:\n    per_second: 1024\n    burst_count: 2048\n  per_user:\n    per_second: 1024\n    burst_count: 2048\n  per_issuer:\n    per_second: 1024\n    burst_count: 2048\n```\n\nYou also need to create a `rc2matrix.yaml` (you need to customize the two tokens) :\n```YAML\nurl: null\nas_token: ASecretASToken\nhs_token: ASecretHSToken\nid: rc2matrix\nsender_localpart: rc2matrix\nnamespaces:\n  users:  # List of users we're interested in\n    - exclusive: false\n      regex: \".*\"\n  aliases:\n    - exclusive: false\n      regex: \".*\"\n  rooms:\n    - exclusive: false\n      regex: \".*\"\n\n```\n\n## Running RC2Matrix\n\nIf you do not have your admin token, you can obtain it with `./rc2matrix.py -v -n \u003cyour matrix hostname\u003e -u \u003cuser_admin\u003e -p \u003cpass_admin\u003e`. Token will be printed on the console.\n\nThen, to import rooms, users and messages into Synapse : `./rc2matrix.py -v -n \u003cyour matrix hostname\u003e -t \u003cadmin_token\u003e -a \u003cASecretASToken\u003e -i \u003cyour folder containing the exports\u003e` (the ASecretASToken is defined in `rc2matrix.yaml`).\n\nIn your folder containing the exports, you should have `rocketchat_messages.json`, `rocketchat_rooms.json` and `rocketchat_users.json` files, as well as a folder `files/` containing the exported files.\n\nYou can remove `-v` for less verbose output, or add `-k` to not check certificates.\n\n## How does it work ?\n\nFirst, the data exported from RC is three JSON files containing rooms, users, and messages. Contents are described on the RC website ([rooms](https://developer.rocket.chat/reference/api/schema-definition/room), [messages](https://developer.rocket.chat/reference/api/schema-definition/message)). Files are not really JSON, but each line is a valid JSON, which can thus be processed sequentially.\n\nOn the Synapse side, we use both the [Matrix client-server API](https://spec.matrix.org/latest/client-server-api/), with the admin and application service account, and the [Synapse Admin API](https://matrix-org.github.io/synapse/latest/usage/administration/admin_api/), with the admin account. Some operations (such as creating rooms) are only authorized to the admin user, whereas some others (such as altering the timestamps of the messages or masquerading identities) are only authorized to the application service, hence these two needed tokens.\n\nFirst the rooms are created (or retrieved if already existing). Then, users are added, without authentication method : they will have to authenticate through an external system. Finally, messages are posted on behalf of these users. Rooms settings (public, private, DM) should be quite similar to RC settings but there may be some unexpected cases. DM messages appear in dedicated rooms.\n\nThis script currently imports messages, threads, reactions, emojis and avatars in order to provide a usable migration path. Advanced formatting is only partially handled.\n\nWhile the RC data will not be altered (there is just an export), Synapse data will obviously be altered. You should not run this script against an already used server, as it may have unexpected issues. You should run this script against a fresh Synapse server and carefully check the result.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworteks%2Frc2matrix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworteks%2Frc2matrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworteks%2Frc2matrix/lists"}