aboutsummaryrefslogtreecommitdiff
path: root/internal/msg/msg.go
blob: a742a9da5b0a12b3a536732fa1f318616102274c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package msg

import (
	"fmt"

	"github.com/Necoro/feed2imap-go/internal/imap"
	"github.com/Necoro/feed2imap-go/pkg/log"
)

// headers
const (
	VersionHeader = "X-Feed2Imap-Version"
	ReasonHeader  = "X-Feed2Imap-Reason"
	IdHeader      = "X-Feed2Imap-Item"
	GuidHeader    = "X-Feed2Imap-Guid"
)

type Messages []Message

type Message struct {
	Content  string
	IsUpdate bool
	ID       string
}

func (m Messages) Upload(client *imap.Client, folder imap.Folder, reupload bool) error {
	toStore := make([]string, 0, len(m))

	msgs := make(chan Message, 5)
	ok := make(chan bool)
	go func() {
		errHappened := false
		for msg := range msgs {
			if err := client.Replace(folder, IdHeader, msg.ID, msg.Content, reupload); err != nil {
				log.Errorf("Error while updating mail with id '%s' in folder '%s'. Skipping.: %s",
					msg.ID, folder, err)
				errHappened = true
			}
		}

		ok <- errHappened
	}()

	for _, msg := range m {
		if !msg.IsUpdate {
			toStore = append(toStore, msg.Content)
		} else {
			msgs <- msg
		}
	}

	close(msgs)

	putErr := client.PutMessages(folder, toStore)
	updOk := <-ok

	if putErr != nil {
		return putErr
	}
	if updOk {
		return fmt.Errorf("Errors during updating mails.")
	}

	return nil
}
colspan='5' class='logmsg'> 2014-04-18init: allow deinitializationJason A. Donenfeld2-2/+18 2014-04-18bash-completion: filter dot files from resultsJason A. Donenfeld1-3/+8 2014-04-18reencrypt: remove option, do automaticallyJason A. Donenfeld5-39/+25 2014-04-18reencryption: add to completion filesJason A. Donenfeld3-1/+5 2014-04-18Specify variable gpg.Jason A. Donenfeld1-1/+1 2014-04-18style: don't escape new line on &&Jason A. Donenfeld1-2/+2 2014-04-18reencryption: remove temporary file on failureJason A. Donenfeld1-1/+1 2014-04-18reencryption: only reencrypt files when requiredJason A. Donenfeld2-16/+37 2014-04-17cp: typo as cvJason A. Donenfeld1-1/+1 2014-04-17bash: gpg_id is localJason A. Donenfeld1-0/+1 2014-04-17move/copy: always reencrypt passwords at destinationJason A. Donenfeld5-25/+56 2014-04-17makefile: allow platform files with gnu sedJason A. Donenfeld1-7/+8 Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-04-17mv: Add pass mv/rename supportJason A. Donenfeld5-3/+78 Based-on-work-by: Matthieu Weber <mweber@free.fr> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-04-17revelation2pass: add plain XML importJavali1-11/+15 I found that revelatio2pass.py script doesn't work. It can not decrypt my password file. I got following error message: raceback (most recent call last): File "git/password-store/contrib/importers/revelation2pass.py", line 159, in <module> main(args.FILE, verbose=args.verbose, xml=args.xml) File "git/password-store/contrib/importers/revelation2pass.py", line 140, in main cleardata_gz = decrypt_gz(password, data) File "git/password-store/contrib/importers/revelation2pass.py", line 117, in decrypt_gz ct = c.decrypt(cipher_text[28:]) File "/usr/lib/python2.7/site-packages/Crypto/Cipher/blockalgo.py", line 295, in decrypt return self._cipher.decrypt(ciphertext) I was unable to fix the problem, but I created a workaround, that add plain XML import option to the revelation2pass.py script. Revelation can export its password file as plain XML format. 2014-04-17platform: add cygwin supportJason A. Donenfeld2-1/+17 According to Brandon Jones, all we need to do is adjust /dev/clipboard from xclip. So we add a platform specific file to do so. http://www.relaytheurgency.com/2014/04/pass-in-cygwin-relatively-simple.html Suggested-by: Brandon Jones <jones.brandon.lee@gmail.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>