Skip to content

Commit

Permalink
Add option for attended/unattended running
Browse files Browse the repository at this point in the history
  • Loading branch information
awesome-michael committed Mar 19, 2022
1 parent 0ed3e1e commit 7f427e8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
2 changes: 2 additions & 0 deletions conf/example_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ skip-files: False
zipfile: /data/Slack_Export.zip
# Set to 'True' to perform a test without making changes to the homeserver
dry-run: False
# Set to 'True' to run without asking for confirmation after each step
run-unattended: False
# Set to 'False' if archived Channels from Slack should be migrated (and accessible in Matrix)
skip-archived: True
# Set to 'True' to invite all users to all rooms ( Very slow on rooms creator whit many users )
Expand Down
30 changes: 24 additions & 6 deletions slack-matrix-migration/slack-matrix-migration/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,23 +884,35 @@ def main():

# create users in matrix and match them to slack users
if "users.json" in jsonFiles and not userLUT:
log.info("Creating Users")
if not config["run-unattended"]:
input('Creating users. Press enter to proceed\n')
else:
log.info("Creating Users")
userlist = migrate_users(jsonFiles["users.json"], config, access_token)

# create rooms and match to channels
# Slack channels
if "channels.json" in jsonFiles and not roomLUT:
log.info("Creating channels")
if not config["run-unattended"]:
input('Creating channels. Press enter to proceed\n')
else:
log.info("Creating channels")
roomlist_channels = migrate_rooms(jsonFiles["channels.json"], config, admin_user)

# Slack groups
if "groups.json" in jsonFiles and not roomLUT:
log.info("Creating groups")
if not config["run-unattended"]:
input('Creating groups. Press enter to proceed\n')
else:
log.info("Creating groups")
roomlist_groups = migrate_rooms(jsonFiles["groups.json"], config, admin_user)

# create DMs
if "dms.json" in jsonFiles and not dmLUT:
log.info("Creating DMS")
if not config["run-unattended"]:
input('Creating DMs. Press enter to proceed\n')
else:
log.info("Creating DMs")
roomlist_dms = migrate_dms(jsonFiles["dms.json"], config, admin_user)

# write LUTs to file to be able to load from later if something goes wrong
Expand All @@ -917,7 +929,10 @@ def main():
yaml.dump(data, outfile, default_flow_style=False)

# send events to rooms
log.info("Migrating messages to rooms. This may take a while...")
if not config["run-unattended"]:
input('Migrating messages to rooms. This may take a while. Press enter to proceed\n')
else:
log.info("Migrating messages to rooms. This may take a while...")
for slack_room, matrix_room in roomLUT.items():
log = logging.getLogger('SLACK.MIGRATE.MESSAGES.{}'.format(roomLUT2[slack_room]))
log.info("Migrating messages for room: " + roomLUT2[slack_room])
Expand All @@ -930,7 +945,10 @@ def main():
later = []

# send events to dms
log.info("Migrating messages to DMs. This may take a while...")
if not config["run-unattended"]:
input('Migrating messages to DMs. This may take a while. Press enter to proceed\n')
else:
log.info("Migrating messages to DMs. This may take a while...")
for slack_room, matrix_room in dmLUT.items():
fileList = sorted(loadZipFolder(config, slack_room))
if fileList:
Expand Down

0 comments on commit 7f427e8

Please sign in to comment.