2023-09-20 03:05:44 +02:00
|
|
|
package messages
|
|
|
|
|
|
|
|
import "encoding/json"
|
|
|
|
|
|
|
|
type LockVaultRequest struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type UnlockVaultRequest struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type UpdateVaultPINRequest struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type WipeVaultRequest struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type GetVaultPINRequest struct {
|
|
|
|
}
|
|
|
|
|
2023-12-22 10:44:49 +01:00
|
|
|
type VaultStatusRequest struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type VaultStatusResponse struct {
|
2023-12-26 21:52:49 +01:00
|
|
|
Locked bool
|
2023-12-28 01:09:49 +01:00
|
|
|
LoggedIn bool
|
|
|
|
PinSet bool
|
2023-12-26 21:52:49 +01:00
|
|
|
NumberOfLogins int
|
|
|
|
NumberOfNotes int
|
|
|
|
LastSynced int64
|
2024-06-24 02:07:08 +02:00
|
|
|
WebsocketConnected bool
|
2023-12-22 10:44:49 +01:00
|
|
|
}
|
|
|
|
|
2023-09-20 03:05:44 +02:00
|
|
|
func init() {
|
|
|
|
registerPayloadParser(func(payload []byte) (interface{}, error) {
|
|
|
|
var req LockVaultRequest
|
|
|
|
err := json.Unmarshal(payload, &req)
|
|
|
|
if err != nil {
|
|
|
|
panic("Unmarshal: " + err.Error())
|
|
|
|
}
|
|
|
|
return req, nil
|
|
|
|
}, LockVaultRequest{})
|
|
|
|
|
|
|
|
registerPayloadParser(func(payload []byte) (interface{}, error) {
|
|
|
|
var req UnlockVaultRequest
|
|
|
|
err := json.Unmarshal(payload, &req)
|
|
|
|
if err != nil {
|
|
|
|
panic("Unmarshal: " + err.Error())
|
|
|
|
}
|
|
|
|
return req, nil
|
|
|
|
}, UnlockVaultRequest{})
|
|
|
|
|
|
|
|
registerPayloadParser(func(payload []byte) (interface{}, error) {
|
|
|
|
var req UpdateVaultPINRequest
|
|
|
|
err := json.Unmarshal(payload, &req)
|
|
|
|
if err != nil {
|
|
|
|
panic("Unmarshal: " + err.Error())
|
|
|
|
}
|
|
|
|
return req, nil
|
|
|
|
}, UpdateVaultPINRequest{})
|
|
|
|
|
|
|
|
registerPayloadParser(func(payload []byte) (interface{}, error) {
|
|
|
|
var req WipeVaultRequest
|
|
|
|
err := json.Unmarshal(payload, &req)
|
|
|
|
if err != nil {
|
|
|
|
panic("Unmarshal: " + err.Error())
|
|
|
|
}
|
|
|
|
return req, nil
|
|
|
|
}, WipeVaultRequest{})
|
|
|
|
|
|
|
|
registerPayloadParser(func(payload []byte) (interface{}, error) {
|
|
|
|
var req GetVaultPINRequest
|
|
|
|
err := json.Unmarshal(payload, &req)
|
|
|
|
if err != nil {
|
|
|
|
panic("Unmarshal: " + err.Error())
|
|
|
|
}
|
|
|
|
return req, nil
|
|
|
|
}, GetVaultPINRequest{})
|
2023-12-22 10:44:49 +01:00
|
|
|
|
|
|
|
registerPayloadParser(func(payload []byte) (interface{}, error) {
|
|
|
|
var req VaultStatusRequest
|
|
|
|
err := json.Unmarshal(payload, &req)
|
|
|
|
if err != nil {
|
|
|
|
panic("Unmarshal: " + err.Error())
|
|
|
|
}
|
|
|
|
return req, nil
|
|
|
|
}, VaultStatusRequest{})
|
|
|
|
|
|
|
|
registerPayloadParser(func(payload []byte) (interface{}, error) {
|
|
|
|
var req VaultStatusResponse
|
|
|
|
err := json.Unmarshal(payload, &req)
|
|
|
|
if err != nil {
|
|
|
|
panic("Unmarshal: " + err.Error())
|
|
|
|
}
|
|
|
|
return req, nil
|
|
|
|
}, VaultStatusResponse{})
|
2023-09-20 03:05:44 +02:00
|
|
|
}
|