Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mtxclient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Nheko Reborn
mtxclient
Commits
8cd268b9
Verified
Commit
8cd268b9
authored
1 year ago
by
Nicolas Werner
Browse files
Options
Downloads
Patches
Plain Diff
Add support for intentional mentions
parent
158e991f
No related branches found
No related tags found
No related merge requests found
Pipeline
#5652
failed
1 year ago
Stage: build
Stage: deploy
Changes
22
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/structs/events/messages/video.cpp
+2
-0
2 additions, 0 deletions
lib/structs/events/messages/video.cpp
tests/messages.cpp
+51
-0
51 additions, 0 deletions
tests/messages.cpp
with
53 additions
and
0 deletions
lib/structs/events/messages/video.cpp
+
2
−
0
View file @
8cd268b9
...
...
@@ -28,6 +28,7 @@ from_json(const json &obj, Video &content)
content
.
file
=
obj
.
at
(
"file"
).
get
<
crypto
::
EncryptedFile
>
();
content
.
relations
=
common
::
parse_relations
(
obj
);
content
.
mentions
=
common
::
parse_mentions
(
obj
);
}
void
...
...
@@ -43,6 +44,7 @@ to_json(json &obj, const Video &content)
obj
[
"url"
]
=
content
.
url
;
common
::
apply_relations
(
obj
,
content
.
relations
);
common
::
add_mentions
(
obj
,
content
.
mentions
);
}
}
// namespace msg
...
...
This diff is collapsed.
Click to expand it.
tests/messages.cpp
+
51
−
0
View file @
8cd268b9
...
...
@@ -587,6 +587,57 @@ TEST(RoomEvents, TextMessage)
EXPECT_EQ
(
data
.
dump
(),
json
(
event
).
dump
());
}
TEST
(
RoomEvents
,
TextMessageWithMention
)
{
json
data
=
R"({
"origin_server_ts": 1510489356530,
"sender": "@nheko_test:matrix.org",
"event_id": "$15104893562785758wEgEU:matrix.org",
"unsigned": {
"age": 2225,
"transaction_id": "m1510489356267.2"
},
"content": {
"body": "hey there",
"msgtype": "m.text",
"m.relates_to": {
"m.in_reply_to": {
"event_id": "$6GKhAfJOcwNd69lgSizdcTob8z2pWQgBOZPrnsWMA1E"
}
},
"m.mentions": {
"room": true,
"user_ids": ["@alice:example.org"]
}
},
"type": "m.room.message",
"room_id": "!lfoDRlNFWlvOnvkBwQ:matrix.org"
})"
_json
;
RoomEvent
<
msg
::
Text
>
event
=
data
.
get
<
RoomEvent
<
msg
::
Text
>>
();
EXPECT_EQ
(
event
.
type
,
EventType
::
RoomMessage
);
EXPECT_EQ
(
event
.
event_id
,
"$15104893562785758wEgEU:matrix.org"
);
EXPECT_EQ
(
event
.
room_id
,
"!lfoDRlNFWlvOnvkBwQ:matrix.org"
);
EXPECT_EQ
(
event
.
sender
,
"@nheko_test:matrix.org"
);
EXPECT_EQ
(
event
.
origin_server_ts
,
1510489356530L
);
EXPECT_EQ
(
event
.
unsigned_data
.
age
,
2225
);
EXPECT_EQ
(
event
.
unsigned_data
.
transaction_id
,
"m1510489356267.2"
);
EXPECT_EQ
(
event
.
content
.
body
,
"hey there"
);
EXPECT_EQ
(
event
.
content
.
msgtype
,
"m.text"
);
EXPECT_EQ
(
event
.
content
.
relations
.
relations
.
at
(
0
).
event_id
,
"$6GKhAfJOcwNd69lgSizdcTob8z2pWQgBOZPrnsWMA1E"
);
EXPECT_EQ
(
event
.
content
.
relations
.
relations
.
at
(
0
).
rel_type
,
mtx
::
common
::
RelationType
::
InReplyTo
);
ASSERT_TRUE
(
event
.
content
.
mentions
.
has_value
());
EXPECT_EQ
(
event
.
content
.
mentions
->
room
,
true
);
EXPECT_EQ
(
event
.
content
.
mentions
->
user_ids
,
std
::
vector
<
std
::
string
>
{
"@alice:example.org"
});
EXPECT_EQ
(
data
.
dump
(),
json
(
event
).
dump
());
}
TEST
(
RoomEvents
,
VideoMessage
)
{
json
data
=
R"({
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
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