Skip to content

Commit

Permalink
添加撤回单聊消息的API接口
Browse files Browse the repository at this point in the history
  • Loading branch information
JiangYongKang committed Sep 21, 2020
1 parent 960fcfa commit 425fbaa
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
tim_sdk (0.1.4)
tim_sdk (0.1.5)

GEM
remote: https://rubygems.org/
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

- [x] 单聊消息
- [x] 导入单聊消息
- [x] 撤回单聊消息

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

撤回单聊消息
```ruby
TimSdk::Api.invoke_admin_msg_withdraw('foo', 'bar', '1927400049_48863998_1599827627')
#=> {:ActionStatus=>"OK", :ErrorInfo=>"", :ErrorCode=>0}
```

设置资料
```ruby
TimSdk::Api.invoke_portrait_set('foo', [
Expand Down
13 changes: 13 additions & 0 deletions lib/tim_sdk/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@ def self.invoke_import_msg(from_account, to_account, msg_random, msg_timestamp,
JSON.parse(response.body, symbolize_names: true) if response.success?
end

# 撤回单聊消息
def self.invoke_admin_msg_withdraw(from_account, to_account, msg_key)
response = connection.post('/v4/openim/admin_msgwithdraw') do |request|
request.body = {
:From_Account => from_account.to_s,
:To_Account => to_account.to_s,
:MsgKey => msg_key.to_s,
}.to_json
end
raise TimServerError, "Response Status: #{response.status}" unless response.success?
JSON.parse(response.body, symbolize_names: true) if response.success?
end

# 设置资料
def self.invoke_portrait_set(account, items)
response = connection.post('/v4/profile/portrait_set') do |request|
Expand Down
2 changes: 1 addition & 1 deletion lib/tim_sdk/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TimSdk
VERSION = '0.1.4'
VERSION = '0.1.5'
end
6 changes: 6 additions & 0 deletions spec/tim_sdk_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
expect(response[:ErrorCode]).to eq(0)
end

it 'should be withdraw message successfully' do
response = TimSdk::Api.invoke_admin_msg_withdraw('foo', 'bar', '1927400049_48863998_1599827627')
expect(response[:ActionStatus]).to eq('OK')
expect(response[:ErrorCode]).to eq(0)
end

it 'should be set account portrait successfully' do
response = TimSdk::Api.invoke_portrait_set('foo', [
{ tag: 'Tag_Profile_IM_Nick', value: 'vincent', },
Expand Down

0 comments on commit 425fbaa

Please sign in to comment.