forked from Silverfish/proton-bridge
Waiting for unilateral update during deleting the message
This commit is contained in:
@ -4,6 +4,9 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
* GODT-847 Waiting for unilateral update during deleting the message.
|
||||||
|
|
||||||
## [IE 1.2.0] Elbe
|
## [IE 1.2.0] Elbe
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@ -37,7 +37,7 @@ func (store *Store) SetIMAPUpdateChannel(updates chan imapBackend.Update) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *Store) imapNotice(address, notice string) {
|
func (store *Store) imapNotice(address, notice string) *imapBackend.StatusUpdate {
|
||||||
update := new(imapBackend.StatusUpdate)
|
update := new(imapBackend.StatusUpdate)
|
||||||
update.Update = imapBackend.NewUpdate(address, "")
|
update.Update = imapBackend.NewUpdate(address, "")
|
||||||
update.StatusResp = &imap.StatusResp{
|
update.StatusResp = &imap.StatusResp{
|
||||||
@ -46,13 +46,14 @@ func (store *Store) imapNotice(address, notice string) {
|
|||||||
Info: notice,
|
Info: notice,
|
||||||
}
|
}
|
||||||
store.imapSendUpdate(update)
|
store.imapSendUpdate(update)
|
||||||
|
return update
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *Store) imapUpdateMessage(
|
func (store *Store) imapUpdateMessage(
|
||||||
address, mailboxName string,
|
address, mailboxName string,
|
||||||
uid, sequenceNumber uint32,
|
uid, sequenceNumber uint32,
|
||||||
msg *pmapi.Message, hasDeletedFlag bool,
|
msg *pmapi.Message, hasDeletedFlag bool,
|
||||||
) {
|
) *imapBackend.MessageUpdate {
|
||||||
store.log.WithFields(logrus.Fields{
|
store.log.WithFields(logrus.Fields{
|
||||||
"address": address,
|
"address": address,
|
||||||
"mailbox": mailboxName,
|
"mailbox": mailboxName,
|
||||||
@ -70,9 +71,10 @@ func (store *Store) imapUpdateMessage(
|
|||||||
}
|
}
|
||||||
update.Message.Uid = uid
|
update.Message.Uid = uid
|
||||||
store.imapSendUpdate(update)
|
store.imapSendUpdate(update)
|
||||||
|
return update
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *Store) imapDeleteMessage(address, mailboxName string, sequenceNumber uint32) {
|
func (store *Store) imapDeleteMessage(address, mailboxName string, sequenceNumber uint32) *imapBackend.ExpungeUpdate {
|
||||||
store.log.WithFields(logrus.Fields{
|
store.log.WithFields(logrus.Fields{
|
||||||
"address": address,
|
"address": address,
|
||||||
"mailbox": mailboxName,
|
"mailbox": mailboxName,
|
||||||
@ -82,9 +84,10 @@ func (store *Store) imapDeleteMessage(address, mailboxName string, sequenceNumbe
|
|||||||
update.Update = imapBackend.NewUpdate(address, mailboxName)
|
update.Update = imapBackend.NewUpdate(address, mailboxName)
|
||||||
update.SeqNum = sequenceNumber
|
update.SeqNum = sequenceNumber
|
||||||
store.imapSendUpdate(update)
|
store.imapSendUpdate(update)
|
||||||
|
return update
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *Store) imapMailboxCreated(address, mailboxName string) {
|
func (store *Store) imapMailboxCreated(address, mailboxName string) *imapBackend.MailboxInfoUpdate {
|
||||||
store.log.WithFields(logrus.Fields{
|
store.log.WithFields(logrus.Fields{
|
||||||
"address": address,
|
"address": address,
|
||||||
"mailbox": mailboxName,
|
"mailbox": mailboxName,
|
||||||
@ -97,9 +100,10 @@ func (store *Store) imapMailboxCreated(address, mailboxName string) {
|
|||||||
Name: mailboxName,
|
Name: mailboxName,
|
||||||
}
|
}
|
||||||
store.imapSendUpdate(update)
|
store.imapSendUpdate(update)
|
||||||
|
return update
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *Store) imapMailboxStatus(address, mailboxName string, total, unread, unreadSeqNum uint) {
|
func (store *Store) imapMailboxStatus(address, mailboxName string, total, unread, unreadSeqNum uint) *imapBackend.MailboxUpdate {
|
||||||
store.log.WithFields(logrus.Fields{
|
store.log.WithFields(logrus.Fields{
|
||||||
"address": address,
|
"address": address,
|
||||||
"mailbox": mailboxName,
|
"mailbox": mailboxName,
|
||||||
@ -114,6 +118,7 @@ func (store *Store) imapMailboxStatus(address, mailboxName string, total, unread
|
|||||||
update.MailboxStatus.Unseen = uint32(unread)
|
update.MailboxStatus.Unseen = uint32(unread)
|
||||||
update.MailboxStatus.UnseenSeqNum = uint32(unreadSeqNum)
|
update.MailboxStatus.UnseenSeqNum = uint32(unreadSeqNum)
|
||||||
store.imapSendUpdate(update)
|
store.imapSendUpdate(update)
|
||||||
|
return update
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *Store) imapSendUpdate(update imapBackend.Update) {
|
func (store *Store) imapSendUpdate(update imapBackend.Update) {
|
||||||
|
|||||||
@ -18,6 +18,8 @@
|
|||||||
package store
|
package store
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -501,7 +503,7 @@ func (storeMailbox *Mailbox) txMarkMessagesAsDeleted(tx *bolt.Tx, apiIDs []strin
|
|||||||
|
|
||||||
// In order to send flags in format
|
// In order to send flags in format
|
||||||
// S: * 2 FETCH (FLAGS (\Deleted \Seen))
|
// S: * 2 FETCH (FLAGS (\Deleted \Seen))
|
||||||
storeMailbox.store.imapUpdateMessage(
|
update := storeMailbox.store.imapUpdateMessage(
|
||||||
storeMailbox.storeAddress.address,
|
storeMailbox.storeAddress.address,
|
||||||
storeMailbox.labelName,
|
storeMailbox.labelName,
|
||||||
uid,
|
uid,
|
||||||
@ -509,6 +511,14 @@ func (storeMailbox *Mailbox) txMarkMessagesAsDeleted(tx *bolt.Tx, apiIDs []strin
|
|||||||
msg,
|
msg,
|
||||||
markAsDeleted,
|
markAsDeleted,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// txMarkMessagesAsDeleted is called only during processing request
|
||||||
|
// from IMAP call (i.e., not from event loop) and in such cases we
|
||||||
|
// have to wait to propagate update back before closing the response.
|
||||||
|
select {
|
||||||
|
case <-time.After(1 * time.Second):
|
||||||
|
case <-update.Done():
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -155,7 +155,7 @@ func (ir *IMAPResponse) AssertSectionsInOrder(wantRegexps ...string) *IMAPRespon
|
|||||||
func (ir *IMAPResponse) AssertSections(wantRegexps ...string) *IMAPResponse {
|
func (ir *IMAPResponse) AssertSections(wantRegexps ...string) *IMAPResponse {
|
||||||
ir.wait()
|
ir.wait()
|
||||||
for _, wantRegexp := range wantRegexps {
|
for _, wantRegexp := range wantRegexps {
|
||||||
a.NoError(ir.t, ir.hasSectionRegexp(wantRegexp), "regexp %v not found", wantRegexp)
|
a.NoError(ir.t, ir.hasSectionRegexp(wantRegexp), "regexp %v not found\nSections: %v", wantRegexp, ir.sections)
|
||||||
}
|
}
|
||||||
return ir
|
return ir
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user