popper 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/lib/popper/mail_account.rb +11 -9
 - data/lib/popper/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 7241d920f1cc1df768881863fd35b016df55897ab00eac6be95afe59e59a392b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a4a80773306057f341999e6deedce2ed8688a4e81006be9b4fe3f0e6c23ba98e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c2fdc66898ca3b56790fd5a266888c9162ce0ab7b62edd13ba5c613999863d431131e07d400f4f19d76753987a0cac568a338bf46fde51e16632fb41d4ffc89a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 814434364ccb6c25d3d9bd3a328d5707644741377947417f127bc3299d2329d16f0b81251c29e43ac8e96c174bafece2e2f7700737e6a86ab1e5ac7425fd765f
         
     | 
    
        data/lib/popper/mail_account.rb
    CHANGED
    
    | 
         @@ -7,13 +7,13 @@ module Popper 
     | 
|
| 
       7 
7 
     | 
    
         
             
                attr_accessor :config, :current_list, :complete_list
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                def initialize(config)
         
     | 
| 
       10 
     | 
    
         
            -
                   
     | 
| 
      
 10 
     | 
    
         
            +
                  @config = config
         
     | 
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                def run
         
     | 
| 
       14 
14 
     | 
    
         
             
                  session_start do |conn|
         
     | 
| 
       15 
     | 
    
         
            -
                     
     | 
| 
       16 
     | 
    
         
            -
                     
     | 
| 
      
 15 
     | 
    
         
            +
                    @current_list = conn.mails.map(&:uidl)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    @complete_list ||= @current_list
         
     | 
| 
       17 
17 
     | 
    
         
             
                    pop(conn)
         
     | 
| 
       18 
18 
     | 
    
         
             
                  end
         
     | 
| 
       19 
19 
     | 
    
         
             
                rescue StandardError => e
         
     | 
| 
         @@ -27,10 +27,12 @@ module Popper 
     | 
|
| 
       27 
27 
     | 
    
         
             
                  Popper.log.info "start popper #{config.name}"
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
                  process_uidl_list(conn).each do |m|
         
     | 
| 
      
 30 
     | 
    
         
            +
                    uidl = m.uidl
         
     | 
| 
      
 31 
     | 
    
         
            +
                    Popper.log.info "pop mail:#{uidl}"
         
     | 
| 
       30 
32 
     | 
    
         
             
                    done_uidls << check_and_action(m)
         
     | 
| 
       31 
33 
     | 
    
         
             
                    m.delete if config.login.respond_to?(:delete_after) && config.login.delete_after
         
     | 
| 
       32 
34 
     | 
    
         
             
                  rescue Net::POPError => e
         
     | 
| 
       33 
     | 
    
         
            -
                     
     | 
| 
      
 35 
     | 
    
         
            +
                    @complete_list += done_uidls
         
     | 
| 
       34 
36 
     | 
    
         
             
                    Popper.log.warn 'pop err write uidl'
         
     | 
| 
       35 
37 
     | 
    
         
             
                    return
         
     | 
| 
       36 
38 
     | 
    
         
             
                  rescue StandardError => e
         
     | 
| 
         @@ -38,8 +40,8 @@ module Popper 
     | 
|
| 
       38 
40 
     | 
    
         
             
                    Popper.log.warn e
         
     | 
| 
       39 
41 
     | 
    
         
             
                  end
         
     | 
| 
       40 
42 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                   
     | 
| 
       42 
     | 
    
         
            -
                  Popper.log.info "success popper #{config.name}"
         
     | 
| 
      
 43 
     | 
    
         
            +
                  @complete_list = @current_list - error_uidls
         
     | 
| 
      
 44 
     | 
    
         
            +
                  Popper.log.info "success popper #{config.name} current_list:#{@current_list.size} complete_list:#{@complete_list.size}"
         
     | 
| 
       43 
45 
     | 
    
         
             
                end
         
     | 
| 
       44 
46 
     | 
    
         | 
| 
       45 
47 
     | 
    
         
             
                def check_and_action(m)
         
     | 
| 
         @@ -79,7 +81,7 @@ module Popper 
     | 
|
| 
       79 
81 
     | 
    
         
             
                end
         
     | 
| 
       80 
82 
     | 
    
         | 
| 
       81 
83 
     | 
    
         
             
                def process_uidl_list(conn)
         
     | 
| 
       82 
     | 
    
         
            -
                  uidl_list = current_list - complete_list
         
     | 
| 
      
 84 
     | 
    
         
            +
                  uidl_list = @current_list - @complete_list
         
     | 
| 
       83 
85 
     | 
    
         
             
                  conn.mails.select { |_m| uidl_list.include?(_m.uidl) }
         
     | 
| 
       84 
86 
     | 
    
         
             
                end
         
     | 
| 
       85 
87 
     | 
    
         | 
| 
         @@ -120,10 +122,10 @@ class EncodeMail < Mail::Message 
     | 
|
| 
       120 
122 
     | 
    
         
             
              def utf_body
         
     | 
| 
       121 
123 
     | 
    
         
             
                if multipart?
         
     | 
| 
       122 
124 
     | 
    
         
             
                  parts.map do |part|
         
     | 
| 
       123 
     | 
    
         
            -
                    part.body.decoded.encode('UTF-8', charset) unless part.attachment?
         
     | 
| 
      
 125 
     | 
    
         
            +
                    part.body.decoded.encode('UTF-8', charset, undef: :replace, invalid: :replace, replace: '') unless part.attachment?
         
     | 
| 
       124 
126 
     | 
    
         
             
                  end.join
         
     | 
| 
       125 
127 
     | 
    
         
             
                else
         
     | 
| 
       126 
     | 
    
         
            -
                  body.decoded.encode('UTF-8', charset)
         
     | 
| 
      
 128 
     | 
    
         
            +
                  body.decoded.encode('UTF-8', charset, undef: :replace, invalid: :replace, replace: '')
         
     | 
| 
       127 
129 
     | 
    
         
             
                end
         
     | 
| 
       128 
130 
     | 
    
         
             
              end
         
     | 
| 
       129 
131 
     | 
    
         
             
            end
         
     | 
    
        data/lib/popper/version.rb
    CHANGED