User Changed webhook: add 'nickname' and 'old_nickname' #93582

Merged
Sybren A. Stüvel merged 2 commits from webhook/gitea-username into main 2023-05-01 15:38:14 +02:00
Showing only changes of commit 3c6ba65e7b - Show all commits

View File

@ -144,10 +144,8 @@ def modified_user_to_webhooks(sender, user: UserModel, **kwargs):
"email": user.email, "email": user.email,
"roles": sorted(user.public_roles()), "roles": sorted(user.public_roles()),
"avatar_changed": old_avatar != cur_avatar, "avatar_changed": old_avatar != cur_avatar,
"date_deletion_requested": user.date_deletion_requested.isoformat() "date_deletion_requested": isoformat(user.date_deletion_requested),
if user.date_deletion_requested else None, "confirmed_email_at": isoformat(user.confirmed_email_at),
"confirmed_email_at": user.confirmed_email_at.isoformat()
if user.confirmed_email_at else None,
# FIXME(anna): add nickname # FIXME(anna): add nickname
} }
json_payload = json.dumps(payload).encode() json_payload = json.dumps(payload).encode()
@ -156,3 +154,10 @@ def modified_user_to_webhooks(sender, user: UserModel, **kwargs):
for hook in hooks: for hook in hooks:
log.debug("Sending to %s, %s", hook, hook.url) log.debug("Sending to %s, %s", hook, hook.url)
hook.send(json_payload, sess) hook.send(json_payload, sess)
def isoformat(timestamp):
"""None-safe timestamp.isoformat()."""
if not timestamp:
return None
return timestamp.isoformat()