mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-04 19:17:37 +08:00
fix: possible id == 0
This commit is contained in:
parent
c84d583235
commit
5c78174d1c
@ -73,6 +73,7 @@ func (s *database) GetGroupMessageByGlobalID(id int32) (*db.StoredGroupMessage,
|
||||
ret.GroupCode = grpmsg.GroupCode
|
||||
ret.AnonymousID = grpmsg.AnonymousID
|
||||
_ = json.Unmarshal(utils.S2B(grpmsg.Content), &ret.Content)
|
||||
if grpmsg.AttributeID != 0 {
|
||||
var attr StoredMessageAttribute
|
||||
s.RLock()
|
||||
err = s.db.Find(Sqlite3MessageAttributeTableName, &attr, "WHERE ID="+strconv.FormatInt(grpmsg.AttributeID, 10))
|
||||
@ -86,6 +87,8 @@ func (s *database) GetGroupMessageByGlobalID(id int32) (*db.StoredGroupMessage,
|
||||
Timestamp: attr.Timestamp,
|
||||
}
|
||||
}
|
||||
}
|
||||
if grpmsg.QuotedInfoID != 0 {
|
||||
var quoinf QuotedInfo
|
||||
s.RLock()
|
||||
err = s.db.Find(Sqlite3QuotedInfoTableName, &quoinf, "WHERE ID="+strconv.FormatInt(grpmsg.QuotedInfoID, 10))
|
||||
@ -97,6 +100,7 @@ func (s *database) GetGroupMessageByGlobalID(id int32) (*db.StoredGroupMessage,
|
||||
}
|
||||
_ = json.Unmarshal(utils.S2B(quoinf.QuotedContent), &ret.QuotedInfo.QuotedContent)
|
||||
}
|
||||
}
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
@ -115,6 +119,7 @@ func (s *database) GetPrivateMessageByGlobalID(id int32) (*db.StoredPrivateMessa
|
||||
ret.SessionUin = privmsg.SessionUin
|
||||
ret.TargetUin = privmsg.TargetUin
|
||||
_ = json.Unmarshal(utils.S2B(privmsg.Content), &ret.Content)
|
||||
if privmsg.AttributeID != 0 {
|
||||
var attr StoredMessageAttribute
|
||||
s.RLock()
|
||||
err = s.db.Find(Sqlite3MessageAttributeTableName, &attr, "WHERE ID="+strconv.FormatInt(privmsg.AttributeID, 10))
|
||||
@ -128,6 +133,8 @@ func (s *database) GetPrivateMessageByGlobalID(id int32) (*db.StoredPrivateMessa
|
||||
Timestamp: attr.Timestamp,
|
||||
}
|
||||
}
|
||||
}
|
||||
if privmsg.QuotedInfoID != 0 {
|
||||
var quoinf QuotedInfo
|
||||
s.RLock()
|
||||
err = s.db.Find(Sqlite3QuotedInfoTableName, &quoinf, "WHERE ID="+strconv.FormatInt(privmsg.QuotedInfoID, 10))
|
||||
@ -139,6 +146,7 @@ func (s *database) GetPrivateMessageByGlobalID(id int32) (*db.StoredPrivateMessa
|
||||
}
|
||||
_ = json.Unmarshal(utils.S2B(quoinf.QuotedContent), &ret.QuotedInfo.QuotedContent)
|
||||
}
|
||||
}
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
@ -155,6 +163,7 @@ func (s *database) GetGuildChannelMessageByID(id string) (*db.StoredGuildChannel
|
||||
ret.GuildID = uint64(guildmsg.GuildID)
|
||||
ret.ChannelID = uint64(guildmsg.ChannelID)
|
||||
_ = json.Unmarshal(utils.S2B(guildmsg.Content), &ret.Content)
|
||||
if guildmsg.AttributeID != 0 {
|
||||
var attr StoredGuildMessageAttribute
|
||||
s.RLock()
|
||||
err = s.db.Find(Sqlite3GuildMessageAttributeTableName, &attr, "WHERE ID="+strconv.FormatInt(guildmsg.AttributeID, 10))
|
||||
@ -168,6 +177,8 @@ func (s *database) GetGuildChannelMessageByID(id string) (*db.StoredGuildChannel
|
||||
Timestamp: attr.Timestamp,
|
||||
}
|
||||
}
|
||||
}
|
||||
if guildmsg.QuotedInfoID != 0 {
|
||||
var quoinf QuotedInfo
|
||||
s.RLock()
|
||||
err = s.db.Find(Sqlite3QuotedInfoTableName, &quoinf, "WHERE ID="+strconv.FormatInt(guildmsg.QuotedInfoID, 10))
|
||||
@ -179,6 +190,7 @@ func (s *database) GetGuildChannelMessageByID(id string) (*db.StoredGuildChannel
|
||||
}
|
||||
_ = json.Unmarshal(utils.S2B(quoinf.QuotedContent), &ret.QuotedInfo.QuotedContent)
|
||||
}
|
||||
}
|
||||
return &ret, nil
|
||||
}
|
||||
|
||||
@ -200,6 +212,9 @@ func (s *database) InsertGroupMessage(msg *db.StoredGroupMessage) error {
|
||||
}))
|
||||
h.Write(utils.S2B(msg.Attribute.SenderName))
|
||||
id := int64(h.Sum64())
|
||||
if id == 0 {
|
||||
id++
|
||||
}
|
||||
s.Lock()
|
||||
err := s.db.Insert(Sqlite3MessageAttributeTableName, &StoredMessageAttribute{
|
||||
ID: id,
|
||||
@ -226,6 +241,9 @@ func (s *database) InsertGroupMessage(msg *db.StoredGroupMessage) error {
|
||||
}
|
||||
h.Write(content)
|
||||
id := int64(h.Sum64())
|
||||
if id == 0 {
|
||||
id++
|
||||
}
|
||||
s.Lock()
|
||||
err = s.db.Insert(Sqlite3QuotedInfoTableName, &QuotedInfo{
|
||||
ID: id,
|
||||
@ -270,6 +288,9 @@ func (s *database) InsertPrivateMessage(msg *db.StoredPrivateMessage) error {
|
||||
}))
|
||||
h.Write(utils.S2B(msg.Attribute.SenderName))
|
||||
id := int64(h.Sum64())
|
||||
if id == 0 {
|
||||
id++
|
||||
}
|
||||
s.Lock()
|
||||
err := s.db.Insert(Sqlite3MessageAttributeTableName, &StoredMessageAttribute{
|
||||
ID: id,
|
||||
@ -296,6 +317,9 @@ func (s *database) InsertPrivateMessage(msg *db.StoredPrivateMessage) error {
|
||||
}
|
||||
h.Write(content)
|
||||
id := int64(h.Sum64())
|
||||
if id == 0 {
|
||||
id++
|
||||
}
|
||||
s.Lock()
|
||||
err = s.db.Insert(Sqlite3QuotedInfoTableName, &QuotedInfo{
|
||||
ID: id,
|
||||
@ -338,6 +362,9 @@ func (s *database) InsertGuildChannelMessage(msg *db.StoredGuildChannelMessage)
|
||||
}))
|
||||
h.Write(utils.S2B(msg.Attribute.SenderName))
|
||||
id := int64(h.Sum64())
|
||||
if id == 0 {
|
||||
id++
|
||||
}
|
||||
s.Lock()
|
||||
err := s.db.Insert(Sqlite3MessageAttributeTableName, &StoredGuildMessageAttribute{
|
||||
ID: id,
|
||||
@ -364,6 +391,9 @@ func (s *database) InsertGuildChannelMessage(msg *db.StoredGuildChannelMessage)
|
||||
}
|
||||
h.Write(content)
|
||||
id := int64(h.Sum64())
|
||||
if id == 0 {
|
||||
id++
|
||||
}
|
||||
s.Lock()
|
||||
err = s.db.Insert(Sqlite3QuotedInfoTableName, &QuotedInfo{
|
||||
ID: id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user