Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

emoji: Restrict reaction_type for compatibility with typeahead.Emoji.

evykassirer7a9a445088ee
diff --git a/web/src/emoji.ts b/web/src/emoji.ts
index d4c41cbdba7..d8c97e6a9ba 100644
--- a/web/src/emoji.ts
+++ b/web/src/emoji.ts
@@ -66,7 +66,7 @@ type EmojiDict = {
// Details needed by template to render an emoji.
export type EmojiRenderingDetails = {
emoji_name: string;
- reaction_type: string;
+ reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
emoji_code: string;
url?: string;
still_url?: string | null;
@@ -325,7 +325,7 @@ export function get_emoji_details_by_name(emoji_name: string): EmojiRenderingDet
export function get_emoji_details_for_rendering(opts: {
emoji_name: string;
emoji_code: string;
- reaction_type: string;
+ reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
}): EmojiRenderingDetails {
if (opts.reaction_type !== "unicode_emoji") {
const realm_emoji = all_realm_emojis.get(opts.emoji_code);
diff --git a/web/src/message_store.ts b/web/src/message_store.ts
index 7b3e52f71c1..0cffab28fdb 100644
--- a/web/src/message_store.ts
+++ b/web/src/message_store.ts
@@ -100,7 +100,7 @@ export type MessageCleanReaction = {
is_realm_emoji: boolean;
label: string;
local_id: string;
- reaction_type: string;
+ reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
user_ids: number[];
vote_text: string;
};
diff --git a/web/src/reactions.ts b/web/src/reactions.ts
index c19a0d87e65..eaa64e32a81 100644
--- a/web/src/reactions.ts
+++ b/web/src/reactions.ts
@@ -24,7 +24,7 @@ type ReactionEvent = {
message_id: number;
user_id: number;
local_id: string;
- reaction_type: string;
+ reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
emoji_name: string;
emoji_code: string;
};
@@ -53,7 +53,7 @@ function get_message(message_id: number): Message | undefined {
export type RawReaction = {
emoji_name: string;
- reaction_type: string;
+ reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
emoji_code: string;
user_id: number;
};
@@ -566,7 +566,7 @@ function make_clean_reaction({
user_ids: number[];
emoji_name: string;
emoji_code: string;
- reaction_type: string;
+ reaction_type: "zulip_extra_emoji" | "realm_emoji" | "unicode_emoji";
should_display_reactors: boolean;
}): MessageCleanReaction {
const emoji_details = emoji.get_emoji_details_for_rendering({
diff --git a/web/src/user_status.ts b/web/src/user_status.ts
index e18aa1d269b..c47c473fd1f 100644
--- a/web/src/user_status.ts
+++ b/web/src/user_status.ts
@@ -19,7 +19,7 @@ const user_status_schema = z.intersection(
z.object({
emoji_name: z.string(),
emoji_code: z.string(),
- reaction_type: z.string(),
+ reaction_type: z.enum(["zulip_extra_emoji", "realm_emoji", "unicode_emoji"]),
}),
z.object({
emoji_name: z.undefined(),
diff --git a/web/tests/user_status.test.js b/web/tests/user_status.test.js
index 977bb0261b1..78cc2b66521 100644
--- a/web/tests/user_status.test.js
+++ b/web/tests/user_status.test.js
@@ -119,7 +119,7 @@ run_test("basics", () => {
type: "user_status",
emoji_name: "",
emoji_code: "",
- reaction_type: "",
+ reaction_type: "unicode_emoji",
status_text: "",
});
assert.deepEqual(user_status.get_status_emoji(2), undefined);