Skip to content

Commit

Permalink
Fix usernames in file uploads.
Browse files Browse the repository at this point in the history
Sometimes slack adds the username to the <@...> name anyway: that would
be "<@UABC|somename> uploaded a file ...".

Previously, the translation would try to find user "UABC|somename". Now
it simply uses "somename" verbatim.

Closes #6 reported by @patcon.
  • Loading branch information
wdoekes committed Aug 29, 2017
1 parent 0c7836c commit e9949e3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,12 @@ def replace_channel(match):

def replace_user(match):
user_id = match.groups()[0]
# <@UABC|somename>, used in file uploads:
# 'text': '<@UABC|somename> uploaded a file: ...'
if '|' in user_id:
return user_id.split('|', 1)[1]
# <@UABC>, used in other places:
# 'text': '<@UABC>: you forget that file sending fails'
try:
return '@' + users_list[user_id]['name']
except KeyError:
Expand Down

0 comments on commit e9949e3

Please sign in to comment.