diff --git a/clients/bot_client.go b/clients/bot_client.go index 6752d2e..0226a18 100644 --- a/clients/bot_client.go +++ b/clients/bot_client.go @@ -22,7 +22,9 @@ type BotClient struct { // InitOlmMachine initializes a BotClient's internal OlmMachine given a client object and a Neb store, // which will be used to store room information. -func (botClient *BotClient) InitOlmMachine(client *mautrix.Client, nebStore *matrix.NEBStore) error { +func (botClient *BotClient) InitOlmMachine(client *mautrix.Client, nebStore *matrix.NEBStore, + cryptoStore crypto.Store) error { + gobStore, err := crypto.NewGobStore("crypto.gob") if err != nil { return err diff --git a/clients/clients.go b/clients/clients.go index f562939..e29e0c5 100644 --- a/clients/clients.go +++ b/clients/clients.go @@ -358,7 +358,7 @@ func (c *Clients) initClient(botClient *BotClient) error { // TODO: Check that the access token is valid for the userID by peforming // a request against the server. - if err = botClient.InitOlmMachine(client, nebStore); err != nil { + if err = botClient.InitOlmMachine(client, nebStore, c.db); err != nil { return err } diff --git a/database/db.go b/database/db.go index 6551650..0d38be8 100644 --- a/database/db.go +++ b/database/db.go @@ -8,6 +8,7 @@ import ( "github.com/matrix-org/go-neb/api" "github.com/matrix-org/go-neb/types" + "maunium.net/go/mautrix/crypto" "maunium.net/go/mautrix/id" ) @@ -327,6 +328,101 @@ func (d *ServiceDB) InsertFromConfig(cfg *api.ConfigFile) error { return nil } +// PutAccount NOP +func (d *ServiceDB) PutAccount(*crypto.OlmAccount) error { + return nil +} + +// GetAccount NOP +func (d *ServiceDB) GetAccount() (*crypto.OlmAccount, error) { + return nil, nil +} + +// HasSession NOP +func (d *ServiceDB) HasSession(id.SenderKey) bool { + return false +} + +// GetSessions NOP +func (d *ServiceDB) GetSessions(id.SenderKey) (crypto.OlmSessionList, error) { + return nil, nil +} + +// GetLatestSession NOP +func (d *ServiceDB) GetLatestSession(id.SenderKey) (*crypto.OlmSession, error) { + return nil, nil +} + +// AddSession NOP +func (d *ServiceDB) AddSession(id.SenderKey, *crypto.OlmSession) error { + return nil +} + +// UpdateSession NOP +func (d *ServiceDB) UpdateSession(id.SenderKey, *crypto.OlmSession) error { + return nil +} + +// PutGroupSession NOP +func (d *ServiceDB) PutGroupSession(id.RoomID, id.SenderKey, id.SessionID, *crypto.InboundGroupSession) error { + return nil +} + +// GetGroupSession NOP +func (d *ServiceDB) GetGroupSession(id.RoomID, id.SenderKey, id.SessionID) (*crypto.InboundGroupSession, error) { + return nil, nil +} + +// AddOutboundGroupSession NOP +func (d *ServiceDB) AddOutboundGroupSession(*crypto.OutboundGroupSession) error { + return nil +} + +// UpdateOutboundGroupSession NOP +func (d *ServiceDB) UpdateOutboundGroupSession(*crypto.OutboundGroupSession) error { + return nil +} + +// GetOutboundGroupSession NOP +func (d *ServiceDB) GetOutboundGroupSession(id.RoomID) (*crypto.OutboundGroupSession, error) { + return nil, nil +} + +// RemoveOutboundGroupSession NOP +func (d *ServiceDB) RemoveOutboundGroupSession(id.RoomID) error { + return nil +} + +// ValidateMessageIndex NOP +func (d *ServiceDB) ValidateMessageIndex(senderKey id.SenderKey, sessionID id.SessionID, eventID id.EventID, index uint, timestamp int64) bool { + return false +} + +// GetDevices NOP +func (d *ServiceDB) GetDevices(id.UserID) (map[id.DeviceID]*crypto.DeviceIdentity, error) { + return nil, nil +} + +// GetDevice NOP +func (d *ServiceDB) GetDevice(id.UserID, id.DeviceID) (*crypto.DeviceIdentity, error) { + return nil, nil +} + +// PutDevices NOP +func (d *ServiceDB) PutDevices(id.UserID, map[id.DeviceID]*crypto.DeviceIdentity) error { + return nil +} + +// FilterTrackedUsers NOP +func (d *ServiceDB) FilterTrackedUsers([]id.UserID) []id.UserID { + return nil +} + +// Flush NOP +func (d *ServiceDB) Flush() error { + return nil +} + func runTransaction(db *sql.DB, fn func(txn *sql.Tx) error) (err error) { txn, err := db.Begin() if err != nil { diff --git a/database/interface.go b/database/interface.go index 6a0532f..c943cdb 100644 --- a/database/interface.go +++ b/database/interface.go @@ -3,11 +3,14 @@ package database import ( "github.com/matrix-org/go-neb/api" "github.com/matrix-org/go-neb/types" + "maunium.net/go/mautrix/crypto" "maunium.net/go/mautrix/id" ) // Storer is the interface which needs to be conformed to in order to persist Go-NEB data type Storer interface { + crypto.Store + StoreMatrixClientConfig(config api.ClientConfig) (oldConfig api.ClientConfig, err error) LoadMatrixClientConfigs() (configs []api.ClientConfig, err error) LoadMatrixClientConfig(userID id.UserID) (config api.ClientConfig, err error) @@ -139,3 +142,98 @@ func (s *NopStorage) StoreBotOptions(opts types.BotOptions) (oldOpts types.BotOp func (s *NopStorage) InsertFromConfig(cfg *api.ConfigFile) error { return nil } + +// PutAccount NOP +func (s *NopStorage) PutAccount(*crypto.OlmAccount) error { + return nil +} + +// GetAccount NOP +func (s *NopStorage) GetAccount() (*crypto.OlmAccount, error) { + return nil, nil +} + +// HasSession NOP +func (s *NopStorage) HasSession(id.SenderKey) bool { + return false +} + +// GetSessions NOP +func (s *NopStorage) GetSessions(id.SenderKey) (crypto.OlmSessionList, error) { + return nil, nil +} + +// GetLatestSession NOP +func (s *NopStorage) GetLatestSession(id.SenderKey) (*crypto.OlmSession, error) { + return nil, nil +} + +// AddSession NOP +func (s *NopStorage) AddSession(id.SenderKey, *crypto.OlmSession) error { + return nil +} + +// UpdateSession NOP +func (s *NopStorage) UpdateSession(id.SenderKey, *crypto.OlmSession) error { + return nil +} + +// PutGroupSession NOP +func (s *NopStorage) PutGroupSession(id.RoomID, id.SenderKey, id.SessionID, *crypto.InboundGroupSession) error { + return nil +} + +// GetGroupSession NOP +func (s *NopStorage) GetGroupSession(id.RoomID, id.SenderKey, id.SessionID) (*crypto.InboundGroupSession, error) { + return nil, nil +} + +// AddOutboundGroupSession NOP +func (s *NopStorage) AddOutboundGroupSession(*crypto.OutboundGroupSession) error { + return nil +} + +// UpdateOutboundGroupSession NOP +func (s *NopStorage) UpdateOutboundGroupSession(*crypto.OutboundGroupSession) error { + return nil +} + +// GetOutboundGroupSession NOP +func (s *NopStorage) GetOutboundGroupSession(id.RoomID) (*crypto.OutboundGroupSession, error) { + return nil, nil +} + +// RemoveOutboundGroupSession NOP +func (s *NopStorage) RemoveOutboundGroupSession(id.RoomID) error { + return nil +} + +// ValidateMessageIndex NOP +func (s *NopStorage) ValidateMessageIndex(senderKey id.SenderKey, sessionID id.SessionID, eventID id.EventID, index uint, timestamp int64) bool { + return false +} + +// GetDevices NOP +func (s *NopStorage) GetDevices(id.UserID) (map[id.DeviceID]*crypto.DeviceIdentity, error) { + return nil, nil +} + +// GetDevice NOP +func (s *NopStorage) GetDevice(id.UserID, id.DeviceID) (*crypto.DeviceIdentity, error) { + return nil, nil +} + +// PutDevices NOP +func (s *NopStorage) PutDevices(id.UserID, map[id.DeviceID]*crypto.DeviceIdentity) error { + return nil +} + +// FilterTrackedUsers NOP +func (s *NopStorage) FilterTrackedUsers([]id.UserID) []id.UserID { + return nil +} + +// Flush NOP +func (s *NopStorage) Flush() error { + return nil +}