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
028e2635
Commit
028e2635
authored
3 years ago
by
Thulinma
Browse files
Options
Downloads
Patches
Plain Diff
Implemented device deletion
parent
f9d0ec07
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
include/mtxclient/http/client.hpp
+7
-4
7 additions, 4 deletions
include/mtxclient/http/client.hpp
lib/http/client.cpp
+50
-0
50 additions, 0 deletions
lib/http/client.cpp
with
57 additions
and
4 deletions
include/mtxclient/http/client.hpp
+
7
−
4
View file @
028e2635
...
...
@@ -598,10 +598,13 @@ public:
const
std
::
string
&
display_name
,
ErrCallback
callback
);
/////! Rename device
// void rename_device(const mtx::requests::DeviceSigningUpload,
// UIAHandler uia_handler,
// ErrCallback cb);
//! Delete device
void
delete_device
(
const
std
::
string
&
device_id
,
UIAHandler
uia_handler
,
ErrCallback
cb
);
//! Delete devices
void
delete_devices
(
const
std
::
vector
<
std
::
string
>
&
device_ids
,
UIAHandler
uia_handler
,
ErrCallback
cb
);
//
// Encryption related endpoints.
...
...
This diff is collapsed.
Click to expand it.
lib/http/client.cpp
+
50
−
0
View file @
028e2635
...
...
@@ -1115,6 +1115,56 @@ Client::set_device_name(const std::string &device_id,
"/client/r0/devices/"
+
mtx
::
client
::
utils
::
url_encode
(
device_id
),
req
,
callback
);
}
void
Client
::
delete_device
(
const
std
::
string
&
device_id
,
UIAHandler
uia_handler
,
ErrCallback
cb
)
{
nlohmann
::
json
req
;
req
[
"devices"
]
=
{
device_id
};
uia_handler
.
next_
=
[
this
,
req
,
cb
](
const
UIAHandler
&
h
,
const
nlohmann
::
json
&
auth
)
{
auto
request
=
req
;
if
(
!
auth
.
empty
())
request
[
"auth"
]
=
auth
;
post
<
nlohmann
::
json
,
mtx
::
responses
::
Empty
>
(
"/client/r0/delete_devices"
,
request
,
[
cb
,
h
](
auto
&
,
RequestErr
e
)
{
if
(
e
&&
e
->
status_code
==
401
&&
!
e
->
matrix_error
.
unauthorized
.
flows
.
empty
())
h
.
prompt
(
h
,
e
->
matrix_error
.
unauthorized
);
else
cb
(
e
);
});
};
uia_handler
.
next_
(
uia_handler
,
{});
}
void
Client
::
delete_devices
(
const
std
::
vector
<
std
::
string
>
&
device_ids
,
UIAHandler
uia_handler
,
ErrCallback
cb
)
{
nlohmann
::
json
req
;
for
(
auto
it
=
device_ids
.
begin
();
it
!=
device_ids
.
end
();
++
it
)
{
req
[
"devices"
].
push_back
(
*
it
);
}
uia_handler
.
next_
=
[
this
,
req
,
cb
](
const
UIAHandler
&
h
,
const
nlohmann
::
json
&
auth
)
{
auto
request
=
req
;
if
(
!
auth
.
empty
())
request
[
"auth"
]
=
auth
;
post
<
nlohmann
::
json
,
mtx
::
responses
::
Empty
>
(
"/client/r0/delete_devices"
,
request
,
[
cb
,
h
](
auto
&
,
RequestErr
e
)
{
if
(
e
&&
e
->
status_code
==
401
&&
!
e
->
matrix_error
.
unauthorized
.
flows
.
empty
())
h
.
prompt
(
h
,
e
->
matrix_error
.
unauthorized
);
else
cb
(
e
);
});
};
uia_handler
.
next_
(
uia_handler
,
{});
}
//
// Encryption related endpoints
//
...
...
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