Skip to content

Commit 425fbaa

Browse files
committed
添加撤回单聊消息的API接口
1 parent 960fcfa commit 425fbaa

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
tim_sdk (0.1.4)
4+
tim_sdk (0.1.5)
55

66
GEM
77
remote: https://rubygems.org/

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
- [x] 单聊消息
1717
- [x] 导入单聊消息
18+
- [x] 撤回单聊消息
1819

1920
- [x] 资料管理
2021
- [x] 设置资料
@@ -116,6 +117,12 @@ TimSdk::Api.invoke_import_msg(
116117
#=> {:ActionStatus=>"OK", :ErrorInfo=>"", :ErrorCode=>0}
117118
```
118119

120+
撤回单聊消息
121+
```ruby
122+
TimSdk::Api.invoke_admin_msg_withdraw('foo', 'bar', '1927400049_48863998_1599827627')
123+
#=> {:ActionStatus=>"OK", :ErrorInfo=>"", :ErrorCode=>0}
124+
```
125+
119126
设置资料
120127
```ruby
121128
TimSdk::Api.invoke_portrait_set('foo', [

lib/tim_sdk/api.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ def self.invoke_import_msg(from_account, to_account, msg_random, msg_timestamp,
108108
JSON.parse(response.body, symbolize_names: true) if response.success?
109109
end
110110

111+
# 撤回单聊消息
112+
def self.invoke_admin_msg_withdraw(from_account, to_account, msg_key)
113+
response = connection.post('/v4/openim/admin_msgwithdraw') do |request|
114+
request.body = {
115+
:From_Account => from_account.to_s,
116+
:To_Account => to_account.to_s,
117+
:MsgKey => msg_key.to_s,
118+
}.to_json
119+
end
120+
raise TimServerError, "Response Status: #{response.status}" unless response.success?
121+
JSON.parse(response.body, symbolize_names: true) if response.success?
122+
end
123+
111124
# 设置资料
112125
def self.invoke_portrait_set(account, items)
113126
response = connection.post('/v4/profile/portrait_set') do |request|

lib/tim_sdk/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module TimSdk
2-
VERSION = '0.1.4'
2+
VERSION = '0.1.5'
33
end

spec/tim_sdk_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@
7878
expect(response[:ErrorCode]).to eq(0)
7979
end
8080

81+
it 'should be withdraw message successfully' do
82+
response = TimSdk::Api.invoke_admin_msg_withdraw('foo', 'bar', '1927400049_48863998_1599827627')
83+
expect(response[:ActionStatus]).to eq('OK')
84+
expect(response[:ErrorCode]).to eq(0)
85+
end
86+
8187
it 'should be set account portrait successfully' do
8288
response = TimSdk::Api.invoke_portrait_set('foo', [
8389
{ tag: 'Tag_Profile_IM_Nick', value: 'vincent', },

0 commit comments

Comments
 (0)