Skip to content

Commit a4525f7

Browse files
committed
广播消息、撤回消息去掉disabled_push属性
1 parent d1fcdb4 commit a4525f7

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

rongcloud/message.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def set_user_info(self, user_id, name, icon, extra=None):
1515
self._user_info = self._render(param_dict, format_str)
1616

1717
def broadcast(self, from_user_id, object_name, content, push_content=None, push_data=None, os=None,
18-
content_available=0, disable_push=False, push_ext=None):
18+
content_available=0, push_ext=None):
1919
"""
2020
单个应用每小时只能发送 2 次,每天最多发送 3 次。如需要调整发送频率,可联系销售,电话 13161856839。
2121
:param from_user_id: 发送人用户 Id。(必传)
@@ -35,7 +35,6 @@ def broadcast(self, from_user_id, object_name, content, push_content=None, push_
3535
:param content_available: 针对 iOS 平台,对 SDK 处于后台暂停状态时为静默推送,是 iOS7 之后推出的一种推送方式。
3636
允许应用在收到通知后在后台运行一段代码,且能够马上执行,查看详细。
3737
1 表示为开启,0 表示为关闭,默认为 0。(非必传)
38-
:param disable_push 是否为静默消息,默认为 false,设为 true 时终端用户离线情况下不会收到通知提醒。暂不支持海外数据中心(非必传)
3938
:param push_ext 推送通知属性设置,详细查看 pushExt 结构说明,pushExt 为 JSON 结构请求时需要做转义处理。disablePush 为 true 时此属性无效。暂不支持海外数据中心(非必传)
4039
:return: 请求返回结果,code 返回码,200 为正常。如:{"code":200}
4140
"""
@@ -49,7 +48,6 @@ def broadcast(self, from_user_id, object_name, content, push_content=None, push_
4948
'{% if push_data is not none %}&pushData={{ push_data }}{% endif %}' \
5049
'{% if os is not none %}&os={{ os }}{% endif %}' \
5150
'{% if content_available != 0 %}&contentAvailable={{ content_available }}{% endif %}' \
52-
'{% if disable_push != False %}&disablePush={{ disable_push }}{% endif %}' \
5351
'{% if push_ext is not none %}&pushExt={{ push_ext }}{% endif %}'
5452
try:
5553
self._check_param(from_user_id, str, '1~64')
@@ -59,7 +57,6 @@ def broadcast(self, from_user_id, object_name, content, push_content=None, push_
5957
self._check_param(push_data, str)
6058
self._check_param(os, str)
6159
self._check_param(content_available, int, '0~1')
62-
self._check_param(disable_push, bool)
6360
self._check_param(push_ext, str)
6461
return self._http_post(url, self._render(param_dict, format_str))
6562
except ParamException as e:
@@ -159,7 +156,7 @@ def send(self, from_user_id, to_user_ids, object_name, content, push_content=Non
159156
except ParamException as e:
160157
return json.loads(str(e))
161158

162-
def recall(self, from_user_id, target_id, uid, sent_time, is_admin=0, is_delete=0, extra=None,disable_push=False):
159+
def recall(self, from_user_id, target_id, uid, sent_time, is_admin=0, is_delete=0, extra=None):
163160
"""
164161
撤回已发送的单聊消息,撤回时间无限制,只允许撤回用户自己发送的消息。
165162
:param from_user_id: 消息发送人用户 Id。(必传)
@@ -171,7 +168,6 @@ def recall(self, from_user_id, target_id, uid, sent_time, is_admin=0, is_delete=
171168
:param is_delete: 是否删除消息,默认为 0 撤回该条消息同时,用户端将该条消息删除并替换为一条小灰条撤回提示消息;
172169
为 1 时,该条消息删除后,不替换为小灰条提示消息。(非必传)
173170
:param extra: 扩展信息,可以放置任意的数据内容。(非必传)
174-
:param disable_push 是否为静默消息,默认为 false,设为 true 时终端用户离线情况下不会收到通知提醒。暂不支持海外数据中心(非必传)
175171
:return: 返回码,200 为正常。如:{"code":200}
176172
"""
177173
param_dict = locals().copy()
@@ -183,8 +179,7 @@ def recall(self, from_user_id, target_id, uid, sent_time, is_admin=0, is_delete=
183179
'&sentTime={{ sent_time }}' \
184180
'{% if is_admin is not none %}&isAdmin={{ is_admin }}{% endif %}' \
185181
'{% if is_delete is not none %}&isDelete={{ is_delete }}{% endif %}' \
186-
'{% if extra is not none %}&extra={{ extra }}{% endif %}' \
187-
'{% if disable_push != False %}&disablePush={{ disable_push }}{% endif %}'
182+
'{% if extra is not none %}&extra={{ extra }}{% endif %}'
188183
try:
189184
self._check_param(from_user_id, str, '1~64')
190185
self._check_param(target_id, str, '1~64')
@@ -193,7 +188,6 @@ def recall(self, from_user_id, target_id, uid, sent_time, is_admin=0, is_delete=
193188
self._check_param(is_admin, int)
194189
self._check_param(is_delete, int)
195190
self._check_param(extra, str)
196-
self._check_param(disable_push, bool)
197191
return self._http_post(url, self._render(param_dict, format_str))
198192
except ParamException as e:
199193
return json.loads(str(e))
@@ -444,7 +438,7 @@ def send_direction(self, from_user_id, to_group_id, to_user_ids, object_name, co
444438
except ParamException as e:
445439
return json.loads(str(e))
446440

447-
def recall(self, from_user_id, group_id, uid, sent_time, is_admin=None, is_delete=None, extra=None,disable_push=False):
441+
def recall(self, from_user_id, group_id, uid, sent_time, is_admin=None, is_delete=None, extra=None):
448442
"""
449443
撤回已发送的群聊消息,撤回时间无限制,只允许撤回用户自己发送的消息。
450444
:param from_user_id: 消息发送人用户 Id。(必传)
@@ -456,7 +450,6 @@ def recall(self, from_user_id, group_id, uid, sent_time, is_admin=None, is_delet
456450
:param is_delete: 是否删除消息,默认为 0 撤回该条消息同时,用户端将该条消息删除并替换为一条小灰条撤回提示消息;
457451
为 1 时,该条消息删除后,不替换为小灰条提示消息。(非必传)
458452
:param extra: 扩展信息,可以放置任意的数据内容。(非必传)
459-
:param disable_push 是否为静默消息,默认为 false,设为 true 时终端用户离线情况下不会收到通知提醒。暂不支持海外数据中心(非必传)
460453
:return: 请求返回结果,code 返回码,200 为正常。如:{"code":200}
461454
"""
462455
param_dict = locals().copy()
@@ -468,8 +461,7 @@ def recall(self, from_user_id, group_id, uid, sent_time, is_admin=None, is_delet
468461
'&sentTime={{ sent_time }}' \
469462
'{% if is_admin is not none %}&isAdmin={{ is_admin }}{% endif %}' \
470463
'{% if is_delete is not none %}&isDelete={{ is_delete }}{% endif %}' \
471-
'{% if extra is not none %}&extra={{ extra }}{% endif %}' \
472-
'{% if disable_push != False %}&disablePush={{ disable_push }}{% endif %}'
464+
'{% if extra is not none %}&extra={{ extra }}{% endif %}'
473465
try:
474466
self._check_param(from_user_id, str, '1~64')
475467
self._check_param(group_id, str, '1~64')
@@ -478,7 +470,6 @@ def recall(self, from_user_id, group_id, uid, sent_time, is_admin=None, is_delet
478470
self._check_param(is_admin, int)
479471
self._check_param(is_delete, int)
480472
self._check_param(extra, str)
481-
self._check_param(disable_push, bool)
482473
return self._http_post(url, self._render(param_dict, format_str))
483474
except ParamException as e:
484475
return json.loads(str(e))

unit_test/message_unittest.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ def test_broadcast(self):
1111
from_user_id = 'AAA'
1212
object_name = 'RC:TxtMsg'
1313
content = {'content': 'hello', 'extra': 'helloExtra'}
14-
disable_push = True
1514
push_ext = "{\"title\":\"youhaveanewmessage.\",\"forceShowPushContent\":0,\"pushConfigs\":[{\"HW\":{\"channelId\":\"hw-123\"}},{\"MI\":{\"channelId\":\"mi-123\"}},{\"OPPO\":{\"channelId\":\"oppo-123\"}},{\"VIVO\":{\"classification\":\"0\"}},{\"APNs\":{\"thread-id\":\"123\",\"apns-collapse-id\":\"123456\"}}]}"
16-
# rep = rc.get_message().broadcast(from_user_id, object_name, content)
17-
# rep = rc.get_message().broadcast(from_user_id, object_name, content, disable_push=disable_push)
18-
rep = rc.get_message().broadcast(from_user_id, object_name, content, disable_push=disable_push, push_ext=push_ext)
15+
rep = rc.get_message().broadcast(from_user_id, object_name, content)
16+
# rep = rc.get_message().broadcast(from_user_id, object_name, content, push_ext=push_ext)
1917
self.assertEqual(rep['code'], 200, rep)
2018

2119
def test_private_send(self):
@@ -36,9 +34,7 @@ def test_private_recall(self):
3634
target_id = 'BBB'
3735
uid = '5FGT-7VA9-G4DD-4V5P'
3836
sent_time = 1507778882124
39-
disable_push = True
40-
# rep = rc.get_message().get_private().recall(from_user_id, target_id, uid, sent_time)
41-
rep = rc.get_message().get_private().recall(from_user_id, target_id, uid, sent_time, disable_push=disable_push)
37+
rep = rc.get_message().get_private().recall(from_user_id, target_id, uid, sent_time)
4238
self.assertEqual(rep['code'], 200, rep)
4339

4440
def test_private_send_template(self):
@@ -97,9 +93,7 @@ def test_group_recall(self):
9793
to_group_id = 'Group_1'
9894
uid = '5FGT-7VA9-G4DD-4V5P'
9995
sent_time = 1507778882124
100-
disable_push = True
101-
# rep = rc.get_message().get_group().recall(from_user_id, to_group_id, uid, sent_time)
102-
rep = rc.get_message().get_group().recall(from_user_id, to_group_id, uid, sent_time, disable_push=disable_push)
96+
rep = rc.get_message().get_group().recall(from_user_id, to_group_id, uid, sent_time)
10397
self.assertEqual(rep['code'], 200, rep)
10498

10599
def test_chatroom_send(self):

0 commit comments

Comments
 (0)