tweak the displayname for the guest user to pnut
This commit is contained in:
parent
722224807a
commit
ebc5b4abd6
1 changed files with 10 additions and 2 deletions
|
@ -32,14 +32,14 @@ def on_receive_events(transaction):
|
|||
text = event['content']['body']
|
||||
else:
|
||||
token = app.config['MATRIX_PNUT_TOKEN']
|
||||
text = "<" + event["user_id"] + "> " + event['content']['body']
|
||||
text = "" + get_displayname(event["user_id"]) + " : " + event['content']['body']
|
||||
elif event['content']['msgtype'] == 'm.emote':
|
||||
if user:
|
||||
token = user.pnut_token
|
||||
text = "* " + user.pnut_id + " " + event['content']['body']
|
||||
else:
|
||||
token = app.config['MATRIX_PNUT_TOKEN']
|
||||
text = "* " + event["user_id"] + " " + event['content']['body']
|
||||
text = "* " + get_displayname(event["user_id"]) + " " + event['content']['body']
|
||||
else:
|
||||
text = None
|
||||
|
||||
|
@ -137,3 +137,11 @@ def query_alias(alias):
|
|||
def not_found(error):
|
||||
return jsonify({'errcode':'COM.MONKEYSTEW.PNUT_NOT_FOUND'}), 404
|
||||
|
||||
def get_displayname(userid):
|
||||
url = "http://localhost:8008/_matrix/client/r0/profile/" + userid
|
||||
r = requests.get(url)
|
||||
if r.status_code == 200:
|
||||
data = json.loads(r.text)
|
||||
return data["displayname"]
|
||||
else:
|
||||
return userid
|
Loading…
Reference in a new issue