forked from Silverfish/proton-bridge
refactor: remove unexported fetchMessage
This commit is contained in:
@ -430,7 +430,7 @@ func (loop *eventLoop) processMessages(eventLog *logrus.Entry, messages []*pmapi
|
|||||||
|
|
||||||
msgLog.WithError(err).Warning("Message was not present in DB. Trying fetch...")
|
msgLog.WithError(err).Warning("Message was not present in DB. Trying fetch...")
|
||||||
|
|
||||||
if msg, err = loop.store.fetchMessage(message.ID); err != nil {
|
if msg, err = loop.apiClient.GetMessage(message.ID); err != nil {
|
||||||
if err == pmapi.ErrNoSuchMessage {
|
if err == pmapi.ErrNoSuchMessage {
|
||||||
msgLog.WithError(err).Warn("Skipping message update because message exists neither in local DB nor on API")
|
msgLog.WithError(err).Warn("Skipping message update because message exists neither in local DB nor on API")
|
||||||
err = nil
|
err = nil
|
||||||
|
|||||||
@ -37,7 +37,7 @@ func (storeMailbox *Mailbox) GetMessage(apiID string) (*Message, error) {
|
|||||||
// FetchMessage fetches the message with the given `apiID`, stores it in the database, and returns a new store message
|
// FetchMessage fetches the message with the given `apiID`, stores it in the database, and returns a new store message
|
||||||
// wrapping it.
|
// wrapping it.
|
||||||
func (storeMailbox *Mailbox) FetchMessage(apiID string) (*Message, error) {
|
func (storeMailbox *Mailbox) FetchMessage(apiID string) (*Message, error) {
|
||||||
msg, err := storeMailbox.store.fetchMessage(apiID)
|
msg, err := storeMailbox.api().GetMessage(apiID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@ -142,14 +142,6 @@ func (store *Store) getMessageFromDB(apiID string) (msg *pmapi.Message, err erro
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetchMessage returns pmapi struct of message by API ID. If the requested
|
|
||||||
// message is not in the database, it will try to fetch it from the server.
|
|
||||||
// NOTE: Do not update the database here to prevent issues (extreme edge case).
|
|
||||||
// The database will be updated by the event loop anyway.
|
|
||||||
func (store *Store) fetchMessage(apiID string) (msg *pmapi.Message, err error) {
|
|
||||||
return store.api.GetMessage(apiID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (store *Store) txGetMessage(tx *bolt.Tx, apiID string) (*pmapi.Message, error) {
|
func (store *Store) txGetMessage(tx *bolt.Tx, apiID string) (*pmapi.Message, error) {
|
||||||
b := tx.Bucket(metadataBucket)
|
b := tx.Bucket(metadataBucket)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user