test
This commit is contained in:
parent
bc02282bbe
commit
c4ac28ed64
16
client.go
16
client.go
@ -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 {
|
||||
|
2
def.go
2
def.go
@ -72,7 +72,7 @@ type ChatWarsMessageReportAck struct {
|
||||
}
|
||||
|
||||
type ChatWarsMessageMeAck struct {
|
||||
ObjID64 int64 `json:"obj_id"`
|
||||
Msg *ChatWarsMessage `json:"msg"`
|
||||
UserID64 int64 `json:"user_id"`
|
||||
GuildID64 int64 `json:"guild_id"`
|
||||
State string `json:"state"`
|
||||
|
20
obj.go
20
obj.go
@ -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
|
||||
}
|
||||
|
@ -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)")
|
||||
|
Loading…
Reference in New Issue
Block a user