rocketchat-API 3.2.0__tar.gz → 3.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.github/workflows/release.yml +8 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/PKG-INFO +2 -1
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/pyproject.toml +1 -0
- rocketchat_api-3.4.0/rocketchat_API/APISections/banners.py +23 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/base.py +42 -18
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/chat.py +61 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/dm.py +4 -0
- rocketchat_api-3.4.0/rocketchat_API/APISections/invites.py +32 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/livechat.py +12 -0
- rocketchat_api-3.4.0/rocketchat_API/APISections/moderation.py +67 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/roles.py +8 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/rocketchat.py +2 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API.egg-info/PKG-INFO +2 -1
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API.egg-info/SOURCES.txt +2 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API.egg-info/requires.txt +1 -0
- rocketchat_api-3.4.0/tests/test_banners.py +62 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_chat.py +103 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_dms.py +8 -0
- rocketchat_api-3.4.0/tests/test_invites.py +50 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_livechat.py +15 -0
- rocketchat_api-3.4.0/tests/test_moderation.py +135 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_roles.py +18 -0
- rocketchat_api-3.2.0/rocketchat_API/APISections/banners.py +0 -11
- rocketchat_api-3.2.0/rocketchat_API/APISections/invites.py +0 -16
- rocketchat_api-3.2.0/tests/test_banners.py +0 -3
- rocketchat_api-3.2.0/tests/test_invites.py +0 -12
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.coveragerc +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.deepsource.toml +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.editorconfig +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.github/actions/test_rocketchat/action.yml +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.github/dependabot.yml +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.github/workflows/lint.yml +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.github/workflows/test.yml +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.github/workflows/test_latest.yml +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.github/workflows/test_manually.yml +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/.gitignore +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/CONTRIBUTING.md +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/LICENSE.txt +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/README.md +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/bandit.yml +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/docker-compose.yml +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/qodana.yaml +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APIExceptions/RocketExceptions.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APIExceptions/__init__.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/__init__.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/assets.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/channels.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/custom_emoji.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/groups.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/integrations.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/licenses.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/miscellaneous.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/permissions.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/rooms.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/settings.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/statistics.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/subscriptions.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/teams.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/users.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/users_engagement.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/__init__.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API.egg-info/dependency_links.txt +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API.egg-info/top_level.txt +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/setup.cfg +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/__init__.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/assets/avatar.png +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/assets/avatar.svg +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/assets/logo.png +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/conftest.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_assets.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_channels.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_custom_emoji.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_exceptions.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_groups.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_integrations.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_licenses.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_paginated.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_permissions.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_rooms.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_server.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_settings.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_subscriptions.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_teams.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_user.py +0 -0
- {rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/tests/test_users_engagement.py +0 -0
|
@@ -28,3 +28,11 @@ jobs:
|
|
|
28
28
|
python3 -m build
|
|
29
29
|
- name: Publish package distributions to PyPI
|
|
30
30
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
31
|
+
- name: Announce release
|
|
32
|
+
uses: jadolg/rocketchat-notification-action@v2.0.0
|
|
33
|
+
with:
|
|
34
|
+
server: https://open.rocket.chat
|
|
35
|
+
message: A new version (${{ github.event.release.tag_name }}) has been released! ${{ github.event.release.html_url }}
|
|
36
|
+
user: ${{ secrets.ROCKETCHAT_USER }}
|
|
37
|
+
password: ${{ secrets.ROCKETCHAT_PASSWORD }}
|
|
38
|
+
channel: "#python_rocketchat_api"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rocketchat_API
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: Python API wrapper for Rocket.Chat
|
|
5
5
|
Author-email: "Jorge Alberto Díaz Orozco (Akiel)" <diazorozcoj@gmail.com>
|
|
6
6
|
Maintainer-email: "Jorge Alberto Díaz Orozco (Akiel)" <diazorozcoj@gmail.com>
|
|
@@ -16,6 +16,7 @@ Provides-Extra: test
|
|
|
16
16
|
Requires-Dist: black; extra == "test"
|
|
17
17
|
Requires-Dist: pytest; extra == "test"
|
|
18
18
|
Requires-Dist: pytest-cov; extra == "test"
|
|
19
|
+
Requires-Dist: pymongo; extra == "test"
|
|
19
20
|
Requires-Dist: requests; extra == "test"
|
|
20
21
|
Requires-Dist: semver; extra == "test"
|
|
21
22
|
Dynamic: license-file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from rocketchat_API.APISections.base import RocketChatBase
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class RocketChatBanners(RocketChatBase):
|
|
5
|
+
def banners(self, platform, **kwargs):
|
|
6
|
+
"""Gets the banner to be shown to the authenticated user"""
|
|
7
|
+
return self.call_api_get(
|
|
8
|
+
"banners",
|
|
9
|
+
platform=platform,
|
|
10
|
+
kwargs=kwargs,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
def banners_get_by_id(self, banner_id, platform, **kwargs):
|
|
14
|
+
"""Gets a banner by its ID."""
|
|
15
|
+
return self.call_api_get(
|
|
16
|
+
"banners/{}".format(banner_id),
|
|
17
|
+
platform=platform,
|
|
18
|
+
kwargs=kwargs,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
def banners_dismiss(self, banner_id, **kwargs):
|
|
22
|
+
"""Dismisses a banner for the authenticated user."""
|
|
23
|
+
return self.call_api_post("banners.dismiss", bannerId=banner_id, kwargs=kwargs)
|
|
@@ -200,24 +200,37 @@ class RocketChatBase:
|
|
|
200
200
|
)
|
|
201
201
|
)
|
|
202
202
|
|
|
203
|
-
def call_api_post(self, method, files=None, use_json=None, **kwargs):
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
203
|
+
def call_api_post(self, method, body=None, files=None, use_json=None, **kwargs):
|
|
204
|
+
"""Send a POST request to the API.
|
|
205
|
+
|
|
206
|
+
There are two modes of operation:
|
|
207
|
+
|
|
208
|
+
1. **Raw body** — pass ``body`` directly. The value is serialized as-is
|
|
209
|
+
via ``json=body``, which supports any JSON-serializable structure
|
|
210
|
+
(lists, dicts, etc.). ``kwargs`` are ignored in this mode.
|
|
211
|
+
|
|
212
|
+
2. **Keyword arguments** (default) — individual kwargs are collected
|
|
213
|
+
into a dict and sent as the request payload. By default the payload
|
|
214
|
+
is sent as JSON (``json=``), but when ``files`` are provided it
|
|
215
|
+
falls back to form-encoded ``data=`` because requests ignores the
|
|
216
|
+
``json`` parameter when ``files`` is set. You can override this
|
|
217
|
+
with ``use_json=True/False``.
|
|
218
|
+
|
|
219
|
+
:param method: API method path, appended to ``self.api_path``.
|
|
220
|
+
:param body: A raw JSON-serializable payload (e.g. a list).
|
|
221
|
+
When provided, ``kwargs``, ``files``, and ``use_json``
|
|
222
|
+
are ignored.
|
|
223
|
+
:param files: Files to upload (passed to ``requests``).
|
|
224
|
+
:param use_json: Force JSON (True) or form-encoded (False) encoding.
|
|
225
|
+
Defaults to JSON when no files are attached.
|
|
226
|
+
"""
|
|
227
|
+
url = self.server_url + self.api_path + method
|
|
228
|
+
|
|
229
|
+
if body is not None:
|
|
216
230
|
return json_or_error(
|
|
217
231
|
self.session.post(
|
|
218
|
-
|
|
219
|
-
json=
|
|
220
|
-
files=files,
|
|
232
|
+
url,
|
|
233
|
+
json=body,
|
|
221
234
|
headers=self.headers,
|
|
222
235
|
verify=self.ssl_verify,
|
|
223
236
|
cert=self.cert,
|
|
@@ -226,10 +239,21 @@ class RocketChatBase:
|
|
|
226
239
|
)
|
|
227
240
|
)
|
|
228
241
|
|
|
242
|
+
reduced_args = self.__reduce_kwargs(kwargs)
|
|
243
|
+
|
|
244
|
+
# "pass" is a Python reserved word, but some endpoints (e.g.
|
|
245
|
+
# users.register) expect it instead of "password".
|
|
246
|
+
if "password" in reduced_args and method != "users.create":
|
|
247
|
+
reduced_args["pass"] = reduced_args.pop("password")
|
|
248
|
+
|
|
249
|
+
if use_json is None:
|
|
250
|
+
use_json = files is None
|
|
251
|
+
|
|
229
252
|
return json_or_error(
|
|
230
253
|
self.session.post(
|
|
231
|
-
|
|
232
|
-
|
|
254
|
+
url,
|
|
255
|
+
json=reduced_args if use_json else None,
|
|
256
|
+
data=None if use_json else reduced_args,
|
|
233
257
|
files=files,
|
|
234
258
|
headers=self.headers,
|
|
235
259
|
verify=self.ssl_verify,
|
|
@@ -116,3 +116,64 @@ class RocketChatChat(RocketChatBase):
|
|
|
116
116
|
roomId=room_id,
|
|
117
117
|
kwargs=kwargs,
|
|
118
118
|
)
|
|
119
|
+
|
|
120
|
+
def chat_unfollow_message(self, mid, **kwargs):
|
|
121
|
+
"""Unfollow a message."""
|
|
122
|
+
return self.call_api_post("chat.unfollowMessage", mid=mid, kwargs=kwargs)
|
|
123
|
+
|
|
124
|
+
@paginated("messages")
|
|
125
|
+
def chat_get_deleted_messages(self, room_id, since, **kwargs):
|
|
126
|
+
"""Get deleted messages from a specific date."""
|
|
127
|
+
return self.call_api_get(
|
|
128
|
+
"chat.getDeletedMessages", roomId=room_id, since=since, kwargs=kwargs
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
@paginated("messages")
|
|
132
|
+
def chat_get_pinned_messages(self, room_id, **kwargs):
|
|
133
|
+
"""Get pinned messages of a room."""
|
|
134
|
+
return self.call_api_get(
|
|
135
|
+
"chat.getPinnedMessages", roomId=room_id, kwargs=kwargs
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
def chat_ignore_user(self, rid, user_id, ignore=True, **kwargs):
|
|
139
|
+
"""Ignore or unignore a user in chat."""
|
|
140
|
+
return self.call_api_get(
|
|
141
|
+
"chat.ignoreUser", rid=rid, userId=user_id, ignore=ignore, kwargs=kwargs
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
def chat_sync_thread_list(self, rid, updated_since, **kwargs):
|
|
145
|
+
"""List threads in a room updated since a given ISO date."""
|
|
146
|
+
return self.call_api_get(
|
|
147
|
+
"chat.syncThreadsList", rid=rid, updatedSince=updated_since, kwargs=kwargs
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
def chat_sync_thread_messages(self, tmid, updated_since, **kwargs):
|
|
151
|
+
"""List the messages in a thread along with any data updates from a specified date."""
|
|
152
|
+
return self.call_api_get(
|
|
153
|
+
"chat.syncThreadMessages",
|
|
154
|
+
tmid=tmid,
|
|
155
|
+
updatedSince=updated_since,
|
|
156
|
+
kwargs=kwargs,
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
def chat_sync_messages(self, room_id, last_update, **kwargs):
|
|
160
|
+
"""List the messages in a room along with any data updates from a specified date."""
|
|
161
|
+
return self.call_api_get(
|
|
162
|
+
"chat.syncMessages", roomId=room_id, lastUpdate=last_update, kwargs=kwargs
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
@paginated("threads")
|
|
166
|
+
def chat_get_threads_list(self, rid, **kwargs):
|
|
167
|
+
"""Get a list of the thread conversations in a room."""
|
|
168
|
+
return self.call_api_get("chat.getThreadsList", rid=rid, kwargs=kwargs)
|
|
169
|
+
|
|
170
|
+
def chat_get_url_preview(self, room_id, url, **kwargs):
|
|
171
|
+
"""Use this endpoint to get a URL preview that can be used in the send and update message endpoints."""
|
|
172
|
+
return self.call_api_get(
|
|
173
|
+
"chat.getURLPreview", roomId=room_id, url=url, kwargs=kwargs
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
@paginated("messages")
|
|
177
|
+
def chat_get_discussions(self, room_id, **kwargs):
|
|
178
|
+
"""Get the discussions in a room."""
|
|
179
|
+
return self.call_api_get("chat.getDiscussions", roomId=room_id, kwargs=kwargs)
|
|
@@ -83,3 +83,7 @@ class RocketChatDM(RocketChatBase):
|
|
|
83
83
|
if user_name:
|
|
84
84
|
return self.call_api_get("dm.counters", roomId=room_id, username=user_name)
|
|
85
85
|
return self.call_api_get("dm.counters", roomId=room_id)
|
|
86
|
+
|
|
87
|
+
def dm_delete(self, room_id, **kwargs):
|
|
88
|
+
"""Delete a direct message room. Requires view-room-administration permission."""
|
|
89
|
+
return self.call_api_post("dm.delete", roomId=room_id, kwargs=kwargs)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from rocketchat_API.APISections.base import RocketChatBase
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class RocketChatInvites(RocketChatBase):
|
|
5
|
+
def find_or_create_invite(self, rid, days, max_uses):
|
|
6
|
+
"""
|
|
7
|
+
Creates or return an existing invite with the specified parameters.
|
|
8
|
+
Requires the create-invite-links permission
|
|
9
|
+
"""
|
|
10
|
+
return self.call_api_post(
|
|
11
|
+
"findOrCreateInvite", rid=rid, days=days, maxUses=max_uses
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
def list_invites(self, **kwargs):
|
|
15
|
+
"""Lists all of the invites on the server. Requires the create-invite-links permission."""
|
|
16
|
+
return self.call_api_get("listInvites", kwargs=kwargs)
|
|
17
|
+
|
|
18
|
+
def remove_invite(self, invite_id, **kwargs):
|
|
19
|
+
"""Deletes an invite. Requires the create-invite-links permission."""
|
|
20
|
+
return self.call_api_delete("removeInvite/{}".format(invite_id))
|
|
21
|
+
|
|
22
|
+
def use_invite_token(self, token, **kwargs):
|
|
23
|
+
"""Reports to the server that an invite token was used."""
|
|
24
|
+
return self.call_api_post("useInviteToken", token=token, kwargs=kwargs)
|
|
25
|
+
|
|
26
|
+
def validate_invite_token(self, token, **kwargs):
|
|
27
|
+
"""Checks if an invite token is valid."""
|
|
28
|
+
return self.call_api_post("validateInviteToken", token=token, kwargs=kwargs)
|
|
29
|
+
|
|
30
|
+
def send_invitation_email(self, emails, **kwargs):
|
|
31
|
+
"""Sends invitation emails to a list of email addresses."""
|
|
32
|
+
return self.call_api_post("sendInvitationEmail", emails=emails, kwargs=kwargs)
|
|
@@ -70,3 +70,15 @@ class RocketChatLivechat(RocketChatBase):
|
|
|
70
70
|
return self.call_api_get(
|
|
71
71
|
"livechat/inquiries.getOne", roomId=room_id, kwargs=kwargs
|
|
72
72
|
)
|
|
73
|
+
|
|
74
|
+
def livechat_get_appearance(self, **kwargs):
|
|
75
|
+
"""Get the settings about the widget appearance. Permission required: view-livechat-manager"""
|
|
76
|
+
return self.call_api_get("livechat/appearance", kwargs=kwargs)
|
|
77
|
+
|
|
78
|
+
def livechat_set_appearance(self, settings):
|
|
79
|
+
"""Update the livechat widget appearance settings. Permission required: view-livechat-manager
|
|
80
|
+
|
|
81
|
+
:param settings: list of dicts with '_id' and 'value' keys,
|
|
82
|
+
e.g. [{"_id": "Livechat_title", "value": "Support"}]
|
|
83
|
+
"""
|
|
84
|
+
return self.call_api_post("livechat/appearance", body=settings)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from rocketchat_API.APISections.base import RocketChatBase, paginated
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class RocketChatModeration(RocketChatBase):
|
|
5
|
+
@paginated("reports")
|
|
6
|
+
def moderation_reports_by_users(self, **kwargs):
|
|
7
|
+
"""Retrieves all the reported messages grouped by users. Permission required: view-moderation-console"""
|
|
8
|
+
return self.call_api_get("moderation.reportsByUsers", kwargs=kwargs)
|
|
9
|
+
|
|
10
|
+
@paginated("reports")
|
|
11
|
+
def moderation_user_reports(self, **kwargs):
|
|
12
|
+
"""Get the list of reported users. Permission required: view-moderation-console"""
|
|
13
|
+
return self.call_api_get("moderation.userReports", kwargs=kwargs)
|
|
14
|
+
|
|
15
|
+
def moderation_user_reported_messages(self, user_id, **kwargs):
|
|
16
|
+
"""Retrieve all reported messages of a user. Permission required: view-moderation-console"""
|
|
17
|
+
return self.call_api_get(
|
|
18
|
+
"moderation.user.reportedMessages", userId=user_id, kwargs=kwargs
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
def moderation_user_reports_by_user_id(self, user_id, **kwargs):
|
|
22
|
+
"""Get the details of a specific user's reports. Permission required: view-moderation-console"""
|
|
23
|
+
return self.call_api_get(
|
|
24
|
+
"moderation.user.reportsByUserId", userId=user_id, kwargs=kwargs
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
@paginated("reports")
|
|
28
|
+
def moderation_reports(self, msg_id, **kwargs):
|
|
29
|
+
"""Retrieve all the reports of a single message. A message can have many reports. Permission required: view-moderation-console"""
|
|
30
|
+
return self.call_api_get("moderation.reports", msgId=msg_id, kwargs=kwargs)
|
|
31
|
+
|
|
32
|
+
def moderation_report_info(self, report_id, **kwargs):
|
|
33
|
+
"""Get more details of a single report. Permission required: view-moderation-console"""
|
|
34
|
+
return self.call_api_get(
|
|
35
|
+
"moderation.reportInfo", reportId=report_id, kwargs=kwargs
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
def moderation_report_user(self, user_id, description, **kwargs):
|
|
39
|
+
"""Report a user."""
|
|
40
|
+
return self.call_api_post(
|
|
41
|
+
"moderation.reportUser",
|
|
42
|
+
userId=user_id,
|
|
43
|
+
description=description,
|
|
44
|
+
kwargs=kwargs,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
def moderation_dismiss_reports(self, user_id=None, msg_id=None, **kwargs):
|
|
48
|
+
"""You can dismiss all the reports of a particular user by the userId. You can also dismiss the report of a message by the msgId. Permission required: manage-moderation-actions"""
|
|
49
|
+
if user_id:
|
|
50
|
+
return self.call_api_post(
|
|
51
|
+
"moderation.dismissReports", userId=user_id, kwargs=kwargs
|
|
52
|
+
)
|
|
53
|
+
return self.call_api_post(
|
|
54
|
+
"moderation.dismissReports", msgId=msg_id, kwargs=kwargs
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
def moderation_dismiss_user_reports(self, user_id, **kwargs):
|
|
58
|
+
"""Dismiss a specific reported user from the list of reported users. Permission required: manage-moderation-actions"""
|
|
59
|
+
return self.call_api_post(
|
|
60
|
+
"moderation.dismissUserReports", userId=user_id, kwargs=kwargs
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
def moderation_user_delete_reported_messages(self, user_id, **kwargs):
|
|
64
|
+
"""Delete all the reports of messages that belongs to user. Permission required: manage-moderation-actions"""
|
|
65
|
+
return self.call_api_post(
|
|
66
|
+
"moderation.user.deleteReportedMessages", userId=user_id, kwargs=kwargs
|
|
67
|
+
)
|
|
@@ -33,3 +33,11 @@ class RocketChatRoles(RocketChatBase):
|
|
|
33
33
|
def roles_sync(self, updated_since):
|
|
34
34
|
"""Gets all the roles in the system which are updated after a given date."""
|
|
35
35
|
return self.call_api_get("roles.sync", updatedSince=updated_since)
|
|
36
|
+
|
|
37
|
+
def roles_delete(self, role_id, **kwargs):
|
|
38
|
+
"""Deletes a role. Permission required: access-permissions"""
|
|
39
|
+
return self.call_api_post("roles.delete", roleId=role_id, kwargs=kwargs)
|
|
40
|
+
|
|
41
|
+
def roles_get_users_in_public_roles(self, **kwargs):
|
|
42
|
+
"""Gets the users that belong to any public role."""
|
|
43
|
+
return self.call_api_get("roles.getUsersInPublicRoles", kwargs=kwargs)
|
|
@@ -12,6 +12,7 @@ from rocketchat_API.APISections.invites import RocketChatInvites
|
|
|
12
12
|
from rocketchat_API.APISections.licenses import RocketChatLicenses
|
|
13
13
|
from rocketchat_API.APISections.livechat import RocketChatLivechat
|
|
14
14
|
from rocketchat_API.APISections.miscellaneous import RocketChatMiscellaneous
|
|
15
|
+
from rocketchat_API.APISections.moderation import RocketChatModeration
|
|
15
16
|
from rocketchat_API.APISections.permissions import RocketChatPermissions
|
|
16
17
|
from rocketchat_API.APISections.roles import RocketChatRoles
|
|
17
18
|
from rocketchat_API.APISections.rooms import RocketChatRooms
|
|
@@ -36,6 +37,7 @@ class RocketChat(
|
|
|
36
37
|
RocketChatLicenses,
|
|
37
38
|
RocketChatLivechat,
|
|
38
39
|
RocketChatMiscellaneous,
|
|
40
|
+
RocketChatModeration,
|
|
39
41
|
RocketChatPermissions,
|
|
40
42
|
RocketChatRoles,
|
|
41
43
|
RocketChatRooms,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rocketchat_API
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.4.0
|
|
4
4
|
Summary: Python API wrapper for Rocket.Chat
|
|
5
5
|
Author-email: "Jorge Alberto Díaz Orozco (Akiel)" <diazorozcoj@gmail.com>
|
|
6
6
|
Maintainer-email: "Jorge Alberto Díaz Orozco (Akiel)" <diazorozcoj@gmail.com>
|
|
@@ -16,6 +16,7 @@ Provides-Extra: test
|
|
|
16
16
|
Requires-Dist: black; extra == "test"
|
|
17
17
|
Requires-Dist: pytest; extra == "test"
|
|
18
18
|
Requires-Dist: pytest-cov; extra == "test"
|
|
19
|
+
Requires-Dist: pymongo; extra == "test"
|
|
19
20
|
Requires-Dist: requests; extra == "test"
|
|
20
21
|
Requires-Dist: semver; extra == "test"
|
|
21
22
|
Dynamic: license-file
|
|
@@ -41,6 +41,7 @@ rocketchat_API/APISections/invites.py
|
|
|
41
41
|
rocketchat_API/APISections/licenses.py
|
|
42
42
|
rocketchat_API/APISections/livechat.py
|
|
43
43
|
rocketchat_API/APISections/miscellaneous.py
|
|
44
|
+
rocketchat_API/APISections/moderation.py
|
|
44
45
|
rocketchat_API/APISections/permissions.py
|
|
45
46
|
rocketchat_API/APISections/roles.py
|
|
46
47
|
rocketchat_API/APISections/rooms.py
|
|
@@ -64,6 +65,7 @@ tests/test_integrations.py
|
|
|
64
65
|
tests/test_invites.py
|
|
65
66
|
tests/test_licenses.py
|
|
66
67
|
tests/test_livechat.py
|
|
68
|
+
tests/test_moderation.py
|
|
67
69
|
tests/test_paginated.py
|
|
68
70
|
tests/test_permissions.py
|
|
69
71
|
tests/test_roles.py
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
from datetime import datetime, timezone
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from pymongo import MongoClient
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@pytest.fixture
|
|
8
|
+
def test_banner():
|
|
9
|
+
"""There's no add_banner method in the public API so we need to add the test data manually to mongodb"""
|
|
10
|
+
client = MongoClient("mongodb://127.0.0.1:27017/rocketchat?directConnection=true")
|
|
11
|
+
db = client["rocketchat"]
|
|
12
|
+
banner = {
|
|
13
|
+
"_id": "test-banner-api",
|
|
14
|
+
"platform": ["web"],
|
|
15
|
+
"roles": ["user"],
|
|
16
|
+
"startAt": datetime(2020, 1, 1, tzinfo=timezone.utc),
|
|
17
|
+
"expireAt": datetime(2030, 1, 1, tzinfo=timezone.utc),
|
|
18
|
+
"createdBy": "system",
|
|
19
|
+
"createdAt": datetime(2026, 1, 1, tzinfo=timezone.utc),
|
|
20
|
+
"active": True,
|
|
21
|
+
"surface": "banner",
|
|
22
|
+
"view": {
|
|
23
|
+
"appId": "banner-core",
|
|
24
|
+
"viewId": "test-banner-api",
|
|
25
|
+
"type": "banner",
|
|
26
|
+
"blocks": [{"type": "section", "text": {"type": "mrkdwn", "text": "Test"}}],
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
db["rocketchat_banner"].insert_one(banner)
|
|
30
|
+
yield banner
|
|
31
|
+
db["rocketchat_banner"].delete_one({"_id": "test-banner-api"})
|
|
32
|
+
db["rocketchat_banner_dismiss"].delete_many({"bannerId": "test-banner-api"})
|
|
33
|
+
client.close()
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_banners(logged_rocket, test_banner):
|
|
37
|
+
result = logged_rocket.banners(platform="web")
|
|
38
|
+
assert "banners" in result
|
|
39
|
+
try:
|
|
40
|
+
banner = next(b for b in result["banners"] if b["_id"] == "test-banner-api")
|
|
41
|
+
except StopIteration:
|
|
42
|
+
pytest.fail("Test banner not found in banners list")
|
|
43
|
+
assert banner["platform"] == test_banner["platform"]
|
|
44
|
+
assert banner["surface"] == test_banner["surface"]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_banners_get_by_id(logged_rocket, test_banner):
|
|
48
|
+
result = logged_rocket.banners_get_by_id("test-banner-api", platform="web")
|
|
49
|
+
assert "banners" in result
|
|
50
|
+
banner = result["banners"][0]
|
|
51
|
+
assert banner["_id"] == "test-banner-api"
|
|
52
|
+
assert banner["platform"] == test_banner["platform"]
|
|
53
|
+
assert banner["roles"] == test_banner["roles"]
|
|
54
|
+
assert banner["surface"] == test_banner["surface"]
|
|
55
|
+
assert banner["view"]["appId"] == test_banner["view"]["appId"]
|
|
56
|
+
assert banner["view"]["blocks"] == test_banner["view"]["blocks"]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_banners_dismiss(logged_rocket, test_banner):
|
|
60
|
+
logged_rocket.banners_dismiss("test-banner-api")
|
|
61
|
+
remaining = logged_rocket.banners(platform="web").get("banners", [])
|
|
62
|
+
assert not any(b["_id"] == "test-banner-api" for b in remaining)
|
|
@@ -224,6 +224,109 @@ def test_chat_get_mentioned_messages(logged_rocket):
|
|
|
224
224
|
assert mentioned_messages[0].get("msg") == "hello @user1"
|
|
225
225
|
|
|
226
226
|
|
|
227
|
+
def test_chat_unfollow_message(logged_rocket):
|
|
228
|
+
message_id = (
|
|
229
|
+
logged_rocket.chat_post_message("hello", channel="GENERAL")
|
|
230
|
+
.get("message")
|
|
231
|
+
.get("_id")
|
|
232
|
+
)
|
|
233
|
+
logged_rocket.chat_follow_message(mid=message_id)
|
|
234
|
+
logged_rocket.chat_unfollow_message(mid=message_id)
|
|
235
|
+
followed_ids = [
|
|
236
|
+
m.get("_id")
|
|
237
|
+
for m in logged_rocket.chat_get_thread_messages(thread_msg_id=message_id)
|
|
238
|
+
]
|
|
239
|
+
assert message_id not in followed_ids
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def test_chat_get_deleted_messages(logged_rocket):
|
|
243
|
+
message_id = (
|
|
244
|
+
logged_rocket.chat_post_message("to be deleted", channel="GENERAL")
|
|
245
|
+
.get("message")
|
|
246
|
+
.get("_id")
|
|
247
|
+
)
|
|
248
|
+
logged_rocket.chat_delete(room_id="GENERAL", msg_id=message_id)
|
|
249
|
+
deleted = list(
|
|
250
|
+
logged_rocket.chat_get_deleted_messages(
|
|
251
|
+
room_id="GENERAL", since="2000-01-01T00:00:00.000Z"
|
|
252
|
+
)
|
|
253
|
+
)
|
|
254
|
+
assert any(m.get("_id") == message_id for m in deleted)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def test_chat_get_pinned_messages(logged_rocket):
|
|
258
|
+
message_id = (
|
|
259
|
+
logged_rocket.chat_post_message("pin me", channel="GENERAL")
|
|
260
|
+
.get("message")
|
|
261
|
+
.get("_id")
|
|
262
|
+
)
|
|
263
|
+
logged_rocket.chat_pin_message(message_id)
|
|
264
|
+
pinned = list(logged_rocket.chat_get_pinned_messages(room_id="GENERAL"))
|
|
265
|
+
assert len(pinned) > 0
|
|
266
|
+
for msg in pinned:
|
|
267
|
+
assert "_id" in msg
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def test_chat_ignore_user(logged_rocket):
|
|
271
|
+
logged_rocket.chat_ignore_user(rid="GENERAL", user_id="rocket.cat")
|
|
272
|
+
logged_rocket.chat_ignore_user(rid="GENERAL", user_id="rocket.cat", ignore=False)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def test_chat_sync_messages(logged_rocket):
|
|
276
|
+
logged_rocket.chat_post_message("sync test", channel="GENERAL")
|
|
277
|
+
result = logged_rocket.chat_sync_messages(
|
|
278
|
+
room_id="GENERAL", last_update="2000-01-01T00:00:00.000Z"
|
|
279
|
+
)
|
|
280
|
+
assert "result" in result
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def test_chat_get_threads_list(logged_rocket):
|
|
284
|
+
threads = list(logged_rocket.chat_get_threads_list(rid="GENERAL"))
|
|
285
|
+
for thread in threads:
|
|
286
|
+
assert "_id" in thread
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def test_chat_sync_thread_list(logged_rocket):
|
|
290
|
+
result = logged_rocket.chat_sync_thread_list(
|
|
291
|
+
rid="GENERAL", updated_since="2000-01-01T00:00:00.000Z"
|
|
292
|
+
)
|
|
293
|
+
assert "threads" in result
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def test_chat_sync_thread_messages(logged_rocket):
|
|
297
|
+
parent_id = (
|
|
298
|
+
logged_rocket.chat_post_message("thread parent", channel="GENERAL")
|
|
299
|
+
.get("message")
|
|
300
|
+
.get("_id")
|
|
301
|
+
)
|
|
302
|
+
logged_rocket.chat_post_message("reply", room_id="GENERAL", tmid=parent_id)
|
|
303
|
+
result = logged_rocket.chat_sync_thread_messages(
|
|
304
|
+
tmid=parent_id, updated_since="2000-01-01T00:00:00.000Z"
|
|
305
|
+
)
|
|
306
|
+
assert "messages" in result
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
def test_chat_get_discussions(logged_rocket):
|
|
310
|
+
discussion = logged_rocket.rooms_create_discussion(
|
|
311
|
+
prid="GENERAL", t_name="test discussion"
|
|
312
|
+
)
|
|
313
|
+
discussion_id = discussion.get("discussion").get("_id")
|
|
314
|
+
|
|
315
|
+
try:
|
|
316
|
+
discussions = list(logged_rocket.chat_get_discussions(room_id="GENERAL"))
|
|
317
|
+
assert len(discussions) > 0
|
|
318
|
+
assert any(d.get("drid") == discussion_id for d in discussions)
|
|
319
|
+
finally:
|
|
320
|
+
logged_rocket.channels_delete(room_id=discussion_id)
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def test_chat_get_url_preview(logged_rocket):
|
|
324
|
+
result = logged_rocket.chat_get_url_preview(
|
|
325
|
+
room_id="GENERAL", url="https://www.w3schools.com/tags/movie.mp4"
|
|
326
|
+
)
|
|
327
|
+
assert "urlPreview" in result
|
|
328
|
+
|
|
329
|
+
|
|
227
330
|
def test_chat_search(logged_rocket):
|
|
228
331
|
logged_rocket.chat_post_message("unique_search_term_test", channel="GENERAL")
|
|
229
332
|
|
|
@@ -158,3 +158,11 @@ def test_dm_list_everyone(logged_rocket):
|
|
|
158
158
|
iterated_dms = list(logged_rocket.dm_list_everyone())
|
|
159
159
|
for dm in iterated_dms:
|
|
160
160
|
assert "_id" in dm
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def test_dm_delete(logged_rocket, recipient_user):
|
|
164
|
+
dm_create = logged_rocket.dm_create(recipient_user)
|
|
165
|
+
room_id = dm_create.get("room").get("_id")
|
|
166
|
+
logged_rocket.dm_delete(room_id)
|
|
167
|
+
room_ids = [dm.get("_id") for dm in logged_rocket.dm_list()]
|
|
168
|
+
assert room_id not in room_ids
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from rocketchat_API.APIExceptions.RocketExceptions import (
|
|
4
|
+
RocketApiException,
|
|
5
|
+
RocketBadStatusCodeException,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.fixture
|
|
10
|
+
def invite(logged_rocket):
|
|
11
|
+
"""Create an invite for GENERAL, yield it, then clean up."""
|
|
12
|
+
result = logged_rocket.find_or_create_invite(rid="GENERAL", days=7, max_uses=5)
|
|
13
|
+
yield result
|
|
14
|
+
try:
|
|
15
|
+
logged_rocket.remove_invite(result["_id"])
|
|
16
|
+
except (RocketApiException, RocketBadStatusCodeException):
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_find_or_create_invite(invite):
|
|
21
|
+
assert invite.get("days") == 7
|
|
22
|
+
assert invite.get("maxUses") == 5
|
|
23
|
+
assert invite.get("rid") == "GENERAL"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_list_invites(logged_rocket, invite):
|
|
27
|
+
list_invites = logged_rocket.list_invites()
|
|
28
|
+
assert isinstance(list_invites, list)
|
|
29
|
+
assert any(i["_id"] == invite["_id"] for i in list_invites)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_remove_invite(logged_rocket, invite):
|
|
33
|
+
logged_rocket.remove_invite(invite["_id"])
|
|
34
|
+
list_invites = logged_rocket.list_invites()
|
|
35
|
+
assert not any(i["_id"] == invite["_id"] for i in list_invites)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_validate_invite_token(logged_rocket, invite):
|
|
39
|
+
result = logged_rocket.validate_invite_token(token=invite["_id"])
|
|
40
|
+
assert result.get("valid") is True
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_use_invite_token(logged_rocket, invite):
|
|
44
|
+
result = logged_rocket.use_invite_token(token=invite["_id"])
|
|
45
|
+
assert "room" in result
|
|
46
|
+
assert result["room"]["rid"] == "GENERAL"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_send_invitation_email(logged_rocket):
|
|
50
|
+
logged_rocket.send_invitation_email(emails=["test@example.com"])
|
|
@@ -125,3 +125,18 @@ def test_livechat_get_inquiries(logged_rocket, livechat_inquiry):
|
|
|
125
125
|
def test_livechat_get_inquiries_non_existent_room(logged_rocket):
|
|
126
126
|
inquiry_not_found = logged_rocket.livechat_inquiries_get_one(room_id="nonexistent")
|
|
127
127
|
assert inquiry_not_found.get("inquiry") is None or "success" in inquiry_not_found
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def test_livechat_get_appearance(logged_rocket):
|
|
131
|
+
result = logged_rocket.livechat_get_appearance()
|
|
132
|
+
assert "appearance" in result
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def test_livechat_set_appearance(logged_rocket):
|
|
136
|
+
appearance = logged_rocket.livechat_get_appearance().get("appearance", [])
|
|
137
|
+
assert len(appearance) > 0, "Expected at least one appearance setting"
|
|
138
|
+
|
|
139
|
+
setting = appearance[0]
|
|
140
|
+
logged_rocket.livechat_set_appearance(
|
|
141
|
+
[{"_id": setting["_id"], "value": setting["value"]}]
|
|
142
|
+
)
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from rocketchat_API.APIExceptions.RocketExceptions import (
|
|
4
|
+
RocketApiException,
|
|
5
|
+
RocketBadStatusCodeException,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@pytest.fixture
|
|
10
|
+
def reported_message(logged_rocket):
|
|
11
|
+
"""Post a message in GENERAL, report it, yield ids, then clean up."""
|
|
12
|
+
msg = logged_rocket.chat_post_message("message to report", channel="GENERAL").get(
|
|
13
|
+
"message"
|
|
14
|
+
)
|
|
15
|
+
msg_id = msg["_id"]
|
|
16
|
+
user_id = msg["u"]["_id"]
|
|
17
|
+
logged_rocket.chat_report_message(
|
|
18
|
+
message_id=msg_id, description="test moderation report"
|
|
19
|
+
)
|
|
20
|
+
reports = list(logged_rocket.moderation_reports(msg_id=msg_id))
|
|
21
|
+
report_id = reports[0]["_id"] if reports else None
|
|
22
|
+
yield {"msg_id": msg_id, "user_id": user_id, "report_id": report_id}
|
|
23
|
+
try:
|
|
24
|
+
logged_rocket.moderation_dismiss_reports(msg_id=msg_id, reason="cleanup")
|
|
25
|
+
except (RocketApiException, RocketBadStatusCodeException):
|
|
26
|
+
pass
|
|
27
|
+
try:
|
|
28
|
+
logged_rocket.chat_delete(room_id="GENERAL", msg_id=msg_id)
|
|
29
|
+
except (RocketApiException, RocketBadStatusCodeException):
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@pytest.fixture
|
|
34
|
+
def reported_user(logged_rocket):
|
|
35
|
+
"""Report the logged-in user (self-report), yield user_id, then clean up."""
|
|
36
|
+
user_id = logged_rocket.me().get("_id")
|
|
37
|
+
logged_rocket.moderation_report_user(
|
|
38
|
+
user_id=user_id, description="test user report"
|
|
39
|
+
)
|
|
40
|
+
yield user_id
|
|
41
|
+
logged_rocket.moderation_dismiss_user_reports(user_id=user_id, reason="cleanup")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def test_moderation_reports(logged_rocket, reported_message):
|
|
45
|
+
reports = list(logged_rocket.moderation_reports(msg_id=reported_message["msg_id"]))
|
|
46
|
+
assert len(reports) > 0
|
|
47
|
+
report = reports[0]
|
|
48
|
+
assert report["_id"] == reported_message["report_id"]
|
|
49
|
+
assert "description" in report
|
|
50
|
+
assert "reportedBy" in report
|
|
51
|
+
assert "room" in report
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_moderation_report_info(logged_rocket, reported_message):
|
|
55
|
+
result = logged_rocket.moderation_report_info(
|
|
56
|
+
report_id=reported_message["report_id"]
|
|
57
|
+
)
|
|
58
|
+
assert result["report"]["_id"] == reported_message["report_id"]
|
|
59
|
+
assert result["report"]["room"]["_id"] == "GENERAL"
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_moderation_reports_by_users(logged_rocket, reported_message):
|
|
63
|
+
reports = list(logged_rocket.moderation_reports_by_users())
|
|
64
|
+
assert len(reports) > 0
|
|
65
|
+
assert any(r["userId"] == reported_message["user_id"] for r in reports)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def test_moderation_user_reported_messages(logged_rocket, reported_message):
|
|
69
|
+
result = logged_rocket.moderation_user_reported_messages(
|
|
70
|
+
user_id=reported_message["user_id"]
|
|
71
|
+
)
|
|
72
|
+
assert "messages" in result
|
|
73
|
+
assert len(result["messages"]) > 0
|
|
74
|
+
assert result["user"]["_id"] == reported_message["user_id"]
|
|
75
|
+
assert any(
|
|
76
|
+
m["message"]["_id"] == reported_message["msg_id"] for m in result["messages"]
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_moderation_report_user(logged_rocket, reported_user):
|
|
81
|
+
reports = list(logged_rocket.moderation_user_reports())
|
|
82
|
+
assert len(reports) > 0
|
|
83
|
+
assert any(r["reportedUser"]["_id"] == reported_user for r in reports)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_moderation_user_reports(logged_rocket, reported_user):
|
|
87
|
+
reports = list(logged_rocket.moderation_user_reports())
|
|
88
|
+
assert len(reports) > 0
|
|
89
|
+
report = reports[0]
|
|
90
|
+
assert "reportedUser" in report
|
|
91
|
+
assert "ts" in report
|
|
92
|
+
assert "count" in report
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def test_moderation_user_reports_by_user_id(logged_rocket, reported_user):
|
|
96
|
+
result = logged_rocket.moderation_user_reports_by_user_id(user_id=reported_user)
|
|
97
|
+
assert result["user"]["_id"] == reported_user
|
|
98
|
+
assert "reports" in result
|
|
99
|
+
assert len(result["reports"]) > 0
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def test_moderation_dismiss_reports_by_msg(logged_rocket, reported_message):
|
|
103
|
+
logged_rocket.moderation_dismiss_reports(msg_id=reported_message["msg_id"])
|
|
104
|
+
reports = list(logged_rocket.moderation_reports(msg_id=reported_message["msg_id"]))
|
|
105
|
+
assert len(reports) == 0
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_moderation_dismiss_reports_by_user(logged_rocket, reported_message):
|
|
109
|
+
logged_rocket.moderation_dismiss_reports(user_id=reported_message["user_id"])
|
|
110
|
+
reports = list(logged_rocket.moderation_reports_by_users())
|
|
111
|
+
assert not any(r["userId"] == reported_message["user_id"] for r in reports)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def test_moderation_dismiss_user_reports(logged_rocket, reported_user):
|
|
115
|
+
logged_rocket.moderation_dismiss_user_reports(user_id=reported_user)
|
|
116
|
+
reports = list(logged_rocket.moderation_user_reports())
|
|
117
|
+
assert not any(r["reportedUser"]["_id"] == reported_user for r in reports)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def test_moderation_user_delete_reported_messages(logged_rocket):
|
|
121
|
+
msg = logged_rocket.chat_post_message(
|
|
122
|
+
"message to delete via moderation", channel="GENERAL"
|
|
123
|
+
).get("message")
|
|
124
|
+
msg_id = msg["_id"]
|
|
125
|
+
user_id = msg["u"]["_id"]
|
|
126
|
+
logged_rocket.chat_report_message(
|
|
127
|
+
message_id=msg_id, description="report before delete"
|
|
128
|
+
)
|
|
129
|
+
logged_rocket.moderation_user_delete_reported_messages(user_id=user_id)
|
|
130
|
+
deleted = list(
|
|
131
|
+
logged_rocket.chat_get_deleted_messages(
|
|
132
|
+
room_id="GENERAL", since="2000-01-01T00:00:00.000Z"
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
assert any(m["_id"] == msg_id for m in deleted)
|
|
@@ -50,3 +50,21 @@ def test_roles_get_users_in_role(logged_rocket):
|
|
|
50
50
|
def test_roles_sync(logged_rocket):
|
|
51
51
|
roles_sync = logged_rocket.roles_sync(updated_since="2017-11-25T15:08:17.248Z")
|
|
52
52
|
assert len(roles_sync.get("roles")) > 0
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_roles_delete(logged_rocket, skip_if_no_license):
|
|
56
|
+
name = str(uuid.uuid1())
|
|
57
|
+
role_id = logged_rocket.roles_create(name=name).get("role").get("_id")
|
|
58
|
+
logged_rocket.roles_delete(role_id=role_id)
|
|
59
|
+
roles = logged_rocket.roles_list().get("roles", [])
|
|
60
|
+
assert not any(r["_id"] == role_id for r in roles)
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def test_roles_get_users_in_public_roles(logged_rocket):
|
|
64
|
+
result = logged_rocket.roles_get_users_in_public_roles()
|
|
65
|
+
assert "users" in result
|
|
66
|
+
assert len(result["users"]) > 0
|
|
67
|
+
user = result["users"][0]
|
|
68
|
+
assert "_id" in user
|
|
69
|
+
assert "username" in user
|
|
70
|
+
assert "roles" in user
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
from rocketchat_API.APISections.base import RocketChatBase
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class RocketChatBanners(RocketChatBase):
|
|
5
|
-
def banners(self, platform, **kwargs):
|
|
6
|
-
"""Gets the banner to be shown to the authenticated user"""
|
|
7
|
-
return self.call_api_get(
|
|
8
|
-
"banners",
|
|
9
|
-
platform=platform,
|
|
10
|
-
kwargs=kwargs,
|
|
11
|
-
)
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
from rocketchat_API.APISections.base import RocketChatBase
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class RocketChatInvites(RocketChatBase):
|
|
5
|
-
def find_or_create_invite(self, rid, days, max_uses):
|
|
6
|
-
"""
|
|
7
|
-
Creates or return an existing invite with the specified parameters.
|
|
8
|
-
Requires the create-invite-links permission
|
|
9
|
-
"""
|
|
10
|
-
return self.call_api_post(
|
|
11
|
-
"findOrCreateInvite", rid=rid, days=days, maxUses=max_uses
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
def list_invites(self, **kwargs):
|
|
15
|
-
"""Lists all of the invites on the server. Requires the create-invite-links permission."""
|
|
16
|
-
return self.call_api_get("listInvites", kwargs=kwargs)
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
def test_find_or_create_invite(logged_rocket):
|
|
2
|
-
rid = "GENERAL"
|
|
3
|
-
find_or_create_invite = logged_rocket.find_or_create_invite(
|
|
4
|
-
rid=rid, days=7, max_uses=5
|
|
5
|
-
)
|
|
6
|
-
assert find_or_create_invite.get("days") == 7
|
|
7
|
-
assert find_or_create_invite.get("maxUses") == 5
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def test_list_invites(logged_rocket):
|
|
11
|
-
list_invites = logged_rocket.list_invites()
|
|
12
|
-
assert isinstance(list_invites, list)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APIExceptions/RocketExceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{rocketchat_api-3.2.0 → rocketchat_api-3.4.0}/rocketchat_API/APISections/users_engagement.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|