Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
conduwuit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
🥺
conduwuit
Commits
b30884c7
Commit
b30884c7
authored
1 year ago
by
tezlm
Committed by
🥺
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
reply to messages
parent
ebb94341
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/service/admin/mod.rs
+28
-21
28 additions, 21 deletions
src/service/admin/mod.rs
src/service/rooms/timeline/mod.rs
+1
-1
1 addition, 1 deletion
src/service/rooms/timeline/mod.rs
with
29 additions
and
22 deletions
src/service/admin/mod.rs
+
28
−
21
View file @
b30884c7
...
...
@@ -9,6 +9,7 @@
use
regex
::
Regex
;
use
ruma
::{
events
::{
relation
::
InReplyTo
,
room
::{
canonical_alias
::
RoomCanonicalAliasEventContent
,
create
::
RoomCreateEventContent
,
...
...
@@ -16,7 +17,7 @@
history_visibility
::{
HistoryVisibility
,
RoomHistoryVisibilityEventContent
},
join_rules
::{
JoinRule
,
RoomJoinRulesEventContent
},
member
::{
MembershipState
,
RoomMemberEventContent
},
message
::
RoomMessageEventContent
,
message
::
{
Relation
::
Reply
,
RoomMessageEventContent
}
,
name
::
RoomNameEventContent
,
power_levels
::
RoomPowerLevelsEventContent
,
topic
::
RoomTopicEventContent
,
...
...
@@ -285,7 +286,7 @@ enum ServerCommand {
#[derive(Debug)]
pub
enum
AdminRoomEvent
{
ProcessMessage
(
String
),
ProcessMessage
(
String
,
Arc
<
EventId
>
),
SendMessage
(
RoomMessageEventContent
),
}
...
...
@@ -333,9 +334,11 @@ async fn handler(&self) {
loop
{
tokio
::
select!
{
Some
(
event
)
=
receiver
.recv
()
=>
{
let
message_content
=
match
event
{
AdminRoomEvent
::
SendMessage
(
content
)
=>
content
,
AdminRoomEvent
::
ProcessMessage
(
room_message
)
=>
self
.process_admin_message
(
room_message
)
.await
let
(
mut
message_content
,
reply
)
=
match
event
{
AdminRoomEvent
::
SendMessage
(
content
)
=>
(
content
,
None
),
AdminRoomEvent
::
ProcessMessage
(
room_message
,
reply_id
)
=>
{
(
self
.process_admin_message
(
room_message
)
.await
,
Some
(
reply_id
))
}
};
let
mutex_state
=
Arc
::
clone
(
...
...
@@ -349,20 +352,24 @@ async fn handler(&self) {
let
state_lock
=
mutex_state
.lock
()
.await
;
services
()
.rooms.timeline
.build_and_append_pdu
(
PduBuilder
{
event_type
:
TimelineEventType
::
RoomMessage
,
content
:
to_raw_value
(
&
message_content
)
.expect
(
"event is valid, we just created it"
),
unsigned
:
None
,
state_key
:
None
,
redacts
:
None
,
},
&
conduit_user
,
&
conduit_room
,
&
state_lock
)
.await
.unwrap
();
if
let
Some
(
reply
)
=
reply
{
message_content
.relates_to
=
Some
(
Reply
{
in_reply_to
:
InReplyTo
{
event_id
:
reply
.into
()
}
})
}
services
()
.rooms.timeline
.build_and_append_pdu
(
PduBuilder
{
event_type
:
TimelineEventType
::
RoomMessage
,
content
:
to_raw_value
(
&
message_content
)
.expect
(
"event is valid, we just created it"
),
unsigned
:
None
,
state_key
:
None
,
redacts
:
None
,
},
&
conduit_user
,
&
conduit_room
,
&
state_lock
)
.await
.unwrap
();
drop
(
state_lock
);
...
...
@@ -371,9 +378,9 @@ async fn handler(&self) {
}
}
pub
fn
process_message
(
&
self
,
room_message
:
String
)
{
pub
fn
process_message
(
&
self
,
room_message
:
String
,
event_id
:
Arc
<
EventId
>
)
{
self
.sender
.send
(
AdminRoomEvent
::
ProcessMessage
(
room_message
))
.send
(
AdminRoomEvent
::
ProcessMessage
(
room_message
,
event_id
))
.unwrap
();
}
...
...
This diff is collapsed.
Click to expand it.
src/service/rooms/timeline/mod.rs
+
1
−
1
View file @
b30884c7
...
...
@@ -483,7 +483,7 @@ struct ExtractBody {
&&
services
()
.globals
.emergency_password
()
.is_none
();
if
to_conduit
&&
!
from_conduit
&&
admin_room
.as_ref
()
==
Some
(
&
pdu
.room_id
)
{
services
()
.admin
.process_message
(
body
);
services
()
.admin
.process_message
(
body
,
pdu
.event_id
.clone
()
);
}
}
}
...
...
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