好友黑名单功能
This commit is contained in:
parent
a22512d5cd
commit
44d440788c
@ -35,10 +35,12 @@ PRIMARY KEY (`idx`),
|
|||||||
UNIQUE KEY `friend_req` (`sender_account_id`,`receiver_account_id`)
|
UNIQUE KEY `friend_req` (`sender_account_id`,`receiver_account_id`)
|
||||||
) COMMENT "等待验证的好友请求";
|
) COMMENT "等待验证的好友请求";
|
||||||
|
|
||||||
CREATE TABLE `t_friend_blocked` (
|
drop table if exists t_friend_blacklist;
|
||||||
|
CREATE TABLE `t_friend_blacklist` (
|
||||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
`idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||||
`account_id` varchar(60) COLLATE utf8_bin NOT NULL,
|
`account_id` varchar(60) COLLATE utf8_bin NOT NULL,
|
||||||
`blocked_account_id` varchar(60) COLLATE utf8_bin NOT NULL,
|
`blocked_account_id` varchar(60) COLLATE utf8_bin NOT NULL,
|
||||||
|
`is_removed` tinyint(4) DEFAULT '0' COMMENT '是否移除黑名单 default:0, removed:1',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
PRIMARY KEY (`idx`),
|
PRIMARY KEY (`idx`),
|
||||||
|
@ -46,6 +46,8 @@ type MsgHandler interface {
|
|||||||
CMListPendingFriendRequest(*f5.MsgHdr, *CMListPendingFriendRequest)
|
CMListPendingFriendRequest(*f5.MsgHdr, *CMListPendingFriendRequest)
|
||||||
CMListFriend(*f5.MsgHdr, *CMListFriend)
|
CMListFriend(*f5.MsgHdr, *CMListFriend)
|
||||||
CMDeleteFriendShip(*f5.MsgHdr, *CMDeleteFriendShip)
|
CMDeleteFriendShip(*f5.MsgHdr, *CMDeleteFriendShip)
|
||||||
|
CMAddBlacklist(*f5.MsgHdr, *CMAddBlacklist)
|
||||||
|
CMRemoveBlacklist(*f5.MsgHdr, *CMRemoveBlacklist)
|
||||||
CMGuildInfo(*f5.MsgHdr, *CMGuildInfo)
|
CMGuildInfo(*f5.MsgHdr, *CMGuildInfo)
|
||||||
CMCreateGuild(*f5.MsgHdr, *CMCreateGuild)
|
CMCreateGuild(*f5.MsgHdr, *CMCreateGuild)
|
||||||
CMApplyToGuild(*f5.MsgHdr, *CMApplyToGuild)
|
CMApplyToGuild(*f5.MsgHdr, *CMApplyToGuild)
|
||||||
@ -92,6 +94,12 @@ func (this *MsgHandlerImpl) CMListFriend(hdr *f5.MsgHdr, msg *CMListFriend) {
|
|||||||
func (this *MsgHandlerImpl) CMDeleteFriendShip(hdr *f5.MsgHdr, msg *CMDeleteFriendShip) {
|
func (this *MsgHandlerImpl) CMDeleteFriendShip(hdr *f5.MsgHdr, msg *CMDeleteFriendShip) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *MsgHandlerImpl) CMAddBlacklist(hdr *f5.MsgHdr, msg *CMAddBlacklist) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *MsgHandlerImpl) CMRemoveBlacklist(hdr *f5.MsgHdr, msg *CMRemoveBlacklist) {
|
||||||
|
}
|
||||||
|
|
||||||
func (this *MsgHandlerImpl) CMGuildInfo(hdr *f5.MsgHdr, msg *CMGuildInfo) {
|
func (this *MsgHandlerImpl) CMGuildInfo(hdr *f5.MsgHdr, msg *CMGuildInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,6 +225,22 @@ func (this *SMDeleteFriendShip) GetNetMsgId() uint16 {
|
|||||||
return uint16(SMMessageIdE__SMDeleteFriendShip)
|
return uint16(SMMessageIdE__SMDeleteFriendShip)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *CMAddBlacklist) GetNetMsgId() uint16 {
|
||||||
|
return uint16(CMMessageIdE__CMAddBlacklist)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *SMAddBlacklist) GetNetMsgId() uint16 {
|
||||||
|
return uint16(SMMessageIdE__SMAddBlacklist)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *CMRemoveBlacklist) GetNetMsgId() uint16 {
|
||||||
|
return uint16(CMMessageIdE__CMRemoveBlacklist)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *SMRemoveBlacklist) GetNetMsgId() uint16 {
|
||||||
|
return uint16(SMMessageIdE__SMRemoveBlacklist)
|
||||||
|
}
|
||||||
|
|
||||||
func (this *CMGuildInfo) GetNetMsgId() uint16 {
|
func (this *CMGuildInfo) GetNetMsgId() uint16 {
|
||||||
return uint16(CMMessageIdE__CMGuildInfo)
|
return uint16(CMMessageIdE__CMGuildInfo)
|
||||||
}
|
}
|
||||||
@ -439,6 +463,30 @@ func init() {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handlers[int(CMMessageIdE__CMAddBlacklist)] = &CsNetMsgHandler{
|
||||||
|
MsgId: int(CMMessageIdE__CMAddBlacklist),
|
||||||
|
ParseCb: func (data []byte) interface{} {
|
||||||
|
msg := &CMAddBlacklist{}
|
||||||
|
proto.Unmarshal(data, msg)
|
||||||
|
return msg
|
||||||
|
},
|
||||||
|
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
|
||||||
|
handler.CMAddBlacklist(hdr, hdr.Msg.(*CMAddBlacklist))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
handlers[int(CMMessageIdE__CMRemoveBlacklist)] = &CsNetMsgHandler{
|
||||||
|
MsgId: int(CMMessageIdE__CMRemoveBlacklist),
|
||||||
|
ParseCb: func (data []byte) interface{} {
|
||||||
|
msg := &CMRemoveBlacklist{}
|
||||||
|
proto.Unmarshal(data, msg)
|
||||||
|
return msg
|
||||||
|
},
|
||||||
|
Cb: func (hdr *f5.MsgHdr, handler MsgHandler) {
|
||||||
|
handler.CMRemoveBlacklist(hdr, hdr.Msg.(*CMRemoveBlacklist))
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
handlers[int(CMMessageIdE__CMGuildInfo)] = &CsNetMsgHandler{
|
handlers[int(CMMessageIdE__CMGuildInfo)] = &CsNetMsgHandler{
|
||||||
MsgId: int(CMMessageIdE__CMGuildInfo),
|
MsgId: int(CMMessageIdE__CMGuildInfo),
|
||||||
ParseCb: func (data []byte) interface{} {
|
ParseCb: func (data []byte) interface{} {
|
||||||
|
@ -36,6 +36,8 @@ const (
|
|||||||
CMMessageIdE__CMListPendingFriendRequest CMMessageIdE = 110
|
CMMessageIdE__CMListPendingFriendRequest CMMessageIdE = 110
|
||||||
CMMessageIdE__CMListFriend CMMessageIdE = 111
|
CMMessageIdE__CMListFriend CMMessageIdE = 111
|
||||||
CMMessageIdE__CMDeleteFriendShip CMMessageIdE = 112
|
CMMessageIdE__CMDeleteFriendShip CMMessageIdE = 112
|
||||||
|
CMMessageIdE__CMAddBlacklist CMMessageIdE = 113
|
||||||
|
CMMessageIdE__CMRemoveBlacklist CMMessageIdE = 114
|
||||||
// 公会相关
|
// 公会相关
|
||||||
CMMessageIdE__CMGuildInfo CMMessageIdE = 120
|
CMMessageIdE__CMGuildInfo CMMessageIdE = 120
|
||||||
CMMessageIdE__CMCreateGuild CMMessageIdE = 121
|
CMMessageIdE__CMCreateGuild CMMessageIdE = 121
|
||||||
@ -64,6 +66,8 @@ var (
|
|||||||
110: "_CMListPendingFriendRequest",
|
110: "_CMListPendingFriendRequest",
|
||||||
111: "_CMListFriend",
|
111: "_CMListFriend",
|
||||||
112: "_CMDeleteFriendShip",
|
112: "_CMDeleteFriendShip",
|
||||||
|
113: "_CMAddBlacklist",
|
||||||
|
114: "_CMRemoveBlacklist",
|
||||||
120: "_CMGuildInfo",
|
120: "_CMGuildInfo",
|
||||||
121: "_CMCreateGuild",
|
121: "_CMCreateGuild",
|
||||||
122: "_CMApplyToGuild",
|
122: "_CMApplyToGuild",
|
||||||
@ -88,6 +92,8 @@ var (
|
|||||||
"_CMListPendingFriendRequest": 110,
|
"_CMListPendingFriendRequest": 110,
|
||||||
"_CMListFriend": 111,
|
"_CMListFriend": 111,
|
||||||
"_CMDeleteFriendShip": 112,
|
"_CMDeleteFriendShip": 112,
|
||||||
|
"_CMAddBlacklist": 113,
|
||||||
|
"_CMRemoveBlacklist": 114,
|
||||||
"_CMGuildInfo": 120,
|
"_CMGuildInfo": 120,
|
||||||
"_CMCreateGuild": 121,
|
"_CMCreateGuild": 121,
|
||||||
"_CMApplyToGuild": 122,
|
"_CMApplyToGuild": 122,
|
||||||
@ -154,6 +160,8 @@ const (
|
|||||||
SMMessageIdE__SMListPendingFriendRequest SMMessageIdE = 110
|
SMMessageIdE__SMListPendingFriendRequest SMMessageIdE = 110
|
||||||
SMMessageIdE__SMListFriend SMMessageIdE = 111
|
SMMessageIdE__SMListFriend SMMessageIdE = 111
|
||||||
SMMessageIdE__SMDeleteFriendShip SMMessageIdE = 112
|
SMMessageIdE__SMDeleteFriendShip SMMessageIdE = 112
|
||||||
|
SMMessageIdE__SMAddBlacklist SMMessageIdE = 113
|
||||||
|
SMMessageIdE__SMRemoveBlacklist SMMessageIdE = 114
|
||||||
// 公会相关
|
// 公会相关
|
||||||
SMMessageIdE__SMGuildInfo SMMessageIdE = 120
|
SMMessageIdE__SMGuildInfo SMMessageIdE = 120
|
||||||
SMMessageIdE__SMCreateGuild SMMessageIdE = 121
|
SMMessageIdE__SMCreateGuild SMMessageIdE = 121
|
||||||
@ -183,6 +191,8 @@ var (
|
|||||||
110: "_SMListPendingFriendRequest",
|
110: "_SMListPendingFriendRequest",
|
||||||
111: "_SMListFriend",
|
111: "_SMListFriend",
|
||||||
112: "_SMDeleteFriendShip",
|
112: "_SMDeleteFriendShip",
|
||||||
|
113: "_SMAddBlacklist",
|
||||||
|
114: "_SMRemoveBlacklist",
|
||||||
120: "_SMGuildInfo",
|
120: "_SMGuildInfo",
|
||||||
121: "_SMCreateGuild",
|
121: "_SMCreateGuild",
|
||||||
122: "_SMApplyToGuild",
|
122: "_SMApplyToGuild",
|
||||||
@ -208,6 +218,8 @@ var (
|
|||||||
"_SMListPendingFriendRequest": 110,
|
"_SMListPendingFriendRequest": 110,
|
||||||
"_SMListFriend": 111,
|
"_SMListFriend": 111,
|
||||||
"_SMDeleteFriendShip": 112,
|
"_SMDeleteFriendShip": 112,
|
||||||
|
"_SMAddBlacklist": 113,
|
||||||
|
"_SMRemoveBlacklist": 114,
|
||||||
"_SMGuildInfo": 120,
|
"_SMGuildInfo": 120,
|
||||||
"_SMCreateGuild": 121,
|
"_SMCreateGuild": 121,
|
||||||
"_SMApplyToGuild": 122,
|
"_SMApplyToGuild": 122,
|
||||||
@ -263,7 +275,7 @@ var File_cs_msgid_proto protoreflect.FileDescriptor
|
|||||||
|
|
||||||
var file_cs_msgid_proto_rawDesc = []byte{
|
var file_cs_msgid_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0e, 0x63, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x69, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
0x0a, 0x0e, 0x63, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x69, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
0x12, 0x02, 0x63, 0x73, 0x2a, 0xe1, 0x03, 0x0a, 0x0d, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61,
|
0x12, 0x02, 0x63, 0x73, 0x2a, 0x8e, 0x04, 0x0a, 0x0d, 0x43, 0x4d, 0x4d, 0x65, 0x73, 0x73, 0x61,
|
||||||
0x67, 0x65, 0x49, 0x64, 0x5f, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x43, 0x4d, 0x50, 0x69, 0x6e,
|
0x67, 0x65, 0x49, 0x64, 0x5f, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x43, 0x4d, 0x50, 0x69, 0x6e,
|
||||||
0x67, 0x10, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x43, 0x4d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x10,
|
0x67, 0x10, 0x65, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x43, 0x4d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x10,
|
||||||
0x67, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
|
0x67, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
|
||||||
@ -280,52 +292,57 @@ var file_cs_msgid_proto_rawDesc = []byte{
|
|||||||
0x75, 0x65, 0x73, 0x74, 0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x43, 0x4d, 0x4c, 0x69, 0x73,
|
0x75, 0x65, 0x73, 0x74, 0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x43, 0x4d, 0x4c, 0x69, 0x73,
|
||||||
0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x10, 0x6f, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x43, 0x4d,
|
0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x10, 0x6f, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x43, 0x4d,
|
||||||
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x68, 0x69, 0x70,
|
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x68, 0x69, 0x70,
|
||||||
0x10, 0x70, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x43, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e,
|
0x10, 0x70, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x41, 0x64, 0x64, 0x42, 0x6c, 0x61, 0x63,
|
||||||
0x66, 0x6f, 0x10, 0x78, 0x12, 0x12, 0x0a, 0x0e, 0x5f, 0x43, 0x4d, 0x43, 0x72, 0x65, 0x61, 0x74,
|
0x6b, 0x6c, 0x69, 0x73, 0x74, 0x10, 0x71, 0x12, 0x16, 0x0a, 0x12, 0x5f, 0x43, 0x4d, 0x52, 0x65,
|
||||||
0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x79, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x41,
|
0x6d, 0x6f, 0x76, 0x65, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x6c, 0x69, 0x73, 0x74, 0x10, 0x72, 0x12,
|
||||||
0x70, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7a, 0x12, 0x0e, 0x0a,
|
0x10, 0x0a, 0x0c, 0x5f, 0x43, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10,
|
||||||
0x0a, 0x5f, 0x43, 0x4d, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x10, 0x7b, 0x12, 0x0d, 0x0a,
|
0x78, 0x12, 0x12, 0x0a, 0x0e, 0x5f, 0x43, 0x4d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x75,
|
||||||
0x09, 0x5f, 0x43, 0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x7c, 0x12, 0x11, 0x0a, 0x0d,
|
0x69, 0x6c, 0x64, 0x10, 0x79, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x41, 0x70, 0x70, 0x6c,
|
||||||
0x5f, 0x43, 0x4d, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7d, 0x12,
|
0x79, 0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7a, 0x12, 0x0e, 0x0a, 0x0a, 0x5f, 0x43,
|
||||||
0x14, 0x0a, 0x10, 0x5f, 0x43, 0x4d, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x4d, 0x65, 0x6d,
|
0x4d, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x10, 0x7b, 0x12, 0x0d, 0x0a, 0x09, 0x5f, 0x43,
|
||||||
0x62, 0x65, 0x72, 0x10, 0x7e, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x43, 0x4d, 0x50, 0x72, 0x6f, 0x6d,
|
0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x7c, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x43, 0x4d,
|
||||||
0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7f, 0x12, 0x14, 0x0a, 0x0f, 0x5f,
|
0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7d, 0x12, 0x14, 0x0a, 0x10,
|
||||||
0x43, 0x4d, 0x44, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x80,
|
0x5f, 0x43, 0x4d, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72,
|
||||||
0x01, 0x12, 0x0f, 0x0a, 0x0a, 0x5f, 0x43, 0x4d, 0x44, 0x69, 0x73, 0x62, 0x61, 0x6e, 0x64, 0x10,
|
0x10, 0x7e, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x43, 0x4d, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65,
|
||||||
0x81, 0x01, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x47,
|
0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7f, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x44,
|
||||||
0x75, 0x69, 0x6c, 0x64, 0x73, 0x10, 0x82, 0x01, 0x2a, 0xf2, 0x03, 0x0a, 0x0d, 0x53, 0x4d, 0x4d,
|
0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x80, 0x01, 0x12, 0x0f,
|
||||||
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x5f, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x53,
|
0x0a, 0x0a, 0x5f, 0x43, 0x4d, 0x44, 0x69, 0x73, 0x62, 0x61, 0x6e, 0x64, 0x10, 0x81, 0x01, 0x12,
|
||||||
0x4d, 0x50, 0x69, 0x6e, 0x67, 0x10, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x5f, 0x53, 0x4d, 0x52, 0x70,
|
0x14, 0x0a, 0x0f, 0x5f, 0x43, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x47, 0x75, 0x69, 0x6c,
|
||||||
0x63, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x66, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x4d, 0x4c,
|
0x64, 0x73, 0x10, 0x82, 0x01, 0x2a, 0x9f, 0x04, 0x0a, 0x0d, 0x53, 0x4d, 0x4d, 0x65, 0x73, 0x73,
|
||||||
0x6f, 0x67, 0x69, 0x6e, 0x10, 0x67, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x63,
|
0x61, 0x67, 0x65, 0x49, 0x64, 0x5f, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x5f, 0x53, 0x4d, 0x50, 0x69,
|
||||||
0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x10, 0x68, 0x12, 0x1c, 0x0a, 0x18, 0x5f, 0x53, 0x4d, 0x53,
|
0x6e, 0x67, 0x10, 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x5f, 0x53, 0x4d, 0x52, 0x70, 0x63, 0x45, 0x72,
|
||||||
0x65, 0x61, 0x72, 0x63, 0x68, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75,
|
0x72, 0x6f, 0x72, 0x10, 0x66, 0x12, 0x0c, 0x0a, 0x08, 0x5f, 0x53, 0x4d, 0x4c, 0x6f, 0x67, 0x69,
|
||||||
0x6e, 0x74, 0x49, 0x64, 0x10, 0x69, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61,
|
0x6e, 0x10, 0x67, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x6e,
|
||||||
0x72, 0x63, 0x68, 0x55, 0x73, 0x65, 0x72, 0x10, 0x6a, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d,
|
0x65, 0x63, 0x74, 0x10, 0x68, 0x12, 0x1c, 0x0a, 0x18, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72,
|
||||||
0x41, 0x64, 0x64, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
0x63, 0x68, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x49,
|
||||||
0x10, 0x6b, 0x12, 0x1a, 0x0a, 0x16, 0x5f, 0x53, 0x4d, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x46,
|
0x64, 0x10, 0x69, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68,
|
||||||
0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6c, 0x12, 0x1a,
|
0x55, 0x73, 0x65, 0x72, 0x10, 0x6a, 0x12, 0x17, 0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x41, 0x64, 0x64,
|
||||||
0x0a, 0x16, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e,
|
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6b, 0x12,
|
||||||
0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6d, 0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x53,
|
0x1a, 0x0a, 0x16, 0x5f, 0x53, 0x4d, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x46, 0x72, 0x69, 0x65,
|
||||||
0x4d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x69, 0x65,
|
0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6c, 0x12, 0x1a, 0x0a, 0x16, 0x5f,
|
||||||
0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x5f,
|
0x53, 0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65,
|
||||||
0x53, 0x4d, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x10, 0x6f, 0x12, 0x17,
|
0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6d, 0x12, 0x1f, 0x0a, 0x1b, 0x5f, 0x53, 0x4d, 0x4c, 0x69,
|
||||||
0x0a, 0x13, 0x5f, 0x53, 0x4d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e,
|
0x73, 0x74, 0x50, 0x65, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52,
|
||||||
0x64, 0x53, 0x68, 0x69, 0x70, 0x10, 0x70, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x47, 0x75,
|
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x10, 0x6e, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x4c,
|
||||||
0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x10, 0x78, 0x12, 0x12, 0x0a, 0x0e, 0x5f, 0x53, 0x4d,
|
0x69, 0x73, 0x74, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x10, 0x6f, 0x12, 0x17, 0x0a, 0x13, 0x5f,
|
||||||
0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x79, 0x12, 0x13, 0x0a,
|
0x53, 0x4d, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x68,
|
||||||
0x0f, 0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64,
|
0x69, 0x70, 0x10, 0x70, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x41, 0x64, 0x64, 0x42, 0x6c,
|
||||||
0x10, 0x7a, 0x12, 0x0e, 0x0a, 0x0a, 0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65,
|
0x61, 0x63, 0x6b, 0x6c, 0x69, 0x73, 0x74, 0x10, 0x71, 0x12, 0x16, 0x0a, 0x12, 0x5f, 0x53, 0x4d,
|
||||||
0x10, 0x7b, 0x12, 0x0d, 0x0a, 0x09, 0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10,
|
0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x6c, 0x69, 0x73, 0x74, 0x10,
|
||||||
0x7c, 0x12, 0x11, 0x0a, 0x0d, 0x5f, 0x53, 0x4d, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69,
|
0x72, 0x12, 0x10, 0x0a, 0x0c, 0x5f, 0x53, 0x4d, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x49, 0x6e, 0x66,
|
||||||
0x6c, 0x64, 0x10, 0x7d, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x53, 0x4d, 0x44, 0x69, 0x73, 0x6d, 0x69,
|
0x6f, 0x10, 0x78, 0x12, 0x12, 0x0a, 0x0e, 0x5f, 0x53, 0x4d, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
|
||||||
0x73, 0x73, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7e, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x53,
|
0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x79, 0x12, 0x13, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x41, 0x70,
|
||||||
0x4d, 0x50, 0x72, 0x6f, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7f,
|
0x70, 0x6c, 0x79, 0x54, 0x6f, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7a, 0x12, 0x0e, 0x0a, 0x0a,
|
||||||
0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x44, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d,
|
0x5f, 0x53, 0x4d, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x10, 0x7b, 0x12, 0x0d, 0x0a, 0x09,
|
||||||
0x62, 0x65, 0x72, 0x10, 0x80, 0x01, 0x12, 0x0f, 0x0a, 0x0a, 0x5f, 0x53, 0x4d, 0x44, 0x69, 0x73,
|
0x5f, 0x53, 0x4d, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x10, 0x7c, 0x12, 0x11, 0x0a, 0x0d, 0x5f,
|
||||||
0x62, 0x61, 0x6e, 0x64, 0x10, 0x81, 0x01, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x53, 0x65,
|
0x53, 0x4d, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x10, 0x7d, 0x12, 0x14,
|
||||||
0x61, 0x72, 0x63, 0x68, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x10, 0x82, 0x01, 0x42, 0x06, 0x5a,
|
0x0a, 0x10, 0x5f, 0x53, 0x4d, 0x44, 0x69, 0x73, 0x6d, 0x69, 0x73, 0x73, 0x4d, 0x65, 0x6d, 0x62,
|
||||||
0x04, 0x2e, 0x3b, 0x63, 0x73,
|
0x65, 0x72, 0x10, 0x7e, 0x12, 0x14, 0x0a, 0x10, 0x5f, 0x53, 0x4d, 0x50, 0x72, 0x6f, 0x6d, 0x6f,
|
||||||
|
0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x7f, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x53,
|
||||||
|
0x4d, 0x44, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x10, 0x80, 0x01,
|
||||||
|
0x12, 0x0f, 0x0a, 0x0a, 0x5f, 0x53, 0x4d, 0x44, 0x69, 0x73, 0x62, 0x61, 0x6e, 0x64, 0x10, 0x81,
|
||||||
|
0x01, 0x12, 0x14, 0x0a, 0x0f, 0x5f, 0x53, 0x4d, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x47, 0x75,
|
||||||
|
0x69, 0x6c, 0x64, 0x73, 0x10, 0x82, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x63, 0x73,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -6,58 +6,51 @@ import (
|
|||||||
"q5"
|
"q5"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (fm *FriendsMgr) insertFriendRequest(account1Id string, account2Id string, is_friendship string) {
|
func (fm *FriendsMgr) upsertFriendRequest(account1Id string, account2Id string, isFriendship string) {
|
||||||
fields := [][]string{
|
|
||||||
{"sender_account_id", account1Id},
|
|
||||||
{"receiver_account_id", account2Id},
|
|
||||||
{"is_friendship", is_friendship},
|
|
||||||
}
|
|
||||||
f5.GetJsStyleDb().Replace(
|
|
||||||
FRIEND_DB,
|
|
||||||
"t_friend_pending_request",
|
|
||||||
fields,
|
|
||||||
func(err error, lastInsertId int64, rowsAffected int64) {
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("error:%v\n", err)
|
|
||||||
}
|
|
||||||
fmt.Printf("lastInsertId:%d\n", lastInsertId)
|
|
||||||
fmt.Printf("rowsAffected:%d\n", rowsAffected)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fm *FriendsMgr) updateFriendRequest(account1Id string, account2Id string, fields [][]string) {
|
|
||||||
if len(fields) <= 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
where := [][]string{
|
where := [][]string{
|
||||||
{"sender_account_id", account1Id},
|
|
||||||
{"receiver_account_id", account2Id},
|
|
||||||
}
|
|
||||||
f5.GetJsStyleDb().Update(
|
|
||||||
FRIEND_DB,
|
|
||||||
"t_friend_pending_request",
|
|
||||||
fields,
|
|
||||||
where,
|
|
||||||
func(err error, lastInsertId int64, rowsAffected int64) {
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("error:%v\n", err)
|
|
||||||
}
|
|
||||||
fmt.Printf("lastInsertId:%d\n", lastInsertId)
|
|
||||||
fmt.Printf("rowsAffected:%d\n", rowsAffected)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fm *FriendsMgr) insertFriendShip(account1Id string, account2Id string) {
|
|
||||||
fields := [][]string{
|
|
||||||
{"account1_id", account1Id},
|
{"account1_id", account1Id},
|
||||||
{"account2_id", account2Id},
|
{"account2_id", account2Id},
|
||||||
}
|
}
|
||||||
f5.GetJsStyleDb().Insert(
|
insertKv := [][]string{
|
||||||
|
{"sender_account_id", account1Id},
|
||||||
|
{"receiver_account_id", account2Id},
|
||||||
|
{"is_friendship", isFriendship},
|
||||||
|
}
|
||||||
|
updateKv := insertKv
|
||||||
|
f5.GetJsStyleDb().Upsert(
|
||||||
|
FRIEND_DB,
|
||||||
|
"t_friend_pending_request",
|
||||||
|
where,
|
||||||
|
updateKv,
|
||||||
|
insertKv,
|
||||||
|
func(err error, lastInsertId int64, rowsAffected int64) {
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error:%v\n", err)
|
||||||
|
}
|
||||||
|
fmt.Printf("lastInsertId:%d\n", lastInsertId)
|
||||||
|
fmt.Printf("rowsAffected:%d\n", rowsAffected)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fm *FriendsMgr) upsertFriendShip(account1Id string, account2Id string, isDeleteFriendship int) {
|
||||||
|
where := [][]string{
|
||||||
|
{"account1_id", account1Id},
|
||||||
|
{"account2_id", account2Id},
|
||||||
|
}
|
||||||
|
fields := [][]string{
|
||||||
|
{"account1_id", account1Id},
|
||||||
|
{"account2_id", account2Id},
|
||||||
|
{"is_delete_friendship", q5.ToString(isDeleteFriendship)},
|
||||||
|
}
|
||||||
|
insertKv := fields
|
||||||
|
updateKv := fields
|
||||||
|
f5.GetJsStyleDb().Upsert(
|
||||||
FRIEND_DB,
|
FRIEND_DB,
|
||||||
"t_friend_ships",
|
"t_friend_ships",
|
||||||
fields,
|
where,
|
||||||
|
updateKv,
|
||||||
|
insertKv,
|
||||||
func(err error, lastInsertId int64, rowsAffected int64) {
|
func(err error, lastInsertId int64, rowsAffected int64) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error:%v\n", err)
|
fmt.Printf("error:%v\n", err)
|
||||||
@ -88,6 +81,32 @@ func (fm *FriendsMgr) updateFriendShip(account1Id string, account2Id string, fie
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fm *FriendsMgr) upsertBlacklist(account1Id string, account2Id string, isRemoved int) {
|
||||||
|
where := [][]string{
|
||||||
|
{"account_id", account1Id},
|
||||||
|
}
|
||||||
|
insertKv := [][]string{
|
||||||
|
{"account_id", account1Id},
|
||||||
|
{"blocked_account_id", account2Id},
|
||||||
|
{"is_removed", q5.ToString(isRemoved)},
|
||||||
|
}
|
||||||
|
updateKv := insertKv
|
||||||
|
f5.GetJsStyleDb().Upsert(
|
||||||
|
FRIEND_DB,
|
||||||
|
"t_friend_blacklist",
|
||||||
|
where,
|
||||||
|
updateKv,
|
||||||
|
insertKv,
|
||||||
|
func(err error, lastInsertId int64, rowsAffected int64) {
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("error:%v\n", err)
|
||||||
|
}
|
||||||
|
fmt.Printf("lastInsertId:%d\n", lastInsertId)
|
||||||
|
fmt.Printf("rowsAffected:%d\n", rowsAffected)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// loadUsers 加载所有用户
|
// loadUsers 加载所有用户
|
||||||
func (fm *FriendsMgr) loadUsers() {
|
func (fm *FriendsMgr) loadUsers() {
|
||||||
fields := []string{"account_id", "name"}
|
fields := []string{"account_id", "name"}
|
||||||
@ -176,3 +195,31 @@ func (fm *FriendsMgr) loadPendingRequestsResult(err error, rows *f5.DataSet) {
|
|||||||
fm.pendingReqs[receiverAccountId][senderAccountId] = true
|
fm.pendingReqs[receiverAccountId][senderAccountId] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// loadPendingRequests 加载等待验证好友请求
|
||||||
|
func (fm *FriendsMgr) loadBlacklist() {
|
||||||
|
fields := []string{"account_id", "blocked_account_id"}
|
||||||
|
f5.GetJsStyleDb().Select(
|
||||||
|
FRIEND_DB,
|
||||||
|
"t_friend_blacklist",
|
||||||
|
fields,
|
||||||
|
[][]string{
|
||||||
|
{"is_removed", "0"},
|
||||||
|
},
|
||||||
|
fm.loadBlacklistResult,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fm *FriendsMgr) loadBlacklistResult(err error, rows *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("loadBlacklistResult err:%v \n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fm.blackList = make(map[string]map[string]bool, 100)
|
||||||
|
for rows.Next() {
|
||||||
|
account1Id := q5.ToString(*rows.GetByIndex(0))
|
||||||
|
account2Id := q5.ToString(*rows.GetByIndex(1))
|
||||||
|
fm.blackList[account1Id] = make(map[string]bool, MaxBlockedMembers)
|
||||||
|
fm.blackList[account1Id][account2Id] = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -17,7 +17,7 @@ type FriendsMgr struct {
|
|||||||
searchCaches map[string]SearchCache // SearchKeyword -> 好友搜索结果 []*User
|
searchCaches map[string]SearchCache // SearchKeyword -> 好友搜索结果 []*User
|
||||||
friendships map[string][]*Friendship // AccountId -> 好友关系列表 []*Friendship
|
friendships map[string][]*Friendship // AccountId -> 好友关系列表 []*Friendship
|
||||||
pendingReqs map[string]map[string]bool // AccountId -> 等待请求列表 map[account2Id]true
|
pendingReqs map[string]map[string]bool // AccountId -> 等待请求列表 map[account2Id]true
|
||||||
blackList map[string][]string // AccountId -> 黑名单列表 []AccountIds
|
blackList map[string]map[string]bool // AccountId -> 黑名单列表 map[account2Id]true
|
||||||
userCount int // 用户总数
|
userCount int // 用户总数
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,6 +34,9 @@ func (fm *FriendsMgr) init() {
|
|||||||
fm.loadFriendships()
|
fm.loadFriendships()
|
||||||
// 加载等待验证好友请求 列表
|
// 加载等待验证好友请求 列表
|
||||||
fm.loadPendingRequests()
|
fm.loadPendingRequests()
|
||||||
|
// 加载黑名单列表
|
||||||
|
fm.loadBlacklist()
|
||||||
|
|
||||||
fm.searchCaches = make(map[string]SearchCache)
|
fm.searchCaches = make(map[string]SearchCache)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,9 +89,6 @@ func (fm *FriendsMgr) searchUsers(keyword string) []*User {
|
|||||||
}
|
}
|
||||||
fm.clearExpiredCaches()
|
fm.clearExpiredCaches()
|
||||||
|
|
||||||
// Print result:
|
|
||||||
PrintUsers("Search result:", listFriend)
|
|
||||||
|
|
||||||
return listFriend
|
return listFriend
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ func (fm *FriendsMgr) addFriendRequest(account1Id string, account2Id string) err
|
|||||||
fm.pendingReqs[account2Id][account1Id] = true
|
fm.pendingReqs[account2Id][account1Id] = true
|
||||||
|
|
||||||
// persist to db
|
// persist to db
|
||||||
fm.insertFriendRequest(account1Id, account2Id, "0")
|
fm.upsertFriendRequest(account1Id, account2Id, "0")
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -155,10 +155,12 @@ func (fm *FriendsMgr) acceptFriendRequest(account1Id string, account2Id string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// step1. update reqs
|
// step1. update reqs
|
||||||
fm.insertFriendRequest(account2Id, account1Id, "1")
|
fm.upsertFriendRequest(account2Id, account1Id, "1")
|
||||||
|
fm.upsertFriendRequest(account1Id, account2Id, "1")
|
||||||
|
|
||||||
// step2. insert friendship
|
// step2. insert friendship
|
||||||
a1, a2 := swapMiniAccount(account1Id, account2Id)
|
a1, a2 := swapMiniAccount(account1Id, account2Id)
|
||||||
fm.insertFriendShip(a1, a2)
|
fm.upsertFriendShip(a1, a2, 0)
|
||||||
|
|
||||||
// Create a new friendship
|
// Create a new friendship
|
||||||
friendship := &Friendship{
|
friendship := &Friendship{
|
||||||
@ -182,10 +184,8 @@ func (fm *FriendsMgr) rejectFriendRequest(account1Id string, account2Id string)
|
|||||||
return errors.New("no pending friend request from user1 to user2")
|
return errors.New("no pending friend request from user1 to user2")
|
||||||
}
|
}
|
||||||
|
|
||||||
//fields := [][]string{{"is_friendship", q5.ToString(2)}}
|
|
||||||
//fm.updateFriendRequest(account1Id, account2Id, fields)
|
|
||||||
// 申请表,申请者,目标者,
|
// 申请表,申请者,目标者,
|
||||||
fm.insertFriendRequest(account2Id, account1Id, "2")
|
fm.upsertFriendRequest(account2Id, account1Id, "2")
|
||||||
|
|
||||||
delete(fm.pendingReqs[account1Id], account2Id)
|
delete(fm.pendingReqs[account1Id], account2Id)
|
||||||
delete(fm.pendingReqs[account2Id], account1Id)
|
delete(fm.pendingReqs[account2Id], account1Id)
|
||||||
@ -204,8 +204,8 @@ func (fm *FriendsMgr) deleteFriendShip(account1Id, account2Id string) error {
|
|||||||
var found bool
|
var found bool
|
||||||
for i, friendship := range user1Friendships {
|
for i, friendship := range user1Friendships {
|
||||||
if friendship.User1.AccountId == account2Id || friendship.User2.AccountId == account2Id {
|
if friendship.User1.AccountId == account2Id || friendship.User2.AccountId == account2Id {
|
||||||
// 删除好友请求, insert和replace, 不存在则新增,存在则替换值
|
// 删除好友请求, upsert 不存在则新增,存在则替换值
|
||||||
fm.insertFriendRequest(account1Id, account2Id, "3")
|
fm.upsertFriendRequest(account1Id, account2Id, "3")
|
||||||
fm.friendships[account1Id] = append(user1Friendships[:i], user1Friendships[i+1:]...)
|
fm.friendships[account1Id] = append(user1Friendships[:i], user1Friendships[i+1:]...)
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
@ -219,7 +219,7 @@ func (fm *FriendsMgr) deleteFriendShip(account1Id, account2Id string) error {
|
|||||||
for i, friendship := range user2Friendships {
|
for i, friendship := range user2Friendships {
|
||||||
if friendship.User1.AccountId == account1Id || friendship.User2.AccountId == account1Id {
|
if friendship.User1.AccountId == account1Id || friendship.User2.AccountId == account1Id {
|
||||||
// 删除好友请求, insert和replace, 不存在则新增,存在则替换值
|
// 删除好友请求, insert和replace, 不存在则新增,存在则替换值
|
||||||
fm.insertFriendRequest(account2Id, account1Id, "3")
|
fm.upsertFriendRequest(account2Id, account1Id, "3")
|
||||||
fm.friendships[account2Id] = append(user2Friendships[:i], user2Friendships[i+1:]...)
|
fm.friendships[account2Id] = append(user2Friendships[:i], user2Friendships[i+1:]...)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -271,36 +271,44 @@ func (fm *FriendsMgr) listFriend(accountId string) []*User {
|
|||||||
return users
|
return users
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fm *FriendsMgr) addBlocked(account1Id string, account2Id string) error {
|
// addBlacklist 加入黑名单
|
||||||
if fm.blackList[account1Id] == nil {
|
func (fm *FriendsMgr) addBlacklist(account1Id string, account2Id string) error {
|
||||||
fm.blackList[account1Id] = []string{}
|
user2 := fm.getUser(account2Id)
|
||||||
|
if user2 == nil {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fm.blackList[account1Id] == nil {
|
||||||
|
fm.blackList[account1Id] = make(map[string]bool, MaxBlockedMembers)
|
||||||
|
}
|
||||||
|
|
||||||
|
isRemoved, exists := fm.blackList[account1Id][account2Id]
|
||||||
|
if exists && !isRemoved {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if len(fm.blackList[account1Id]) >= 50 {
|
if len(fm.blackList[account1Id]) >= 50 {
|
||||||
return fmt.Errorf("your blacklist has reached the limit")
|
return fmt.Errorf("your blacklist has reached the limit")
|
||||||
}
|
}
|
||||||
|
|
||||||
index := fm.findBlockedUserIndex(account1Id, account2Id)
|
fm.blackList[account1Id][account2Id] = false
|
||||||
if index < 0 {
|
fm.upsertBlacklist(account1Id, account2Id, 0)
|
||||||
fm.blackList[account1Id] = append(fm.blackList[account1Id], account2Id)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fm *FriendsMgr) removeBlocked(account1Id string, account2Id string) error {
|
// removeBlacklist 移除黑名单
|
||||||
|
func (fm *FriendsMgr) removeBlacklist(account1Id string, account2Id string) error {
|
||||||
if fm.blackList[account1Id] == nil {
|
if fm.blackList[account1Id] == nil {
|
||||||
return fmt.Errorf("your blacklist is emtpy")
|
return fmt.Errorf("your blacklist is emtpy")
|
||||||
}
|
}
|
||||||
|
|
||||||
index := fm.findBlockedUserIndex(account1Id, account2Id)
|
if isRemoved, exists := fm.blackList[account1Id][account2Id]; !exists || isRemoved {
|
||||||
if index < 0 {
|
|
||||||
return fmt.Errorf("your blacklist not exists target account id")
|
return fmt.Errorf("your blacklist not exists target account id")
|
||||||
}
|
}
|
||||||
|
|
||||||
blockedUsers := fm.blackList[account1Id]
|
delete(fm.blackList[account1Id], account2Id)
|
||||||
blockedUsers = append(blockedUsers[:index], blockedUsers[index+1:]...)
|
fm.upsertBlacklist(account1Id, account2Id, 1)
|
||||||
|
|
||||||
fm.blackList[account1Id] = blockedUsers
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -336,18 +344,6 @@ func PrintUsers(str string, userList []*User) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fm *FriendsMgr) findBlockedUserIndex(Account1Id, Account2Id string) int {
|
|
||||||
if fm.blackList[Account1Id] != nil {
|
|
||||||
for i, blockedAccountId := range fm.blackList[Account1Id] {
|
|
||||||
if blockedAccountId == Account2Id {
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
func (fm *FriendsMgr) findFriendShipIndex(Account1Id, Account2Id string) int {
|
func (fm *FriendsMgr) findFriendShipIndex(Account1Id, Account2Id string) int {
|
||||||
// 通常 account1Id,指自己, account2Id 指对方
|
// 通常 account1Id,指自己, account2Id 指对方
|
||||||
if _, exists := fm.friendships[Account1Id]; exists {
|
if _, exists := fm.friendships[Account1Id]; exists {
|
||||||
@ -369,16 +365,20 @@ func (fm *FriendsMgr) getUser(accountId string) *User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fm *FriendsMgr) checkInBlackList(account1Id, account2Id string) error {
|
func (fm *FriendsMgr) checkInBlackList(account1Id, account2Id string) error {
|
||||||
for _, blockedAccountId := range fm.blackList[account1Id] {
|
if fm.blackList[account1Id] == nil {
|
||||||
if blockedAccountId == account2Id {
|
fm.blackList[account1Id] = make(map[string]bool, MaxBlockedMembers)
|
||||||
return fmt.Errorf("user:%s in user:%s blocked", account2Id, account1Id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for _, blockedAccountId := range fm.blackList[account2Id] {
|
if isRemoved, exists := fm.blackList[account1Id][account2Id]; isRemoved && exists {
|
||||||
if blockedAccountId == account1Id {
|
return fmt.Errorf("user:%s in user:%s blocked", account2Id, account1Id)
|
||||||
return fmt.Errorf("user:%s in user:%s blocked", account1Id, account2Id)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fm.blackList[account2Id] == nil {
|
||||||
|
fm.blackList[account2Id] = make(map[string]bool, MaxBlockedMembers)
|
||||||
|
}
|
||||||
|
if isRemoved, exists := fm.blackList[account2Id][account1Id]; isRemoved && exists {
|
||||||
|
return fmt.Errorf("user:%s in user:%s blocked", account1Id, account2Id)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ func (this *HandlerMgr) init() {
|
|||||||
|
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMPing), PLAYER_MGR_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMPing), PLAYER_MGR_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), PLAYER_MGR_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMLogin), PLAYER_MGR_HANDLER_ID)
|
||||||
|
// 好友
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchUser), PLAYER_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchUser), PLAYER_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchUserByAccountId), PLAYER_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMSearchUserByAccountId), PLAYER_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMAddFriendRequest), PLAYER_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMAddFriendRequest), PLAYER_HANDLER_ID)
|
||||||
@ -22,7 +23,9 @@ func (this *HandlerMgr) init() {
|
|||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMListPendingFriendRequest), PLAYER_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMListPendingFriendRequest), PLAYER_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMListFriend), PLAYER_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMListFriend), PLAYER_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMDeleteFriendShip), PLAYER_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMDeleteFriendShip), PLAYER_HANDLER_ID)
|
||||||
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMAddBlacklist), PLAYER_HANDLER_ID)
|
||||||
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMRemoveBlacklist), PLAYER_HANDLER_ID)
|
||||||
|
// 公会
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMGuildInfo), PLAYER_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMGuildInfo), PLAYER_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMCreateGuild), PLAYER_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMCreateGuild), PLAYER_HANDLER_ID)
|
||||||
cs.RegHandlerId(int(cs.CMMessageIdE__CMApplyToGuild), PLAYER_HANDLER_ID)
|
cs.RegHandlerId(int(cs.CMMessageIdE__CMApplyToGuild), PLAYER_HANDLER_ID)
|
||||||
|
@ -162,6 +162,42 @@ func (p *Player) CMDeleteFriendShip(hdr *f5.MsgHdr, msg *cs.CMDeleteFriendShip)
|
|||||||
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CMAddBlacklist 加入黑名单
|
||||||
|
func (p *Player) CMAddBlacklist(hdr *f5.MsgHdr, msg *cs.CMAddBlacklist) {
|
||||||
|
rspMsg := &cs.SMDeleteFriendShip{}
|
||||||
|
user1Id := p.accountId
|
||||||
|
user2Id := msg.GetTargetAccountId()
|
||||||
|
err := friendMgr.addBlacklist(user1Id, user2Id)
|
||||||
|
if err != nil {
|
||||||
|
reason := err.Error()
|
||||||
|
rspMsg.Reason = &reason
|
||||||
|
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||||
|
f5.GetSysLog().Info("CMAddBlacklist err:%s, params: %s or %s\n", reason, user1Id, user2Id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
status := "added"
|
||||||
|
rspMsg.Status = &status
|
||||||
|
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CMRemoveBlacklist 移除黑名单
|
||||||
|
func (p *Player) CMRemoveBlacklist(hdr *f5.MsgHdr, msg *cs.CMRemoveBlacklist) {
|
||||||
|
rspMsg := &cs.SMRemoveBlacklist{}
|
||||||
|
user1Id := p.accountId
|
||||||
|
user2Id := msg.GetTargetAccountId()
|
||||||
|
err := friendMgr.removeBlacklist(user1Id, user2Id)
|
||||||
|
if err != nil {
|
||||||
|
reason := err.Error()
|
||||||
|
rspMsg.Reason = &reason
|
||||||
|
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||||
|
f5.GetSysLog().Info("CMRemoveBlacklist err:%s, params: %s or %s\n", reason, user1Id, user2Id)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
status := "removed"
|
||||||
|
rspMsg.Status = &status
|
||||||
|
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||||
|
}
|
||||||
|
|
||||||
//func (fm *Player) FillFriend(rspMsg) {
|
//func (fm *Player) FillFriend(rspMsg) {
|
||||||
// //
|
// //
|
||||||
//}
|
//}
|
||||||
|
@ -58,7 +58,8 @@ func (this *PlayerMgr) init() {
|
|||||||
GAME_DB,
|
GAME_DB,
|
||||||
"t_user",
|
"t_user",
|
||||||
[][]string{
|
[][]string{
|
||||||
[]string{"account_id", "100"}},
|
[]string{"account_id", "100"},
|
||||||
|
},
|
||||||
func(err error, row *f5.DataSet) {
|
func(err error, row *f5.DataSet) {
|
||||||
fmt.Println(row)
|
fmt.Println(row)
|
||||||
})
|
})
|
||||||
|
@ -18,6 +18,8 @@ enum CMMessageId_e
|
|||||||
_CMListPendingFriendRequest = 110;
|
_CMListPendingFriendRequest = 110;
|
||||||
_CMListFriend = 111;
|
_CMListFriend = 111;
|
||||||
_CMDeleteFriendShip = 112;
|
_CMDeleteFriendShip = 112;
|
||||||
|
_CMAddBlacklist = 113;
|
||||||
|
_CMRemoveBlacklist = 114;
|
||||||
|
|
||||||
// 公会相关
|
// 公会相关
|
||||||
_CMGuildInfo = 120;
|
_CMGuildInfo = 120;
|
||||||
@ -48,6 +50,8 @@ enum SMMessageId_e
|
|||||||
_SMListPendingFriendRequest = 110;
|
_SMListPendingFriendRequest = 110;
|
||||||
_SMListFriend = 111;
|
_SMListFriend = 111;
|
||||||
_SMDeleteFriendShip = 112;
|
_SMDeleteFriendShip = 112;
|
||||||
|
_SMAddBlacklist = 113;
|
||||||
|
_SMRemoveBlacklist = 114;
|
||||||
|
|
||||||
// 公会相关
|
// 公会相关
|
||||||
_SMGuildInfo = 120;
|
_SMGuildInfo = 120;
|
||||||
|
@ -205,7 +205,6 @@ message SMListFriend
|
|||||||
repeated MFUser users = 1;
|
repeated MFUser users = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 请求删除好友
|
// 请求删除好友
|
||||||
message CMDeleteFriendShip
|
message CMDeleteFriendShip
|
||||||
{
|
{
|
||||||
@ -219,6 +218,33 @@ message SMDeleteFriendShip
|
|||||||
optional string status = 2;
|
optional string status = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 请求加入黑名单
|
||||||
|
message CMAddBlacklist
|
||||||
|
{
|
||||||
|
optional string target_account_id = 1; // 账号id
|
||||||
|
}
|
||||||
|
|
||||||
|
// 回复加入黑名单
|
||||||
|
message SMAddBlacklist
|
||||||
|
{
|
||||||
|
optional string reason = 1;
|
||||||
|
optional string status = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 请求移除黑名单
|
||||||
|
message CMRemoveBlacklist
|
||||||
|
{
|
||||||
|
optional string target_account_id = 1; // 账号id
|
||||||
|
}
|
||||||
|
|
||||||
|
// 回复移除黑名单
|
||||||
|
message SMRemoveBlacklist
|
||||||
|
{
|
||||||
|
optional string reason = 1;
|
||||||
|
optional string status = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
message MFUser {
|
message MFUser {
|
||||||
optional string account_id = 1;
|
optional string account_id = 1;
|
||||||
optional string username = 2;
|
optional string username = 2;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user