mirror of https://github.com/zulip/zulip.git
submessage: Send only relevant 'event' array data.
We sent entire 'events' array to 'widgetize.activate' and then removed its first element(using .shift()); instead we should send only relevant data ie. the entire array after the first element. This also helps us avoid an extra check in node tests.
This commit is contained in:
parent
2e8b950022
commit
7329100dc7
|
@ -50,9 +50,10 @@ export function do_process_submessages(in_opts) {
|
|||
if (!events) {
|
||||
return;
|
||||
}
|
||||
const [widget_event, ...inbound_events] = events;
|
||||
|
||||
if (events[0].sender_id !== message.sender_id) {
|
||||
blueslip.warn(`User ${events[0].sender_id} tried to hijack message ${message.id}`);
|
||||
if (widget_event.sender_id !== message.sender_id) {
|
||||
blueslip.warn(`User ${widget_event.sender_id} tried to hijack message ${message.id}`);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -60,7 +61,7 @@ export function do_process_submessages(in_opts) {
|
|||
|
||||
// Right now, our only use of submessages is widgets.
|
||||
|
||||
const data = events[0].data;
|
||||
const data = widget_event.data;
|
||||
|
||||
if (data === undefined) {
|
||||
return;
|
||||
|
@ -77,7 +78,7 @@ export function do_process_submessages(in_opts) {
|
|||
widgetize.activate({
|
||||
widget_type,
|
||||
extra_data: data.extra_data,
|
||||
events,
|
||||
events: inbound_events,
|
||||
$row,
|
||||
message,
|
||||
post_to_server,
|
||||
|
|
|
@ -58,8 +58,6 @@ export function activate(in_opts: WidgetOptions): void {
|
|||
const message = in_opts.message;
|
||||
const post_to_server = in_opts.post_to_server;
|
||||
|
||||
events.shift();
|
||||
|
||||
if (!widgets.has(widget_type)) {
|
||||
if (widget_type === "tictactoe") {
|
||||
return; // don't warn for deleted legacy widget
|
||||
|
|
|
@ -46,8 +46,6 @@ const fake_poll_widget = {
|
|||
assert.ok($widget_elem.hasClass("widget-content"));
|
||||
$widget_elem.handle_events = (e) => {
|
||||
is_event_handled = true;
|
||||
assert.notDeepStrictEqual(e, events);
|
||||
events.shift();
|
||||
assert.deepStrictEqual(e, events);
|
||||
};
|
||||
data.callback("test_data");
|
||||
|
|
Loading…
Reference in New Issue