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
f664dbbd
Verified
Commit
f664dbbd
authored
3 years ago
by
Nicolas Werner
Browse files
Options
Downloads
Patches
Plain Diff
Add function to knock on rooms
parent
a368db30
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/mtxclient/http/client.hpp
+6
-0
6 additions, 0 deletions
include/mtxclient/http/client.hpp
lib/http/client.cpp
+23
-0
23 additions, 0 deletions
lib/http/client.cpp
with
29 additions
and
0 deletions
include/mtxclient/http/client.hpp
+
6
−
0
View file @
f664dbbd
...
...
@@ -338,6 +338,12 @@ public:
Callback
<
mtx
::
responses
::
RoomId
>
cb
);
//! Leave a room by its room_id.
void
leave_room
(
const
std
::
string
&
room_id
,
Callback
<
mtx
::
responses
::
Empty
>
cb
);
//! Knock on a room.
void
knock_room
(
const
std
::
string
&
room_id
,
const
std
::
vector
<
std
::
string
>
&
via
,
Callback
<
mtx
::
responses
::
RoomId
>
cb
,
const
std
::
string
&
reason
=
""
);
//! Invite a user to a room.
void
invite_user
(
const
std
::
string
&
room_id
,
const
std
::
string
&
user_id
,
...
...
This diff is collapsed.
Click to expand it.
lib/http/client.cpp
+
23
−
0
View file @
f664dbbd
...
...
@@ -541,6 +541,29 @@ Client::join_room(const std::string &room,
post
<
std
::
string
,
mtx
::
responses
::
RoomId
>
(
api_path
,
"{}"
,
callback
);
}
void
Client
::
knock_room
(
const
std
::
string
&
room
,
const
std
::
vector
<
std
::
string
>
&
via
,
Callback
<
mtx
::
responses
::
RoomId
>
cb
,
const
std
::
string
&
reason
)
{
using
mtx
::
client
::
utils
::
url_encode
;
std
::
string
query
;
if
(
!
via
.
empty
())
{
query
=
"?server_name="
+
url_encode
(
via
[
0
]);
for
(
size_t
i
=
1
;
i
<
via
.
size
();
i
++
)
{
query
+=
"&server_name="
+
url_encode
(
via
[
i
]);
}
}
auto
api_path
=
"/client/r0/knock/"
+
url_encode
(
room
)
+
query
;
auto
body
=
nlohmann
::
json
::
object
();
if
(
!
reason
.
empty
())
body
[
"reason"
]
=
reason
;
post
<
std
::
string
,
mtx
::
responses
::
RoomId
>
(
api_path
,
body
.
dump
(),
cb
);
}
void
Client
::
leave_room
(
const
std
::
string
&
room_id
,
Callback
<
mtx
::
responses
::
Empty
>
callback
)
{
...
...
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