store

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GroupRecordTypeGroupv1 = 0
	GroupRecordTypeGroupv2 = 1
	GroupJoinStatusJoined  = 0
	GroupJoinStatusInvited = 1
)
View Source
const (
	SessionTypePrivateChat    int32 = 0
	SessionTypeGroupV1        int32 = 1
	SessionTypeGroupV2        int32 = 2
	SessionTypeGroupV2Invited int32 = 3
)

SessionTypes

Variables

View Source
var ActiveSessionID int64

ActiveSessionID represents the currently opend chat

View Source
var AllGroups []*GroupRecord
View Source
var AllSessions []*Session

TODO that hasn't to be in the db controller

View Source
var Groups = map[string]*GroupRecord{}
View Source
var SessionsModel = &Sessions{
	Sess: make([]*Session, 0),
}

Functions

func AddDevice

func AddDevice(url string) error

func AvatarImageProvider

func AvatarImageProvider(id string, width, height int) image.Image

func CopyAttachment

func CopyAttachment(src string) (string, error)

CopyAttachment makes a copy of a file that is in the volatile content hub cache

func DeleteGroup

func DeleteGroup(hexid string) error

DeleteGroup deletes a group from the database

func DeleteMessage

func DeleteMessage(id int64) error

func DeleteSession

func DeleteSession(ID int64) error

DeleteSession deletes a session in the database

func FetchAllGroups

func FetchAllGroups() error

func FindQuotedMessage added in v0.9.0

func FindQuotedMessage(quote *signalservice.DataMessage_Quote) (error, int64)

FindQuotedMessage searches the equivalent message of DataMessage_Quote in our DB and returns the local message id

func GetContactForTel

func GetContactForTel(tel string) *textsecureContacts.Contact

func GetContactForUUID added in v0.9.9

func GetContactForUUID(uuid string) *textsecureContacts.Contact

func GroupUpdateMsg

func GroupUpdateMsg(tels []string, title string) string

func IsEncrypted

func IsEncrypted(filename string) (bool, error)

IsEncrypted returns true, if the database with the given filename is encrypted, and false otherwise. If the database header cannot be read properly an error is returned.

func LoadChats

func LoadChats() error

func LoadGroups added in v0.7.5

func LoadGroups() error

func LoadMessagesFromDB

func LoadMessagesFromDB() error

func MigrateMessagesFromSessionToAnotherSession added in v0.9.7

func MigrateMessagesFromSessionToAnotherSession(oldSession int64, newSession int64) error

MigrateMessagesFromSessionToAnotherSession copies the messages from the old session to the new session and then deletes the oldSession

func RefreshContacts

func RefreshContacts() error

func TelToName

func TelToName(tel string) string

func UpdateMessageRead

func UpdateMessageRead(m *Message) error

func UpdateMessageReceipt added in v0.9.0

func UpdateMessageReceipt(m *Message) error

func UpdateMessageReceiptSent added in v0.8.3

func UpdateMessageReceiptSent(m *Message) error

func UpdateMessageSent

func UpdateMessageSent(m *Message) error

func UpdateMessagesTable_v_0_7_8 added in v0.8.0

func UpdateMessagesTable_v_0_7_8() error

fix v.0.7.8 add SendingError + expireTimer

func UpdateSession

func UpdateSession(s *Session) error

UpdateSession updates a session in the database

func UpdateSessionTable

func UpdateSessionTable() error

func UpdateSessionTable_v_0_7_8 added in v0.8.0

func UpdateSessionTable_v_0_7_8() error

func UpdateSessionTable_v_0_9_0 added in v0.9.0

func UpdateSessionTable_v_0_9_0() error

add support for quoted messages

func UpdateSessionTable_v_0_9_5 added in v0.9.6

func UpdateSessionTable_v_0_9_5() error

add support uuids

func UpdateTimestamps

func UpdateTimestamps()

