From 425fbaa10f91279c56ec3d604742909a2a6c877f Mon Sep 17 00:00:00 2001 From: JiangYongKang Date: Mon, 21 Sep 2020 17:17:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=92=A4=E5=9B=9E=E5=8D=95?= =?UTF-8?q?=E8=81=8A=E6=B6=88=E6=81=AF=E7=9A=84API=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 2 +- README.md | 7 +++++++ lib/tim_sdk/api.rb | 13 +++++++++++++ lib/tim_sdk/version.rb | 2 +- spec/tim_sdk_spec.rb | 6 ++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2cbef01..0a1dd05 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - tim_sdk (0.1.4) + tim_sdk (0.1.5) GEM remote: https://rubygems.org/ diff --git a/README.md b/README.md index 57a955d..823111e 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ - [x] 单聊消息 - [x] 导入单聊消息 + - [x] 撤回单聊消息 - [x] 资料管理 - [x] 设置资料 @@ -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', [ diff --git a/lib/tim_sdk/api.rb b/lib/tim_sdk/api.rb index beb074f..bb7f9cb 100644 --- a/lib/tim_sdk/api.rb +++ b/lib/tim_sdk/api.rb @@ -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| diff --git a/lib/tim_sdk/version.rb b/lib/tim_sdk/version.rb index 0f98352..3845146 100644 --- a/lib/tim_sdk/version.rb +++ b/lib/tim_sdk/version.rb @@ -1,3 +1,3 @@ module TimSdk - VERSION = '0.1.4' + VERSION = '0.1.5' end diff --git a/spec/tim_sdk_spec.rb b/spec/tim_sdk_spec.rb index c5c4bb2..85893cf 100644 --- a/spec/tim_sdk_spec.rb +++ b/spec/tim_sdk_spec.rb @@ -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', },