Fetch synced_from and synced_to from db to avoid resetting values to zero
This commit is contained in:
parent
612d8918ea
commit
64589fbd1f
|
@ -367,6 +367,8 @@ func (db sqlitePersistence) Chat(chatID string) (*Chat, error) {
|
||||||
lastMessageBytes []byte
|
lastMessageBytes []byte
|
||||||
invitationAdmin sql.NullString
|
invitationAdmin sql.NullString
|
||||||
profile sql.NullString
|
profile sql.NullString
|
||||||
|
syncedFrom sql.NullInt64
|
||||||
|
syncedTo sql.NullInt64
|
||||||
)
|
)
|
||||||
|
|
||||||
err := db.db.QueryRow(`
|
err := db.db.QueryRow(`
|
||||||
|
@ -393,7 +395,9 @@ func (db sqlitePersistence) Chat(chatID string) (*Chat, error) {
|
||||||
joined,
|
joined,
|
||||||
description,
|
description,
|
||||||
highlight,
|
highlight,
|
||||||
received_invitation_admin
|
received_invitation_admin,
|
||||||
|
synced_from,
|
||||||
|
synced_to
|
||||||
FROM chats
|
FROM chats
|
||||||
WHERE id = ?
|
WHERE id = ?
|
||||||
`, chatID).Scan(&chat.ID,
|
`, chatID).Scan(&chat.ID,
|
||||||
|
@ -419,11 +423,19 @@ func (db sqlitePersistence) Chat(chatID string) (*Chat, error) {
|
||||||
&chat.Description,
|
&chat.Description,
|
||||||
&chat.Highlight,
|
&chat.Highlight,
|
||||||
&chat.ReceivedInvitationAdmin,
|
&chat.ReceivedInvitationAdmin,
|
||||||
|
&syncedFrom,
|
||||||
|
&syncedTo,
|
||||||
)
|
)
|
||||||
switch err {
|
switch err {
|
||||||
case sql.ErrNoRows:
|
case sql.ErrNoRows:
|
||||||
return nil, nil
|
return nil, nil
|
||||||
case nil:
|
case nil:
|
||||||
|
if syncedFrom.Valid {
|
||||||
|
chat.SyncedFrom = uint32(syncedFrom.Int64)
|
||||||
|
}
|
||||||
|
if syncedTo.Valid {
|
||||||
|
chat.SyncedTo = uint32(syncedTo.Int64)
|
||||||
|
}
|
||||||
if invitationAdmin.Valid {
|
if invitationAdmin.Valid {
|
||||||
chat.InvitationAdmin = invitationAdmin.String
|
chat.InvitationAdmin = invitationAdmin.String
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue