feat(chatroom): impl delete chatroom members
This commit is contained in:
parent
da3357cb3b
commit
51312d1bbe
@ -2,6 +2,7 @@
|
||||
|
||||
#include "chatroom_manager.h"
|
||||
#include "log.hpp"
|
||||
#include "offsets.h"
|
||||
#include "pb_util.h"
|
||||
#include "rpc_helper.h"
|
||||
#include "util.h"
|
||||
@ -11,14 +12,15 @@ extern QWORD g_WeChatWinDllAddr;
|
||||
|
||||
namespace chatroom
|
||||
{
|
||||
namespace OsRoom = Offsets::Chatroom;
|
||||
|
||||
#define OS_GET_CHATROOM_MGR 0x1B83BD0
|
||||
#define OS_ADD_MEMBERS 0x2155100
|
||||
#define OS_DELETE_MEMBERS 0x2155740
|
||||
#define OS_INVITE_MEMBERS 0x2154AE0
|
||||
|
||||
using get_chatroom_mgr_t = QWORD (*)();
|
||||
using add_member_to_chatroom_t = QWORD (*)(QWORD, QWORD, QWORD, QWORD);
|
||||
using del_member_from_chatroom_t = QWORD (*)(QWORD, QWORD, QWORD);
|
||||
using del_member_from_chatroom_t = QWORD (*)(QWORD, QWORD, WxString *);
|
||||
using invite_member_to_chatroom_t = QWORD (*)(QWORD, QWORD, QWORD, QWORD);
|
||||
|
||||
static vector<WxString> parse_wxids(const string &wxids)
|
||||
@ -53,21 +55,15 @@ int add_chatroom_member(const string &roomid, const string &wxids)
|
||||
|
||||
int del_chatroom_member(const string &roomid, const string &wxids)
|
||||
{
|
||||
if (roomid.empty() || wxids.empty()) {
|
||||
LOG_ERROR("Empty roomid or wxids.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
get_chatroom_mgr_t get_chatroom_mgr
|
||||
= reinterpret_cast<get_chatroom_mgr_t>(g_WeChatWinDllAddr + OS_GET_CHATROOM_MGR);
|
||||
get_chatroom_mgr_t get_chatroom_mgr = reinterpret_cast<get_chatroom_mgr_t>(g_WeChatWinDllAddr + OsRoom::MGR);
|
||||
del_member_from_chatroom_t del_members
|
||||
= reinterpret_cast<del_member_from_chatroom_t>(g_WeChatWinDllAddr + OS_DELETE_MEMBERS);
|
||||
= reinterpret_cast<del_member_from_chatroom_t>(g_WeChatWinDllAddr + OsRoom::DEL);
|
||||
|
||||
vector<WxString> wx_members = parse_wxids(wxids);
|
||||
auto wx_roomid = util::new_wx_string(roomid);
|
||||
QWORD p_members = reinterpret_cast<QWORD>(&wx_members.front());
|
||||
WxString *wx_roomid = util::CreateWxString(roomid);
|
||||
auto wx_members = util::parse_wxids(wxids).wxWxids;
|
||||
QWORD p_members = reinterpret_cast<QWORD>(&wx_members);
|
||||
|
||||
return static_cast<int>(del_members(get_chatroom_mgr(), p_members, reinterpret_cast<QWORD>(wx_roomid.get())));
|
||||
return static_cast<int>(del_members(get_chatroom_mgr(), p_members, wx_roomid));
|
||||
}
|
||||
|
||||
int invite_chatroom_member(const string &roomid, const string &wxids)
|
||||
@ -98,10 +94,17 @@ bool rpc_add_chatroom_member(const MemberMgmt &m, uint8_t *out, size_t *len)
|
||||
|
||||
bool rpc_delete_chatroom_member(const MemberMgmt &m, uint8_t *out, size_t *len)
|
||||
{
|
||||
const std::string wxids = m.wxids;
|
||||
const std::string roomid = m.roomid;
|
||||
return fill_response<Functions_FUNC_DEL_ROOM_MEMBERS>(
|
||||
out, len, [&](Response &rsp) { rsp.msg.status = del_chatroom_member(roomid, wxids); });
|
||||
int status = -1;
|
||||
if (m.wxids && m.roomid) {
|
||||
const std::string wxids = m.wxids;
|
||||
const std::string roomid = m.roomid;
|
||||
|
||||
status = del_chatroom_member(roomid, wxids);
|
||||
} else {
|
||||
LOG_ERROR("wxid 和 roomid 不能为空");
|
||||
}
|
||||
|
||||
return fill_response<Functions_FUNC_DEL_ROOM_MEMBERS>(out, len, [&](Response &rsp) { rsp.msg.status = status; });
|
||||
}
|
||||
|
||||
bool rpc_invite_chatroom_member(const MemberMgmt &m, uint8_t *out, size_t *len)
|
||||
|
@ -267,7 +267,7 @@ const std::unordered_map<Functions, RpcServer::FunctionHandler> RpcServer::rpcFu
|
||||
{ Functions_FUNC_DECRYPT_IMAGE, [](const Request &r, uint8_t *out, size_t *len) { return misc::rpc_decrypt_image(r.msg.dec, out, len); } },
|
||||
{ Functions_FUNC_EXEC_OCR, [](const Request &r, uint8_t *out, size_t *len) { return misc::rpc_get_ocr_result(r.msg.str, out, len); } },
|
||||
// { Functions_FUNC_ADD_ROOM_MEMBERS, [](const Request &r, uint8_t *out, size_t *len) { return chatroom::rpc_add_chatroom_member(r.msg.m, out, len); } },
|
||||
// { Functions_FUNC_DEL_ROOM_MEMBERS, [](const Request &r, uint8_t *out, size_t *len) { return chatroom::rpc_delete_chatroom_member(r.msg.m, out, len); } },
|
||||
{ Functions_FUNC_DEL_ROOM_MEMBERS, [](const Request &r, uint8_t *out, size_t *len) { return chatroom::rpc_delete_chatroom_member(r.msg.m, out, len); } },
|
||||
// { Functions_FUNC_INV_ROOM_MEMBERS, [](const Request &r, uint8_t *out, size_t *len) { return chatroom::rpc_invite_chatroom_member(r.msg.m, out, len); } },
|
||||
// clang-format on
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user