Sha256: aa92f0b8d34656ee356f282472751cec0a809d206242fe8dac91c8b855bdbc17
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true require 'osa/util/constants' require 'public_suffix' require 'osa/util/db' require 'osa/util/context' context = OSA::Context.new continue = true while continue mails = context.graph_client.mails(context.config.junk_folder_id) continue = false loop do break if mails.nil? mails['value'].each do |mail| email_address = mail['sender']['emailAddress']['address'] next if email_address.nil? domain = PublicSuffix.domain(email_address.split('@', 2)[1]) flagged = mail['flag']['flagStatus'] == 'flagged' blacklisted = nil blacklisted = OSA::Blacklist.where(value: email_address).or(OSA::Blacklist.where(value: domain)).exists? unless flagged if flagged puts "Email from #{email_address} is flagged, reporting and deleting" elsif blacklisted puts "#{email_address} is blacklisted, reporting and deleting" else puts "Skipping mail from #{email_address}, its not blacklisted" next end continue = true puts "forwarding spam from #{email_address}" context.graph_client.forward_mail_as_attachment(mail['id'], context.config.spamcop_report_email) puts "deleting spam from #{email_address}" context.graph_client.delete_mail(mail['id']) end mails = mails.next end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
osa-0.1.2 | lib/osa/scripts/scan_junk_folder.rb |