Skip to content

Commit

Permalink
allow attachment download from slackdump standard export (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
limwz01 authored Jan 26, 2024
1 parent 39b6126 commit 898eec3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions slackviewer/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import flask


Expand Down Expand Up @@ -26,6 +28,11 @@ def channel_name(name):
no_external_references=app.no_external_references)


@app.route("/channel/<name>/attachments/<attachment>")
def channel_name_attachment(name, attachment):
return flask.send_file(os.path.join(flask._app_ctx_stack.path, name, "attachments", attachment))


@app.route("/group/<name>/")
def group_name(name):
messages = flask._app_ctx_stack.groups[name]
Expand All @@ -44,6 +51,11 @@ def group_name(name):
no_external_references=app.no_external_references)


@app.route("/group/<name>/attachments/<attachment>")
def group_name_attachment(name, attachment):
return flask.send_file(os.path.join(flask._app_ctx_stack.path, name, "attachments", attachment))


@app.route("/dm/<id>/")
def dm_id(id):
messages = flask._app_ctx_stack.dms[id]
Expand All @@ -62,6 +74,11 @@ def dm_id(id):
no_external_references=app.no_external_references)


@app.route("/dm/<name>/attachments/<attachment>")
def dm_name_attachment(name, attachment):
return flask.send_file(os.path.join(flask._app_ctx_stack.path, name, "attachments", attachment))


@app.route("/mpim/<name>/")
def mpim_name(name):
messages = flask._app_ctx_stack.mpims.get(name, list())
Expand All @@ -80,6 +97,11 @@ def mpim_name(name):
no_external_references=app.no_external_references)


@app.route("/mpim/<name>/attachments/<attachment>")
def mpim_name_attachment(name, attachment):
return flask.send_file(os.path.join(flask._app_ctx_stack.path, name, "attachments", attachment))


@app.route("/")
def index():
channels = list(flask._app_ctx_stack.channels.keys())
Expand Down
1 change: 1 addition & 0 deletions slackviewer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def configure_app(app, archive, channels, no_sidebar, no_external_references, de
reader = Reader(path)

top = flask._app_ctx_stack
top.path = path
top.channels = reader.compile_channels(channels)
top.groups = reader.compile_groups()
top.dms = reader.compile_dm_messages()
Expand Down

0 comments on commit 898eec3

Please sign in to comment.