UpdateTimestamps keeps the timestamps of the last message of each session updated in human readable form.

Types

type Attachment added in v0.8.0

type Attachment struct {
	File     string
	FileName string
	CType    int
}

func SaveAttachment

func SaveAttachment(a *textsecure.Attachment) (Attachment, error)

type Contacts

type Contacts struct {
	Contacts []textsecureContacts.Contact
	Len      int
}
var ContactsModel *Contacts = &Contacts{}

func (*Contacts) GetContact

func (c *Contacts) GetContact(i int) textsecureContacts.Contact

type DataStore

type DataStore struct {
	Dbx *sqlx.DB
}
var DS *DataStore

func NewDataStore

func NewDataStore(dbPath, saltPath, password string) (*DataStore, error)

func NewStorage

func NewStorage(password string) (*DataStore, error)

NewStorage

func (*DataStore) Convert

func (ds *DataStore) Convert(password string) error

func (*DataStore) DBX

func (ds *DataStore) DBX() *sqlx.DB

func (*DataStore) Decrypt

func (ds *DataStore) Decrypt(dbPath string) error

Decrypt database and closes connection

func (*DataStore) DecryptDb

func (ds *DataStore) DecryptDb(password string) bool

func (*DataStore) Encrypt

func (ds *DataStore) Encrypt(dbFile string, password string) error

func (*DataStore) EncryptDb

func (ds *DataStore) EncryptDb(password string) bool

func (*DataStore) ResetDb

func (ds *DataStore) ResetDb()

ResetDb removes the database file and resets the config for encrypted database.

func (*DataStore) SetupDb

func (ds *DataStore) SetupDb(password string) bool

SetupDb tries to decrypt the database and runs the migrations

type GroupRecord

type GroupRecord struct {
	ID         int64
	Uuid       string
	GroupID    string
	Name       string
	Members    string
	Avatar     []byte
	Active     bool
	Type       int
	JoinStatus int
}

func GetGroupById added in v0.7.5

func GetGroupById(hexid string) *GroupRecord

func SaveGroup

func SaveGroup(g *GroupRecord) (*GroupRecord, error)

func UpdateGroup

func UpdateGroup(g *GroupRecord) (*GroupRecord, error)

type LinkedDevices

type LinkedDevices struct {
	LinkedDevices []textsecure.DeviceInfo
	Len           int
}
var LinkedDevicesModel *LinkedDevices = &LinkedDevices{}

func RefreshDevices

func RefreshDevices() (*LinkedDevices, error)

func (*LinkedDevices) DeleteDevice

func (c *LinkedDevices) DeleteDevice() error

func (*LinkedDevices) GetDevice

func (c *LinkedDevices) GetDevice(i int) textsecure.DeviceInfo

func (*LinkedDevices) RefreshDevices

func (c *LinkedDevices) RefreshDevices() error

func (*LinkedDevices) UnlinkDevice

func (c *LinkedDevices) UnlinkDevice(id int) error

type Message

type Message struct {
	ID            int64 `db:"id"`
	SID           int64
	ChatID        string
	Source        string `db:"source"`
	SourceUUID    string `db:"srcUUID"`
	Message       string
	Outgoing      bool
	SentAt        uint64
	ReceivedAt    uint64
	HTime         string
	CType         int
	Attachment    string
	IsSent        bool `db:"issent"`
	IsRead        bool `db:"isread"`
	Flags         int
	ExpireTimer   uint32 `db:"expireTimer"`
	SendingError  bool   `db:"sendingError"`
	Receipt       bool   `db:"receipt"`
	StatusMessage bool   `db:"statusMessage"`
	QuoteID       int64  `db:"quoteId"`
	QuotedMessage *Message
}

func FindOutgoingMessage added in v0.9.0

func FindOutgoingMessage(timestamp uint64) (*Message, error)

FindOutgoingMessage returns a message that is found by it's timestamp

func GetMessageById added in v0.9.0

