fix: return CustomizationColor only on db rows affected (#4593)
This commit is contained in:
parent
926f6a3c72
commit
81f4c86086
|
@ -344,9 +344,8 @@ func (db *Database) UpdateAccountTimestamp(keyUID string, loginTimestamp int64)
|
|||
return err
|
||||
}
|
||||
|
||||
func (db *Database) UpdateAccountCustomizationColor(keyUID string, color string, clock uint64) error {
|
||||
_, err := db.db.Exec("UPDATE accounts SET customizationColor = ?, customizationColorClock = ? WHERE keyUid = ? AND customizationColorClock < ?", color, clock, keyUID, clock)
|
||||
return err
|
||||
func (db *Database) UpdateAccountCustomizationColor(keyUID string, color string, clock uint64) (sql.Result, error) {
|
||||
return db.db.Exec("UPDATE accounts SET customizationColor = ?, customizationColorClock = ? WHERE keyUid = ? AND customizationColorClock < ?", color, clock, keyUID, clock)
|
||||
}
|
||||
|
||||
func (db *Database) DeleteAccount(keyUID string) error {
|
||||
|
|
|
@ -2415,12 +2415,18 @@ func (m *Messenger) HandleSyncSetting(messageState *ReceivedMessageState, messag
|
|||
}
|
||||
|
||||
func (m *Messenger) HandleSyncAccountCustomizationColor(state *ReceivedMessageState, message *protobuf.SyncAccountCustomizationColor, statusMessage *v1protocol.StatusMessage) error {
|
||||
err := m.multiAccounts.UpdateAccountCustomizationColor(message.GetKeyUid(), message.GetCustomizationColor(), message.GetUpdatedAt())
|
||||
result, err := m.multiAccounts.UpdateAccountCustomizationColor(message.GetKeyUid(), message.GetCustomizationColor(), message.GetUpdatedAt())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
state.Response.CustomizationColor = message.GetCustomizationColor()
|
||||
affected, err := result.RowsAffected()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if affected > 0 {
|
||||
state.Response.CustomizationColor = message.GetCustomizationColor()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue