mirror of https://github.com/zulip/zulip.git
events: Add `op` field to `update_message_flags` events.
`update_message_flags` events used `operation` instead of `op`, the latter being the standard field used in other events. So add `op` field to `update_message_flags` and mark `operation` as deprecated, so that it can be removed later.
This commit is contained in:
parent
f429df3401
commit
372e010dbb
|
@ -684,6 +684,7 @@ exports.fixtures = {
|
||||||
|
|
||||||
update_message_flags__read: {
|
update_message_flags__read: {
|
||||||
type: "update_message_flags",
|
type: "update_message_flags",
|
||||||
|
op: "add",
|
||||||
operation: "add",
|
operation: "add",
|
||||||
flag: "read",
|
flag: "read",
|
||||||
messages: [999],
|
messages: [999],
|
||||||
|
@ -692,6 +693,7 @@ exports.fixtures = {
|
||||||
|
|
||||||
update_message_flags__starred_add: {
|
update_message_flags__starred_add: {
|
||||||
type: "update_message_flags",
|
type: "update_message_flags",
|
||||||
|
op: "add",
|
||||||
operation: "add",
|
operation: "add",
|
||||||
flag: "starred",
|
flag: "starred",
|
||||||
messages: [exports.test_message.id],
|
messages: [exports.test_message.id],
|
||||||
|
@ -700,6 +702,7 @@ exports.fixtures = {
|
||||||
|
|
||||||
update_message_flags__starred_remove: {
|
update_message_flags__starred_remove: {
|
||||||
type: "update_message_flags",
|
type: "update_message_flags",
|
||||||
|
op: "remove",
|
||||||
operation: "remove",
|
operation: "remove",
|
||||||
flag: "starred",
|
flag: "starred",
|
||||||
messages: [exports.test_message.id],
|
messages: [exports.test_message.id],
|
||||||
|
|
|
@ -10,6 +10,13 @@ below features are supported.
|
||||||
|
|
||||||
## Changes in Zulip 4.0
|
## Changes in Zulip 4.0
|
||||||
|
|
||||||
|
**Feature level 32**
|
||||||
|
|
||||||
|
* [`GET /events`](/api/get-events): Added `op` field to
|
||||||
|
`update_message_flags` events, deprecating the `operation` field
|
||||||
|
(which has the same value). This removes an unintentional anomaly
|
||||||
|
in the format of this event type.
|
||||||
|
|
||||||
**Feature level 31**
|
**Feature level 31**
|
||||||
|
|
||||||
* [`GET users/me/subscriptions`](/api/get-subscriptions): Added a
|
* [`GET users/me/subscriptions`](/api/get-subscriptions): Added a
|
||||||
|
|
|
@ -29,7 +29,7 @@ DESKTOP_WARNING_VERSION = "5.2.0"
|
||||||
#
|
#
|
||||||
# Changes should be accompanied by documentation explaining what the
|
# Changes should be accompanied by documentation explaining what the
|
||||||
# new level means in templates/zerver/api/changelog.md.
|
# new level means in templates/zerver/api/changelog.md.
|
||||||
API_FEATURE_LEVEL = 31
|
API_FEATURE_LEVEL = 32
|
||||||
|
|
||||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
||||||
# only when going from an old version of the code to a newer version. Bump
|
# only when going from an old version of the code to a newer version. Bump
|
||||||
|
|
|
@ -4120,6 +4120,7 @@ def do_mark_all_as_read(user_profile: UserProfile, client: Client) -> int:
|
||||||
|
|
||||||
event = dict(
|
event = dict(
|
||||||
type='update_message_flags',
|
type='update_message_flags',
|
||||||
|
op ='add',
|
||||||
operation='add',
|
operation='add',
|
||||||
flag='read',
|
flag='read',
|
||||||
messages=[], # we don't send messages, since the client reloads anyway
|
messages=[], # we don't send messages, since the client reloads anyway
|
||||||
|
@ -4167,6 +4168,7 @@ def do_mark_stream_messages_as_read(user_profile: UserProfile,
|
||||||
|
|
||||||
event = dict(
|
event = dict(
|
||||||
type='update_message_flags',
|
type='update_message_flags',
|
||||||
|
op='add',
|
||||||
operation='add',
|
operation='add',
|
||||||
flag='read',
|
flag='read',
|
||||||
messages=message_ids,
|
messages=message_ids,
|
||||||
|
@ -4274,6 +4276,7 @@ def do_update_message_flags(user_profile: UserProfile,
|
||||||
raise AssertionError("Invalid message flags operation")
|
raise AssertionError("Invalid message flags operation")
|
||||||
|
|
||||||
event = {'type': 'update_message_flags',
|
event = {'type': 'update_message_flags',
|
||||||
|
'op': operation,
|
||||||
'operation': operation,
|
'operation': operation,
|
||||||
'flag': flag,
|
'flag': flag,
|
||||||
'messages': messages,
|
'messages': messages,
|
||||||
|
|
|
@ -811,6 +811,7 @@ check_update_message_embedded = check_events_dict(
|
||||||
_check_update_message_flags = check_events_dict(
|
_check_update_message_flags = check_events_dict(
|
||||||
required_keys=[
|
required_keys=[
|
||||||
("type", equals("update_message_flags")),
|
("type", equals("update_message_flags")),
|
||||||
|
("op", check_add_or_remove),
|
||||||
("operation", check_add_or_remove),
|
("operation", check_add_or_remove),
|
||||||
("flag", check_string),
|
("flag", check_string),
|
||||||
("messages", check_list(check_int)),
|
("messages", check_list(check_int)),
|
||||||
|
@ -823,7 +824,7 @@ def check_update_message_flags(
|
||||||
var_name: str, event: Dict[str, object], operation: str
|
var_name: str, event: Dict[str, object], operation: str
|
||||||
) -> None:
|
) -> None:
|
||||||
_check_update_message_flags(var_name, event)
|
_check_update_message_flags(var_name, event)
|
||||||
assert event["operation"] == operation
|
assert event["operation"] == operation and event['op'] == operation
|
||||||
|
|
||||||
|
|
||||||
_check_group = check_dict_only(
|
_check_group = check_dict_only(
|
||||||
|
|
|
@ -742,13 +742,13 @@ def apply_event(state: Dict[str, Any],
|
||||||
# We don't return messages in `/register`, so most flags we
|
# We don't return messages in `/register`, so most flags we
|
||||||
# can ignore, but we do need to update the unread_msgs data if
|
# can ignore, but we do need to update the unread_msgs data if
|
||||||
# unread state is changed.
|
# unread state is changed.
|
||||||
if 'raw_unread_msgs' in state and event['flag'] == 'read' and event['operation'] == 'add':
|
if 'raw_unread_msgs' in state and event['flag'] == 'read' and event['op'] == 'add':
|
||||||
for remove_id in event['messages']:
|
for remove_id in event['messages']:
|
||||||
remove_message_id_from_unread_mgs(state['raw_unread_msgs'], remove_id)
|
remove_message_id_from_unread_mgs(state['raw_unread_msgs'], remove_id)
|
||||||
if event['flag'] == 'starred' and 'starred_messages' in state:
|
if event['flag'] == 'starred' and 'starred_messages' in state:
|
||||||
if event['operation'] == 'add':
|
if event['op'] == 'add':
|
||||||
state['starred_messages'] += event['messages']
|
state['starred_messages'] += event['messages']
|
||||||
if event['operation'] == 'remove':
|
if event['op'] == 'remove':
|
||||||
state['starred_messages'] = [message for message in state['starred_messages']
|
state['starred_messages'] = [message for message in state['starred_messages']
|
||||||
if not (message in event['messages'])]
|
if not (message in event['messages'])]
|
||||||
elif event['type'] == "realm_domains":
|
elif event['type'] == "realm_domains":
|
||||||
|
|
|
@ -2043,9 +2043,17 @@ paths:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- update_message_flags
|
- update_message_flags
|
||||||
|
op:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- add
|
||||||
operation:
|
operation:
|
||||||
|
deprecated: true
|
||||||
description: |
|
description: |
|
||||||
Whether the flags are added or removed.
|
Old name for `op` for this event type.
|
||||||
|
|
||||||
|
**Deprecated**: This is deprecated; please use `op` instead
|
||||||
|
starting with Zulip 4.0 (feature level 32).
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- add
|
- add
|
||||||
|
@ -2069,6 +2077,7 @@ paths:
|
||||||
example:
|
example:
|
||||||
{
|
{
|
||||||
"type": "update_message_flags",
|
"type": "update_message_flags",
|
||||||
|
"op": "add",
|
||||||
"operation": "add",
|
"operation": "add",
|
||||||
"flag": "starred",
|
"flag": "starred",
|
||||||
"messages": [63],
|
"messages": [63],
|
||||||
|
@ -2087,10 +2096,18 @@ paths:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- update_message_flags
|
- update_message_flags
|
||||||
|
op:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- remove
|
||||||
operation:
|
operation:
|
||||||
|
deprecated: true
|
||||||
type: string
|
type: string
|
||||||
description: |
|
description: |
|
||||||
Whether the flags are added or removed.
|
Old name for `op` for this event type.
|
||||||
|
|
||||||
|
**Deprecated**: This is deprecated; please use `op` instead
|
||||||
|
starting with Zulip 4.0 (feature level 32).
|
||||||
enum:
|
enum:
|
||||||
- remove
|
- remove
|
||||||
flag:
|
flag:
|
||||||
|
@ -2112,6 +2129,7 @@ paths:
|
||||||
example:
|
example:
|
||||||
{
|
{
|
||||||
"type": "update_message_flags",
|
"type": "update_message_flags",
|
||||||
|
"op": "remove",
|
||||||
"operation": "remove",
|
"operation": "remove",
|
||||||
"flag": "starred",
|
"flag": "starred",
|
||||||
"messages": [63],
|
"messages": [63],
|
||||||
|
|
Loading…
Reference in New Issue