actionmailbox-imap 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 248418f6ce3fddc3c6a4f1ac9f6c40e013cb2a534b93a21b21e5a61cff71b0e0
4
- data.tar.gz: 38580fb0121551ae67498285117a6530bc3dc8687589f3c09abd868148619cc1
3
+ metadata.gz: bf597bbca58917880d28d6b9ea482e0c67d0dc1aba28c3ce643f297e5c0860df
4
+ data.tar.gz: be76ffc403639b411d67d18e651b7933633c95e0abe5be55cfbf365e84bc369f
5
5
  SHA512:
6
- metadata.gz: d6f690e989e79e1e79442554914bd28f4895b82e8707e1e76649f816a06ed4c2b9d2fffbd44f5fd6d62930a27886b1ba985b0e6dea31bb5afa59246a562b8a81
7
- data.tar.gz: 24c65ffa1ea50fc225a21d4f9c15d880c55434a7b5c4541c0bb4f98dc0330dad01b67a5e21f2090f3a1b19129f2d35808bc2f7e9fb578feda9564c8a5d08396a
6
+ metadata.gz: b501f7a5e650d176d287c773115f11cebcaf639a54dfd81ce781350c9fbedfd89134fbf0011764dd7efc500bc0d6947faf0724be58a4d78bb2269ef0ce66e0dd
7
+ data.tar.gz: d8c7e4a75a3b89fac41c5a426aaf8f3b1b34cc06369be9657bbeaaea275fc11947a7376f34c47fc89d296b69d35af05f957263670b0d593d34b565e8e7d88d19
data/README.md CHANGED
@@ -16,7 +16,7 @@ If the rake task fails to relay a message to ActionMailbox then it will ignore i
16
16
  It seems that there is no plans to create some sort of IMAP implementation relay in ActionMailbox.
17
17
  https://github.com/rails/actionmailbox/issues/14
18
18
 
19
- There is probably a reason for this. We did not want to setup or maintain a mailserver which would probably be the route to go for a robust inboud email application.
19
+ There is probably a reason for this. We did not want to setup or maintain a mailserver which would probably be the route to go for a robust inbound email application.
20
20
 
21
21
  ## Usage
22
22
 
@@ -21,14 +21,22 @@ module ActionMailbox
21
21
  imap.disconnect
22
22
  end
23
23
 
24
- def messages_not_deleted
25
- imap.search(["NOT", "DELETED"])
24
+ def messages
25
+ imap.search(["NOT", "DELETED", "NOT", "SEEN"])
26
26
  end
27
27
 
28
28
  def delete_message(id)
29
29
  imap.store(id, "+FLAGS", [:Deleted])
30
30
  end
31
31
 
32
+ def mark_message_seen(id)
33
+ imap.store(id, "+FLAGS", [:Seen])
34
+ end
35
+
36
+ def mark_message_unseen(id)
37
+ imap.store(id, "-FLAGS", [:Seen])
38
+ end
39
+
32
40
  def fetch_message_attr(id, attr)
33
41
  imap.fetch(id, attr).first.attr[attr]
34
42
  end
@@ -9,7 +9,7 @@ module ActionMailbox
9
9
  end
10
10
 
11
11
  def messages
12
- result = adapter.messages_not_deleted
12
+ result = adapter.messages
13
13
  Messages.new(adapter: adapter, message_ids: result)
14
14
  end
15
15
 
@@ -16,6 +16,14 @@ module ActionMailbox
16
16
  adapter.delete_message(id)
17
17
  end
18
18
 
19
+ def mark_read
20
+ adapter.mark_message_seen(id)
21
+ end
22
+
23
+ def mark_unread
24
+ adapter.mark_message_unseen(id)
25
+ end
26
+
19
27
  private
20
28
 
21
29
  attr_reader :adapter, :id
@@ -25,6 +25,18 @@ module ActionMailbox
25
25
  end
26
26
  end
27
27
 
28
+ def mark_read
29
+ message_ids.each do |id|
30
+ adapter.mark_message_seen(id)
31
+ end
32
+ end
33
+
34
+ def mark_unread
35
+ message_ids.each do |id|
36
+ adapter.mark_message_unseen(id)
37
+ end
38
+ end
39
+
28
40
  private
29
41
 
30
42
  attr_reader :adapter, :message_ids
@@ -1,5 +1,5 @@
1
1
  module Actionmailbox
2
2
  module Imap
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -28,9 +28,14 @@ namespace :action_mailbox do
28
28
 
29
29
  relayer = ActionMailbox::Relayer.new(url: url, password: password)
30
30
 
31
- mailbox.messages.take(config[:take]).each do |message|
31
+ messages = mailbox.messages.take(config[:take])
32
+
33
+ messages.mark_read
34
+
35
+ messages.each do |message|
32
36
  relayer.relay(message.rfc822).tap do |result|
33
37
  message.delete if result.success?
38
+ message.mark_unread unless result.success?
34
39
  end
35
40
  end
36
41
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionmailbox-imap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan Knowlton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-22 00:00:00.000000000 Z
11
+ date: 2019-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails