This commit is contained in:
shoopea 2019-05-30 14:08:39 +08:00
parent bc02282bbe
commit c4ac28ed64
4 changed files with 15 additions and 31 deletions

View File

@ -17,30 +17,26 @@ func clientSendCWMsg(userID64 int64, s string) {
func clientMsgMeAck(m *ChatWarsMessageMeAck) {
log.Printf("clientMsgMeAck %d\n", m.UserID64)
if _, ok := clientsQueue[m.UserID64]; ok {
if _, ok := clientsQueue[m.Msg.UserID64]; ok {
log.Printf("Client in clientsQueue\n")
t, err := getObjMsgDate(m.ObjID64)
logOnError(err, "clientMsgMe : getObjMsgDate")
if c, ok := clientsCW[m.UserID64]; ok {
if c.LastUpdate.Before(t) {
if c.LastUpdate.Before(m.Msg.Date) {
c.GuildID64 = m.GuildID64
c.State = m.State
c.LastUpdate = t
c.LastUpdate = m.Msg.Date
if cacheObjGuild[``].ObjID64 != m.GuildID64 && strings.Compare(c.Role, ``) == 0 {
clientSendCWMsg(m.UserID64, "/g_roles")
clientSendCWMsg(m.Msg.UserID64, "/g_roles")
}
}
} else {
c := ChatWarsClient{
GuildID64: m.GuildID64,
State: m.State,
LastUpdate: t,
LastUpdate: m.Msg.Date,
}
clientsCW[m.UserID64] = &c
if cacheObjGuild[``].ObjID64 != m.GuildID64 {
clientSendCWMsg(m.UserID64, "/g_roles")
} else {
clientSendCWMsg(m.UserID64, "/g_roles")
clientSendCWMsg(m.Msg.UserID64, "/g_roles")
}
}
} else {

8
def.go
View File

@ -72,10 +72,10 @@ type ChatWarsMessageReportAck struct {
}
type ChatWarsMessageMeAck struct {
ObjID64 int64 `json:"obj_id"`
UserID64 int64 `json:"user_id"`
GuildID64 int64 `json:"guild_id"`
State string `json:"state"`
Msg *ChatWarsMessage `json:"msg"`
UserID64 int64 `json:"user_id"`
GuildID64 int64 `json:"guild_id"`
State string `json:"state"`
}
type ChatWarsMessageGoQuestAck struct {

20
obj.go
View File

@ -377,22 +377,10 @@ func loadObjUser() error {
}
func getObjMsgDate(objID64 int64) (time.Time, error) {
var t time.Time
rows, err := db.Query(`SELECT om.date FROM obj_msg om WHERE om.obj_id = ?;`, objID64)
logOnError(err, "getObjMsgDate : select")
m, err := getMsg(objID64)
if err != nil {
return time.Now(), nil
return time.Now(), err
} else {
return m.Date, nil
}
defer rows.Close()
for rows.Next() {
err := rows.Scan(&t)
logOnError(err, "getObjMsgDate : row")
if err != nil {
return time.Now(), nil
}
}
return t, nil
}

View File

@ -143,7 +143,7 @@ func SQLIdentifyMsgWorker(id int, objIds <-chan int64) {
case objSubTypeMessageMeAck:
cwm, err := parseSubTypeMessageMeAck(m, r)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : Parsing objSubTypeMessageMeAck.")
cwm.ObjID64 = objId
cwm.Msg = m
clientMsgMeAck(cwm)
err = setObjSubTypeId(objId, objSubTypeMessageMeAck)
logOnError(err, "SQLIdentifyMsgWorker["+strconv.Itoa(id)+"] : setObjSubTypeId(MeAck)")