Skip to content

Commit

Permalink
Ignore channel canvases
Browse files Browse the repository at this point in the history
Channel canvases are exported as `canvas_in_the_conversation.json` files
in the channel directory. These files contain "canvas" objects
(`filetype="quip"`) which are exported in much the same way as normal
file uploads. However, because the canvases are meant to be living
documents, they have no `ts` key in them. This lack of a `ts` was
causing import errors.

To resolve this, the channel message loader now only loads messages from
filenames matching the pattern `*-*-*.json`, which excludes the channel
canvas file.

Fixes #28
  • Loading branch information
pR0Ps committed Jan 19, 2024
1 parent 41c4aee commit 8c88a07
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Limitations
- No private messages will be imported
- Reactions to messages will be shown in a custom embed, not as normal reactions
- No embeds from Slack (can contain images, buttons, etc) will be preserved.
- No canvases from Slack will be preserved.
- File uploads will be done in two messages. The first is the message content, the second is a
message containing the title of the uploaded file and attaching it.

Expand Down
2 changes: 1 addition & 1 deletion slack_to_discord/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def mention_repl(m):

messages = {}
file_ts_map = {}
for file in sorted(glob.glob(os.path.join(channel_dir, "*.json"))):
for file in sorted(glob.glob(os.path.join(channel_dir, "*-*-*.json"))):
with open(file, "rb") as fp:
data = json.load(fp)
for d in sorted(data, key=lambda x: x["ts"]):
Expand Down

0 comments on commit 8c88a07

Please sign in to comment.