func GetMessageById(id int64) (*Message, error)

GetMessageById returns a message by it's ID

func SaveMessage

func SaveMessage(m *Message) (error, *Message)

func (*Message) GetName

func (m *Message) GetName() string

type MessageList

type MessageList struct {
	ID       int64
	Session  *Session
	Messages []*Message
}

type Session

type Session struct {
	ID              int64
	UUID            string `db:"uuid"`
	Name            string
	Tel             string
	IsGroup         bool  `db:"isgroup"`
	Type            int32 //describes the type of the session, wether it's a private conversation or groupv1 or groupv2
	Last            string
	Timestamp       uint64
	When            string
	CType           int
	Messages        []*Message
	Unread          int
	Active          bool
	Len             int
	Notification    bool
	ExpireTimer     uint32 `db:"expireTimer"`
	GroupJoinStatus int    `db:"groupJoinStatus"`
}

Session defines how a session looks like

func SaveSession

func SaveSession(s *Session) (*Session, error)

SaveSession saves a newly created session in the database

func (*Session) Add

func (s *Session) Add(text string, source string, file []Attachment, mimetype string, outgoing bool, sessionID int64) *Message

Add message to a session

func (*Session) GetMessages

func (s *Session) GetMessages(i int) *Message

func (*Session) MarkRead

func (s *Session) MarkRead()

MarkRead marks a session as read

func (*Session) ToggleSessionNotification added in v1.0.9

func (s *Session) ToggleSessionNotification()

ToggleSessionNotification turns on/off notification for a session

type Sessions

type Sessions struct {
	Sess       []*Session
	ActiveChat string
	Len        int
	Type       string
}

func (*Sessions) CreateSessionForE164 added in v0.9.6

func (s *Sessions) CreateSessionForE164(tel string, UUID string) *Session

CreateSessionForE164 creates a new Session for the phone number

func (*Sessions) CreateSessionForGroup added in v0.9.6

func (s *Sessions) CreateSessionForGroup(group *textsecure.Group) *Session

CreateSessionForGroup creates a session for a group

func (*Sessions) CreateSessionForGroupV2 added in v1.0.0

func (s *Sessions) CreateSessionForGroupV2(group *groupsv2.GroupV2) *Session

CreateSessionForGroupV2 creates a session for a group

func (*Sessions) CreateSessionForUUID added in v0.9.9

func (s *Sessions) CreateSessionForUUID(UUID string) *Session

func (*Sessions) Get

func (s *Sessions) Get(id int64) (*Session, error)

Get returns the session by it's id

func (*Sessions) GetAllSessionsByE164 added in v0.9.7

func (s *Sessions) GetAllSessionsByE164(tel string) []*Session

GetAllSessionsByE164 returns multiple sessions when they are duplicated

func (*Sessions) GetByE164 added in v0.9.6

func (s *Sessions) GetByE164(tel string) *Session

GetByE164 returns the session by the telephone number and creates it if it doesn't exists

func (*Sessions) GetByUUID added in v0.9.6

func (s *Sessions) GetByUUID(UUID string) (*Session, error)

GetByUUID returns the session by the ChatUUID

func (*Sessions) GetIndex

func (s *Sessions) GetIndex(ID int64) int

GetIndex returns the current index of session ID

func (*Sessions) GetMessageList

func (s *Sessions) GetMessageList(ID int64) (error, *MessageList)

GetMessageList returns the message list for the session id

func (*Sessions) GetMoreMessageList

func (s *Sessions) GetMoreMessageList(ID int64, lastID string) (error, *MessageList)

GetMoreMessageList loads more messages from before the lastID

func (*Sessions) GetSession

func (s *Sessions) GetSession(i int64) *Session

GetSession at a certain index

func (*Sessions) UpdateSessionNames

func (s *Sessions) UpdateSessionNames()

UpdateSessionNames updates the non groups with the name from the phone book

Jump to

Keyboard shortcuts

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