export: Correctly treat emoji author field as optional.

While we likely will eventually want to make every custom emoji have
an author, that's not the data model today.

Fixes #11518.
This commit is contained in:
Abdelhadi Dyouri
2019-02-11 12:26:57 +00:00
committed by Tim Abbott
parent 4d1fb5270d
commit 4ac2db56f8

View File

@@ -1279,8 +1279,13 @@ def export_emoji_from_local(realm: Realm, local_dir: Path, output_dir: Path) ->
output_path = os.path.join(output_dir, emoji_path)
os.makedirs(os.path.dirname(output_path), exist_ok=True)
shutil.copy2(local_path, output_path)
# Realm Emoji author is optional.
author = realm_emoji.author
author_id = None
if author:
author_id = realm_emoji.author.id
record = dict(realm_id=realm.id,
author=realm_emoji.author.id,
author=author_id,
path=emoji_path,
s3_path=emoji_path,
file_name=realm_emoji.file_name,