Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/swimmy/command/photo_upload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ class PhotoUploadBot < Base
if data.files
data.files.each do |file|
next unless ["jpg", "png"].include?(file.filetype)
client.say(channel: data.channel, text: "Google Photos にアップロード中 (#{file.name})...")
client.say(channel: data.channel,
text: "Google Photos にアップロード中 (#{file.name})...",
thread_ts: data.thread_ts || data.ts)

# NOTE: We cannot use threads to upload multiple photos asynchronously.
# This is because Google Photos API returns 429 (Too Many Requests)
Expand All @@ -33,7 +35,9 @@ class PhotoUploadBot < Base
end
blob = SlackFileDownloader.new(ENV["SLACK_BOT_TOKEN"]).fetch(file.url_private_download)
url = GooglePhotosUploader.new(google_oauth).upload(blob, file.name, data.text)
client.say(channel: data.channel, text: "アップロード完了 #{url}")
client.say(channel: data.channel,
text: "アップロード完了 #{url}",
thread_ts: data.thread_ts || data.ts)
rescue
message = '写真のアップロードに失敗しました.'
client.say(channel: data.channel, text: message)
Expand Down
Loading