Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
1c555527
Unverified
Commit
1c555527
authored
3 years ago
by
Eric Eastwood
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Split out `/batch_send` meta events to their own fields (MSC2716) (#10777)
parent
8eb7cb2e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/10777.misc
+1
-0
1 addition, 0 deletions
changelog.d/10777.misc
synapse/rest/client/room_batch.py
+18
-11
18 additions, 11 deletions
synapse/rest/client/room_batch.py
with
19 additions
and
11 deletions
changelog.d/10777.misc
0 → 100644
+
1
−
0
View file @
1c555527
Split out [MSC2716](https://github.com/matrix-org/matrix-doc/pull/2716) meta events to their own fields in the `/batch_send` response.
This diff is collapsed.
Click to expand it.
synapse/rest/client/room_batch.py
+
18
−
11
View file @
1c555527
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
import
logging
import
logging
import
re
import
re
from
http
import
HTTPStatus
from
typing
import
TYPE_CHECKING
,
Awaitable
,
List
,
Tuple
from
typing
import
TYPE_CHECKING
,
Awaitable
,
List
,
Tuple
from
twisted.web.server
import
Request
from
twisted.web.server
import
Request
...
@@ -179,7 +180,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
...
@@ -179,7 +180,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
if
not
requester
.
app_service
:
if
not
requester
.
app_service
:
raise
AuthError
(
raise
AuthError
(
403
,
HTTPStatus
.
FORBIDDEN
,
"
Only application services can use the /batchsend endpoint
"
,
"
Only application services can use the /batchsend endpoint
"
,
)
)
...
@@ -192,7 +193,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
...
@@ -192,7 +193,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
if
prev_events_from_query
is
None
:
if
prev_events_from_query
is
None
:
raise
SynapseError
(
raise
SynapseError
(
400
,
HTTPStatus
.
BAD_REQUEST
,
"
prev_event query parameter is required when inserting historical messages back in time
"
,
"
prev_event query parameter is required when inserting historical messages back in time
"
,
errcode
=
Codes
.
MISSING_PARAM
,
errcode
=
Codes
.
MISSING_PARAM
,
)
)
...
@@ -213,7 +214,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
...
@@ -213,7 +214,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
prev_state_ids
=
list
(
prev_state_map
.
values
())
prev_state_ids
=
list
(
prev_state_map
.
values
())
auth_event_ids
=
prev_state_ids
auth_event_ids
=
prev_state_ids
state_events_at_start
=
[]
state_event
_id
s_at_start
=
[]
for
state_event
in
body
[
"
state_events_at_start
"
]:
for
state_event
in
body
[
"
state_events_at_start
"
]:
assert_params_in_dict
(
assert_params_in_dict
(
state_event
,
[
"
type
"
,
"
origin_server_ts
"
,
"
content
"
,
"
sender
"
]
state_event
,
[
"
type
"
,
"
origin_server_ts
"
,
"
content
"
,
"
sender
"
]
...
@@ -279,7 +280,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
...
@@ -279,7 +280,7 @@ class RoomBatchSendEventRestServlet(RestServlet):
)
)
event_id
=
event
.
event_id
event_id
=
event
.
event_id
state_events_at_start
.
append
(
event_id
)
state_event
_id
s_at_start
.
append
(
event_id
)
auth_event_ids
.
append
(
event_id
)
auth_event_ids
.
append
(
event_id
)
events_to_create
=
body
[
"
events
"
]
events_to_create
=
body
[
"
events
"
]
...
@@ -424,20 +425,26 @@ class RoomBatchSendEventRestServlet(RestServlet):
...
@@ -424,20 +425,26 @@ class RoomBatchSendEventRestServlet(RestServlet):
context
=
context
,
context
=
context
,
)
)
# Add the base_insertion_event to the bottom of the list we return
insertion_event_id
=
event_ids
[
0
]
if
base_insertion_event
is
not
None
:
chunk_event_id
=
event_ids
[
-
1
]
event_ids
.
append
(
base_insertion_event
.
event_id
)
historical_event_ids
=
event_id
s
[
1
:
-
1
]
re
turn
200
,
{
re
sponse_dict
=
{
"
state_events
"
:
state_events_at_start
,
"
state_event
_id
s
"
:
state_event
_id
s_at_start
,
"
events
"
:
event_ids
,
"
event
_id
s
"
:
historical_
event_ids
,
"
next_chunk_id
"
:
insertion_event
[
"
content
"
][
"
next_chunk_id
"
:
insertion_event
[
"
content
"
][
EventContentFields
.
MSC2716_NEXT_CHUNK_ID
EventContentFields
.
MSC2716_NEXT_CHUNK_ID
],
],
"
insertion_event_id
"
:
insertion_event_id
,
"
chunk_event_id
"
:
chunk_event_id
,
}
}
if
base_insertion_event
is
not
None
:
response_dict
[
"
base_insertion_event_id
"
]
=
base_insertion_event
.
event_id
return
HTTPStatus
.
OK
,
response_dict
def
on_GET
(
self
,
request
:
Request
,
room_id
:
str
)
->
Tuple
[
int
,
str
]:
def
on_GET
(
self
,
request
:
Request
,
room_id
:
str
)
->
Tuple
[
int
,
str
]:
return
501
,
"
Not implemented
"
return
HTTPStatus
.
NOT_IMPLEMENTED
,
"
Not implemented
"
def
on_PUT
(
def
on_PUT
(
self
,
request
:
SynapseRequest
,
room_id
:
str
self
,
request
:
SynapseRequest
,
room_id
:
str
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment