From 63896afdb6621cc4e38d166bd1f0e98508f61eae Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 19 Apr 2024 11:09:59 +0800 Subject: [PATCH] 1 --- server/imserver/common/types.go | 2 +- server/imserver/guild/guildmgr.go | 12 ++++++------ server/imserver/player/player.go | 20 +++++++++++++++++++- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/server/imserver/common/types.go b/server/imserver/common/types.go index aa6fbce5..7b98e92c 100644 --- a/server/imserver/common/types.go +++ b/server/imserver/common/types.go @@ -88,7 +88,7 @@ type GuildMgr interface { AsyncCreateGuild(string, string, int32, string, func(int32, string, string)) AsyncGetApplyList(int64, string, func(int32, string, int64, []string)) - AsyncApplyJoin(string, string, func(int32, string)) + AsyncApplyJoin(string, string, func(int32, string, Guild)) AsyncAcceptApply(string, string, func(int32, string, string, string)) AsyncRejectApply(string, string, func(int32, string)) AsyncGetGuildRank(int32, func(int32, string, []string)) diff --git a/server/imserver/guild/guildmgr.go b/server/imserver/guild/guildmgr.go index 438ea75b..0ae78005 100644 --- a/server/imserver/guild/guildmgr.go +++ b/server/imserver/guild/guildmgr.go @@ -321,14 +321,14 @@ func (this *guildMgr) AsyncGetApplyList(lastIdx int64, accountId string, }) } -func (this *guildMgr) AsyncApplyJoin(accountId string, guildId string, cb func(int32, string)) { +func (this *guildMgr) AsyncApplyJoin(accountId string, guildId string, cb func(int32, string, common.Guild)) { if this.internalGetGuildByAccountId(accountId) != nil { - cb(0, "") + cb(0, "", nil) return } guild := this.internalGetGuildByGuildId(guildId) if guild == nil { - cb(0, "") + cb(0, "", nil) return } nowTime := f5.GetApp().GetNowSeconds() @@ -341,19 +341,19 @@ func (this *guildMgr) AsyncApplyJoin(accountId string, guildId string, cb func(i model.GuildApply.SetStatus(guild.guildId, accountId, constant.GUILD_APPLY_STATUS_ACCEPT, func (err error, lastInsertId int64, rowsAffected int64) { GetDbLogMgr().GuildAccpetApply(guild.guildId, accountId, accountId) - cb(0, "") return }) + cb(0, "", guild) } else { model.GuildApply.Force( guildId, accountId, func (err error, lastInsertId int64, rowsAffected int64) { if err != nil { - cb(500, "server internal error") + cb(500, "server internal error", nil) return } - cb(0, "") + cb(0, "", nil) }) } } diff --git a/server/imserver/player/player.go b/server/imserver/player/player.go index bdbc610d..6467c07c 100644 --- a/server/imserver/player/player.go +++ b/server/imserver/player/player.go @@ -506,12 +506,30 @@ func (this *player) CMApplyToGuild(hdr *f5.MsgHdr, msg *cs.CMApplyToGuild) { GetGuildMgr().AsyncApplyJoin( this.GetAccountId(), q5.ToString(msg.GetGuildId()), - func (errCode int32, errMsg string) { + func (errCode int32, errMsg string, okGuild common.Guild) { if errCode != 0 { this.SendMsg(rspMsg.Err(errCode, errMsg)) return } this.SendMsg(rspMsg) + if okGuild != nil { + pbGuilds := []*cs.MFGuildMember{} + GetCacheMgr().AsyncGetUsersAndFillMFGuildMember( + []string{ + this.GetAccountId(), + }, + &pbGuilds, + func (errCode int32, errMsg string) { + if errCode == 0 && len(pbGuilds) > 0 { + notifyMsg := new(cs.SMApproveJoinGuildNotify) + notifyMsg.GuildId = proto.Int64(q5.ToInt64(okGuild.GetGuildId())) + notifyMsg.Name = proto.String(okGuild.GetGuildName()) + notifyMsg.AccountId = proto.String(pbGuilds[0].GetAccountId()) + notifyMsg.Username = proto.String(pbGuilds[0].GetUsername()) + GetGuildMgr().NotifyGuildMsg(q5.ToString(msg.GetGuildId()), notifyMsg) + } + }) + } return }) }