Skip to content

Commit

Permalink
integrate keepalive chatroom apis
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin91 committed Mar 10, 2018
1 parent 1de42b5 commit bcc7aa3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/rong_cloud/services/chatroom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ def unblock_chatroom_user(chatroom_id, user_id)
def blocked_chatroom_users(chatroom_id)
request("/chatroom/user/block/list", chatroomId: chatroom_id)
end

# http://www.rongcloud.cn/docs/server.html#chatroom_keepalive_add
def add_keepalive_chatroom(chatroom_id)
request("/chatroom/keepalive/add", chatroomId: chatroom_id)
end

# http://www.rongcloud.cn/docs/server.html#chatroom_keepalive_remove
def remove_keepalive_chatroom(chatroom_id)
request("/chatroom/keepalive/remove", chatroomId: chatroom_id)
end

# http://www.rongcloud.cn/docs/server.html#chatroom_keepalive_query
def keepalive_chatrooms
request("/chatroom/keepalive/query")
end
end
end
end
27 changes: 27 additions & 0 deletions test/rong_cloud/services/chatroom_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,33 @@ def test_block_chatroom_user_flow
refute response["users"].detect{ |u| u["userId"] == "user5" }
end

def test_add_keepalive_chatroom
error = assert_raises RongCloud::RequestError do
@service.add_keepalive_chatroom(10011)
end

assert_equal "聊天室保活服务未开通。", error.message
assert_equal 1009, error.business_code
end

def test_remove_keepalive_chatroom
error = assert_raises RongCloud::RequestError do
@service.remove_keepalive_chatroom(10011)
end

assert_equal "聊天室保活服务未开通。", error.message
assert_equal 1009, error.business_code
end

def test_keepalive_chatrooms
error = assert_raises RongCloud::RequestError do
@service.keepalive_chatrooms
end

assert_equal "聊天室保活服务未开通。", error.message
assert_equal 1009, error.business_code
end

private
def create_chatrooms(chatrooms = { 10000001 => "super chatroom"})
@service.create_chatroom(chatrooms)
Expand Down

0 comments on commit bcc7aa3

Please sign in to comment.