mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-16 18:41:03 +01:00
Change deletion request code to not filter on DeviceId since the two device ID fields are not actually the same (see the newly added comment)
This commit is contained in:
parent
b4f5f50ef7
commit
0c2774ec15
@ -209,11 +209,11 @@ func (db *DB) DeleteMessagesFromBackend(ctx context.Context, userId string, dele
|
||||
}
|
||||
if message.EndTime != (time.Time{}) && message.EntryId != "" {
|
||||
// Note that we do an OR with date or the ID matching since the ID is not always recorded for older history entries.
|
||||
tx = tx.Or(db.WithContext(ctx).Where("user_id = ? AND device_id = ? AND (date = ? OR encrypted_id = ?)", userId, message.DeviceId, message.EndTime, message.EntryId))
|
||||
tx = tx.Or(db.WithContext(ctx).Where("user_id = ? AND (date = ? OR encrypted_id = ?)", userId, message.EndTime, message.EntryId))
|
||||
} else if message.EndTime != (time.Time{}) && message.EntryId == "" {
|
||||
tx = tx.Or(db.WithContext(ctx).Where("user_id = ? AND device_id = ? AND (date = ?)", userId, message.DeviceId, message.EndTime))
|
||||
tx = tx.Or(db.WithContext(ctx).Where("user_id = ? AND (date = ?)", userId, message.EndTime))
|
||||
} else if message.EndTime == (time.Time{}) && message.EntryId != "" {
|
||||
tx = tx.Or(db.WithContext(ctx).Where("user_id = ? AND device_id = ? AND (encrypted_id = ?)", userId, message.DeviceId, message.EntryId))
|
||||
tx = tx.Or(db.WithContext(ctx).Where("user_id = ? AND (encrypted_id = ?)", userId, message.EntryId))
|
||||
} else {
|
||||
return 0, fmt.Errorf("failed to delete entry because message.EndTime=%#v and message.EntryId=%#v are both empty", message.EndTime, message.EntryId)
|
||||
}
|
||||
|
@ -11,8 +11,9 @@ import (
|
||||
type EncHistoryEntry struct {
|
||||
EncryptedData []byte `json:"enc_data"`
|
||||
Nonce []byte `json:"nonce"`
|
||||
DeviceId string `json:"device_id"`
|
||||
UserId string `json:"user_id"`
|
||||
// DeviceId is the ID of the device that will read this entry from the backend. It is *not* the ID of the device that recorded the command.
|
||||
DeviceId string `json:"device_id"`
|
||||
UserId string `json:"user_id"`
|
||||
// Note that EncHistoryEntry.Date == HistoryEntry.EndTime
|
||||
Date time.Time `json:"time"`
|
||||
// Note that EncHistoryEntry.EncryptedId == HistoryEntry.Id (for entries created after pre-saving support)
|
||||
|
Loading…
Reference in New Issue
Block a user