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
6ec38454
Commit
6ec38454
authored
7 years ago
by
Konstantinos Sideris
Browse files
Options
Downloads
Patches
Plain Diff
Add endpoint to upload filters
fixes #14
parent
0b28322a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
cmake/MatrixStructs.cmake
+1
-1
1 addition, 1 deletion
cmake/MatrixStructs.cmake
src/client.cpp
+9
-0
9 additions, 0 deletions
src/client.cpp
src/client.hpp
+4
-1
4 additions, 1 deletion
src/client.hpp
tests/client_api.cpp
+24
-4
24 additions, 4 deletions
tests/client_api.cpp
with
38 additions
and
6 deletions
cmake/MatrixStructs.cmake
+
1
−
1
View file @
6ec38454
...
...
@@ -13,7 +13,7 @@ ExternalProject_Add(
MatrixStructs
GIT_REPOSITORY https://github.com/mujx/matrix-structs
GIT_TAG
baf455a6fee01be8235815c60e1231a8183ef1a3
GIT_TAG
4debe73fc653664e54667dba98aeac80939e3432
BUILD_IN_SOURCE 1
SOURCE_DIR
${
MATRIX_STRUCTS_ROOT
}
...
...
This diff is collapsed.
Click to expand it.
src/client.cpp
+
9
−
0
View file @
6ec38454
...
...
@@ -485,3 +485,12 @@ Client::messages(const mtx::identifiers::Room &room_id,
callback
(
res
,
err
);
});
}
void
Client
::
upload_filter
(
const
nlohmann
::
json
&
j
,
std
::
function
<
void
(
const
mtx
::
responses
::
FilterId
,
RequestErr
err
)
>
callback
)
{
const
auto
api_path
=
"/client/r0/user/"
+
user_id_
.
toString
()
+
"/filter"
;
post
<
nlohmann
::
json
,
mtx
::
responses
::
FilterId
>
(
api_path
,
j
,
callback
);
}
This diff is collapsed.
Click to expand it.
src/client.hpp
+
4
−
1
View file @
6ec38454
...
...
@@ -117,6 +117,10 @@ public:
//! Get the supported versions from the server.
void
versions
(
std
::
function
<
void
(
const
mtx
::
responses
::
Versions
&
res
,
RequestErr
err
)
>
);
//! Upload a filter
void
upload_filter
(
const
nlohmann
::
json
&
j
,
std
::
function
<
void
(
const
mtx
::
responses
::
FilterId
,
RequestErr
err
)
>
);
//! Upload data to the content repository.
void
upload
(
const
std
::
string
&
data
,
const
std
::
string
&
content_type
,
...
...
@@ -369,7 +373,6 @@ mtx::client::Client::create_session(
this
](
RequestID
,
const
boost
::
beast
::
http
::
response
<
boost
::
beast
::
http
::
string_body
>
&
response
,
const
boost
::
system
::
error_code
&
err_code
)
{
ios_
.
post
([
callback
,
response
,
err_code
]()
{
Response
response_data
;
mtx
::
client
::
errors
::
ClientError
client_error
;
...
...
This diff is collapsed.
Click to expand it.
tests/client_api.cpp
+
24
−
4
View file @
6ec38454
...
...
@@ -143,7 +143,6 @@ TEST(ClientAPI, EmptyUserAvatar)
ASSERT_TRUE
(
res
.
avatar_url
.
size
()
==
0
);
});
});
});
alice
->
close
();
...
...
@@ -184,7 +183,6 @@ TEST(ClientAPI, RealUserAvatar)
ASSERT_TRUE
(
res
.
avatar_url
==
avatar_url
);
});
});
});
alice
->
close
();
...
...
@@ -285,7 +283,6 @@ TEST(ClientAPI, LogoutSuccess)
ASSERT_TRUE
(
err
);
EXPECT_EQ
(
mtx
::
errors
::
to_string
(
err
->
matrix_error
.
errcode
),
"M_MISSING_TOKEN"
);
EXPECT_EQ
(
err
->
status_code
,
boost
::
beast
::
http
::
status
::
forbidden
);
});
mtx_client
->
close
();
...
...
@@ -538,7 +535,6 @@ TEST(ClientAPI, InvalidInvite)
EXPECT_EQ
(
mtx
::
errors
::
to_string
(
err
->
matrix_error
.
errcode
),
"M_FORBIDDEN"
);
});
});
...
...
@@ -858,3 +854,27 @@ TEST(ClientAPI, Pagination)
alice
->
close
();
}
TEST
(
ClientAPI
,
UploadFilter
)
{
auto
alice
=
std
::
make_shared
<
Client
>
(
"localhost"
);
alice
->
login
(
"alice"
,
"secret"
,
[
alice
](
const
mtx
::
responses
::
Login
&
,
ErrType
err
)
{
check_error
(
err
);
});
while
(
alice
->
access_token
().
empty
())
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
100
));
nlohmann
::
json
j
=
{
{
"room"
,
{{
"include_leave"
,
true
},
{
"account_data"
,
{{
"not_types"
,
{
"*"
}}}}}},
{
"account_data"
,
{{
"not_types"
,
{
"*"
}}}},
{
"presence"
,
{{
"not_types"
,
{
"*"
}}}}};
alice
->
upload_filter
(
j
,
[](
const
mtx
::
responses
::
FilterId
&
res
,
ErrType
err
)
{
check_error
(
err
);
ASSERT_TRUE
(
res
.
filter_id
.
size
()
>
0
);
});
alice
->
close
();
}
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