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', },