Add 注释
This commit is contained in:
parent
8e225ed25e
commit
e2cc00bdd7
@ -18,11 +18,11 @@ const (
|
||||
|
||||
type FriendsMgr struct {
|
||||
cs.MsgHandlerImpl
|
||||
users map[string]*User
|
||||
searchCaches map[string]SearchCache
|
||||
friendships map[string][]*Friendship
|
||||
pendingReqs map[string]map[string]bool
|
||||
blockedUser map[string][]string
|
||||
users map[string]*User // AccountId -> 用户
|
||||
searchCaches map[string]SearchCache // SearchKeyword -> 好友搜索结果 []*User
|
||||
friendships map[string][]*Friendship // AccountId -> 好友关系列表 []*Friendship
|
||||
pendingReqs map[string]map[string]bool // AccountId -> 等待请求列表 map[targetAccount]true
|
||||
blockedUser map[string][]string // AccountId -> 黑名单列表 []AccountIds
|
||||
}
|
||||
|
||||
type SearchCache struct {
|
||||
@ -75,7 +75,7 @@ func (fm *FriendsMgr) unInit() {
|
||||
// 2. Struct Data Persist to DB
|
||||
}
|
||||
|
||||
func (fm *FriendsMgr) searchUserByAccountId(accountId string) *User {
|
||||
func (fm *FriendsMgr) searchByAccountId(accountId string) *User {
|
||||
if user, ok := fm.users[accountId]; ok {
|
||||
return user
|
||||
}
|
||||
@ -94,7 +94,7 @@ func (fm *FriendsMgr) searchUsers(keyword string) []*User {
|
||||
}
|
||||
|
||||
maxUsers := 20
|
||||
var listFriend []*User
|
||||
listFriend := make([]*User, 0, maxUsers)
|
||||
lowercaseQuery := strings.ToLower(keyword)
|
||||
for _, u := range fm.users {
|
||||
if strings.Contains(strings.ToLower(u.Username), lowercaseQuery) {
|
||||
@ -422,11 +422,14 @@ func PrintUsers(str string, userList []*User) {
|
||||
}
|
||||
}
|
||||
|
||||
func (fm *FriendsMgr) findBlockedUserIndex(AccountId1, AccountId2 string) int {
|
||||
for i, blockedAccountId := range fm.blockedUser[AccountId1] {
|
||||
if blockedAccountId == AccountId2 {
|
||||
return i
|
||||
func (fm *FriendsMgr) findBlockedUserIndex(Account1Id, Account2Id string) int {
|
||||
if fm.blockedUser[Account1Id] != nil {
|
||||
for i, blockedAccountId := range fm.blockedUser[Account1Id] {
|
||||
if blockedAccountId == Account2Id {
|
||||
return i
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user