mongostore

package
v1.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2024 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLength = errors.New("invalid byte array length")
)

Functions

This section is empty.

Types

type Container

type Container struct {
	// contains filtered or unexported fields
}

Container wraps a MongoDB collection for managing waSocket sessions.

func New

func New(uri, dbName, collectionName string, log waLog.Logger) (*Container, error)

New creates a new Container for MongoDB.

func (*Container) Close

func (c *Container) Close() error

Close is a no-op for MongoDB, but can be used to close the client connection if needed.

func (*Container) DeleteDevice

func (c *Container) DeleteDevice(device *store.Device) error

DeleteDevice deletes the given device from MongoDB.

func (*Container) GetAllDevices

func (c *Container) GetAllDevices() ([]*store.Device, error)

GetAllDevices finds all the devices in the MongoDB collection.

func (*Container) GetDevice

func (c *Container) GetDevice(jid types.JID) (*store.Device, error)

GetDevice finds a device by its JID in MongoDB.

func (*Container) GetFirstDevice

func (c *Container) GetFirstDevice() (*store.Device, error)

GetFirstDevice returns the first device found or creates a new one if none exist.

func (*Container) NewDevice

func (c *Container) NewDevice() *store.Device

NewDevice creates a new device instance.

func (*Container) PutDevice

func (c *Container) PutDevice(device *store.Device) error

PutDevice stores the given device in MongoDB.

type MongoStore

type MongoStore struct {
	JID string
	// contains filtered or unexported fields
}

func NewMongoStore

func NewMongoStore(client *mongo.Client, dbName, jid string) *MongoStore

func (*MongoStore) DeleteIdentity

func (s *MongoStore) DeleteIdentity(address string) error

func (*MongoStore) GenOnePreKey

func (s *MongoStore) GenOnePreKey() (*keys.PreKey, error)

func (*MongoStore) GetSenderKey

func (s *MongoStore) GetSenderKey(group, user string) ([]byte, error)

func (*MongoStore) GetSession

func (s *MongoStore) GetSession(address string) ([]byte, error)

func (*MongoStore) IsTrustedIdentity

func (s *MongoStore) IsTrustedIdentity(address string, key [32]byte) (bool, error)

func (*MongoStore) PutIdentity

func (s *MongoStore) PutIdentity(address string, key [32]byte) error

func (*MongoStore) PutSenderKey

func (s *MongoStore) PutSenderKey(group, user string, key []byte) error

func (*MongoStore) PutSession

func (s *MongoStore) PutSession(address string, session []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL