mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-15 22:56:48 +00:00
GODT-1657: Stable sync (still needs more tests)
This commit is contained in:
@ -17,6 +17,11 @@ func (user *User) Username() string {
|
||||
return user.vault.getUser(user.userID).Username
|
||||
}
|
||||
|
||||
// GluonKey returns the key needed to decrypt the user's gluon database.
|
||||
func (user *User) GluonKey() []byte {
|
||||
return user.vault.getUser(user.userID).GluonKey
|
||||
}
|
||||
|
||||
func (user *User) GetGluonIDs() map[string]string {
|
||||
return user.vault.getUser(user.userID).GluonIDs
|
||||
}
|
||||
@ -42,44 +47,33 @@ func (user *User) SetUIDValidity(addrID string, validity imap.UID) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (user *User) GluonKey() []byte {
|
||||
return user.vault.getUser(user.userID).GluonKey
|
||||
}
|
||||
|
||||
// AddressMode returns the user's address mode.
|
||||
func (user *User) AddressMode() AddressMode {
|
||||
return user.vault.getUser(user.userID).AddressMode
|
||||
}
|
||||
|
||||
// SetAddressMode sets the address mode for the given user.
|
||||
func (user *User) SetAddressMode(mode AddressMode) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
data.AddressMode = mode
|
||||
})
|
||||
}
|
||||
|
||||
// BridgePass returns the user's bridge password (unencoded).
|
||||
func (user *User) BridgePass() []byte {
|
||||
return user.vault.getUser(user.userID).BridgePass
|
||||
}
|
||||
|
||||
// AuthUID returns the user's auth UID.
|
||||
func (user *User) AuthUID() string {
|
||||
return user.vault.getUser(user.userID).AuthUID
|
||||
}
|
||||
|
||||
// AuthRef returns the user's auth refresh token.
|
||||
func (user *User) AuthRef() string {
|
||||
return user.vault.getUser(user.userID).AuthRef
|
||||
}
|
||||
|
||||
func (user *User) KeyPass() []byte {
|
||||
return user.vault.getUser(user.userID).KeyPass
|
||||
}
|
||||
|
||||
func (user *User) EventID() string {
|
||||
return user.vault.getUser(user.userID).EventID
|
||||
}
|
||||
|
||||
func (user *User) HasSync() bool {
|
||||
return user.vault.getUser(user.userID).HasSync
|
||||
}
|
||||
|
||||
func (user *User) SetKeyPass(keyPass []byte) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
data.KeyPass = keyPass
|
||||
})
|
||||
}
|
||||
|
||||
// SetAuth sets the auth secrets for the given user.
|
||||
func (user *User) SetAuth(authUID, authRef string) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
@ -88,23 +82,59 @@ func (user *User) SetAuth(authUID, authRef string) error {
|
||||
})
|
||||
}
|
||||
|
||||
// SetAddressMode sets the address mode for the given user.
|
||||
func (user *User) SetAddressMode(mode AddressMode) error {
|
||||
// KeyPass returns the user's (salted) key password.
|
||||
func (user *User) KeyPass() []byte {
|
||||
return user.vault.getUser(user.userID).KeyPass
|
||||
}
|
||||
|
||||
// SetKeyPass sets the user's (salted) key password.
|
||||
func (user *User) SetKeyPass(keyPass []byte) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
data.AddressMode = mode
|
||||
data.KeyPass = keyPass
|
||||
})
|
||||
}
|
||||
|
||||
// SyncStatus return's the user's sync status.
|
||||
func (user *User) SyncStatus() SyncStatus {
|
||||
return user.vault.getUser(user.userID).SyncStatus
|
||||
}
|
||||
|
||||
// SetHasLabels sets whether the user's labels have been synced.
|
||||
func (user *User) SetHasLabels(hasLabels bool) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
data.SyncStatus.HasLabels = hasLabels
|
||||
})
|
||||
}
|
||||
|
||||
// SetHasMessages sets whether the user's messages have been synced.
|
||||
func (user *User) SetHasMessages(hasMessages bool) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
data.SyncStatus.HasMessages = hasMessages
|
||||
})
|
||||
}
|
||||
|
||||
// SetLastMessageID sets the last synced message ID for the given user.
|
||||
func (user *User) SetLastMessageID(messageID string) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
data.SyncStatus.LastMessageID = messageID
|
||||
})
|
||||
}
|
||||
|
||||
// ClearSyncStatus clears the user's sync status.
|
||||
func (user *User) ClearSyncStatus() error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
data.SyncStatus = SyncStatus{}
|
||||
})
|
||||
}
|
||||
|
||||
// EventID returns the last processed event ID of the user.
|
||||
func (user *User) EventID() string {
|
||||
return user.vault.getUser(user.userID).EventID
|
||||
}
|
||||
|
||||
// SetEventID sets the event ID for the given user.
|
||||
func (user *User) SetEventID(eventID string) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
data.EventID = eventID
|
||||
})
|
||||
}
|
||||
|
||||
// SetSync sets the sync state for the given user.
|
||||
func (user *User) SetSync(hasSync bool) error {
|
||||
return user.vault.modUser(user.userID, func(data *UserData) {
|
||||
data.HasSync = hasSync
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user