Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
realm_emoji: Fix race while custom emoji are being uploaded.
Tim Abbottfe282b343a4c
diff --git a/zerver/models.py b/zerver/models.pyindex 19fabad26f2..2f31ef763e3 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -1111,7 +1111,17 @@ class RealmEmoji(models.Model):def get_realm_emoji_dicts(realm: Realm, only_active_emojis: bool = False) -> Dict[str, EmojiInfo]:- query = RealmEmoji.objects.filter(realm=realm).select_related("author")+ # RealmEmoji objects with file_name=None are still in the process+ # of being uploaded, and we expect to be cleaned up by a+ # try/finally block if the upload fails, so it's correct to+ # exclude them.+ query = (+ RealmEmoji.objects.filter(realm=realm)+ .exclude(+ file_name=None,+ )+ .select_related("author")+ )if only_active_emojis:query = query.filter(deactivated=False)d = {}