Repository: zulip/zulip

Issue:
Animated status emojis uploaded before 5.x always animate – not only on hover
Animated emojis uploaded before version 5.x used as status emojis are currently always animating next to user names in the sidebar and message feed, not only on hover.

Newly uploaded, animated emojis have the desired behavior, only animating on hover.


Discussion:
Thanks for the report @alfonsrv ! We had a migration that was supposed to address this; it's definitely something we'd like to take care of. Would you be willing to stop by the [#production help stream on chat.zulip.org](https://chat.zulip.org/#narrow/stream/31-production-help) so that we can debug interactively?
Hello @zulip/server-emoji members, this issue was labeled with the "area: emoji" label, so you may want to check it out!

<!-- areaLabelAddition -->

I'm puzzled by the report, since we added a migration to re-upload all existing custom emoji in 30ac291ebab5ead80de31f0ea07b4d845013fd8f.

That migration makes use of the `deferred_work` queue processor. @alfonsrv can you check `rabbitmqctl list_queues` (as `root`) to see whether your `deferred_work` queue processor just hasn't processed these jobs?

I'd expect logs to be in `/var/log/zulip/events_deferred_work.log` or if that doesn't exist, `/var/log/zulip/events.log`.
This is being discussed here: https://chat.zulip.org/#narrow/stream/31-production-help/topic/Status.20icons.20animate.20after.20upgrade.20.28issue.20.2321608.29/near/1357180

Resolving patch:
diff --git a/zerver/migrations/0387_reupload_realmemoji_again.py b/zerver/migrations/0387_reupload_realmemoji_again.py
new file mode 100644
--- /dev/null
+++ b/zerver/migrations/0387_reupload_realmemoji_again.py
@@ -0,0 +1,46 @@
+from django.conf import settings
+from django.db import migrations
+from django.db.backends.postgresql.schema import DatabaseSchemaEditor
+from django.db.migrations.state import StateApps
+
+from zerver.lib.queue import queue_json_publish
+
+
+def reupload_realm_emoji(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
+    """As detailed in https://github.com/zulip/zulip/issues/21608, it is
+    possible for the deferred_work queue from Zulip 4.x to have been
+    started up by puppet during the deployment before migrations were
+    run on Zulip 5.0.
+
+    This means that the deferred_work events produced by migration
+    0376 might have been processed and discarded without effect.
+
+    Since it's harmless to reupload a custom emoji a second time, we
+    fix this issue for the slice of servers that have already
+    installed 5.0 by repeating that part of the migration.
+    """
+
+    Realm = apps.get_model("zerver", "Realm")
+    if settings.TEST_SUITE:
+        # There are no custom emoji in the test suite data set, and
+        # the below code won't work because RabbitMQ isn't enabled for
+        # the test suite.
+        return
+
+    for realm_id in Realm.objects.order_by("id").values_list("id", flat=True):
+        event = {
+            "type": "reupload_realm_emoji",
+            "realm_id": realm_id,
+        }
+        queue_json_publish("deferred_work", event)
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("zerver", "0386_fix_attachment_caches"),
+    ]
+
+    operations = [
+        migrations.RunPython(reupload_realm_emoji, reverse_code=migrations.RunPython.noop),
+    ]


Test patch: