mirror of
https://github.com/zulip/zulip.git
synced 2025-11-13 10:26:28 +00:00
reactions: Don't process clicks from spectators.
The reaction count goes up locally if we don't have this check. This is misleading for spectators.
This commit is contained in:
@@ -44,6 +44,9 @@ const emoji_picker = mock_esm("../../static/js/emoji_picker", {
|
|||||||
});
|
});
|
||||||
const message_lists = mock_esm("../../static/js/message_lists");
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
const message_store = mock_esm("../../static/js/message_store");
|
const message_store = mock_esm("../../static/js/message_store");
|
||||||
|
const login_to_access = mock_esm("../../static/js/login_to_access", {
|
||||||
|
show() {},
|
||||||
|
});
|
||||||
|
|
||||||
message_lists.current = {
|
message_lists.current = {
|
||||||
selected_message() {
|
selected_message() {
|
||||||
@@ -907,15 +910,23 @@ test("process_reaction_click", ({override}) => {
|
|||||||
emoji_name: "smile",
|
emoji_name: "smile",
|
||||||
emoji_code: "1f642",
|
emoji_code: "1f642",
|
||||||
};
|
};
|
||||||
{
|
|
||||||
const stub = make_stub();
|
// Test spectator cannot react.
|
||||||
|
page_params.is_spectator = true;
|
||||||
|
let stub = make_stub();
|
||||||
|
login_to_access.show = stub.f;
|
||||||
|
reactions.process_reaction_click(message.id, "unicode_emoji,1f642");
|
||||||
|
let args = stub.get_args("args").args;
|
||||||
|
assert.equal(args, undefined);
|
||||||
|
|
||||||
|
page_params.is_spectator = false;
|
||||||
|
stub = make_stub();
|
||||||
channel.del = stub.f;
|
channel.del = stub.f;
|
||||||
reactions.process_reaction_click(message.id, "unicode_emoji,1f642");
|
reactions.process_reaction_click(message.id, "unicode_emoji,1f642");
|
||||||
assert.equal(stub.num_calls, 1);
|
assert.equal(stub.num_calls, 1);
|
||||||
const args = stub.get_args("args").args;
|
args = stub.get_args("args").args;
|
||||||
assert.equal(args.url, "/json/messages/1001/reactions");
|
assert.equal(args.url, "/json/messages/1001/reactions");
|
||||||
assert.deepEqual(args.data, expected_reaction_info);
|
assert.deepEqual(args.data, expected_reaction_info);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("warnings", () => {
|
test("warnings", () => {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import * as blueslip from "./blueslip";
|
|||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
import * as emoji_picker from "./emoji_picker";
|
import * as emoji_picker from "./emoji_picker";
|
||||||
import {$t} from "./i18n";
|
import {$t} from "./i18n";
|
||||||
|
import * as login_to_access from "./login_to_access";
|
||||||
import * as message_lists from "./message_lists";
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
@@ -110,6 +111,13 @@ export function toggle_emoji_reaction(message_id, emoji_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function process_reaction_click(message_id, local_id) {
|
export function process_reaction_click(message_id, local_id) {
|
||||||
|
if (page_params.is_spectator) {
|
||||||
|
// Spectators can't react, since they don't have accounts. We
|
||||||
|
// stop here to avoid a confusing reaction local echo.
|
||||||
|
login_to_access.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const message = get_message(message_id);
|
const message = get_message(message_id);
|
||||||
|
|
||||||
if (!message) {
|
if (!message) {
|
||||||
|
|||||||
Reference in New Issue
Block a user