Skip to content

Commit

Permalink
update to Sisimai 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dmke committed Feb 6, 2024
1 parent 91f6339 commit 68cde90
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source "https://rubygems.org"
git_source(:github) { |name| "https://github.com/#{name}.git" }

gem "sinatra"
gem "sisimai", github: "sisimai/rb-sisimai", ref: "v4.25.16p1"
gem "sisimai", github: "sisimai/rb-sisimai", ref: "v5.0.0"
gem "webrick"

group :test do
Expand Down
28 changes: 14 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
GIT
remote: https://github.com/sisimai/rb-sisimai.git
revision: 7d972e18862ab2c07a181e2839b4e78505d9d2c8
ref: v4.25.16p1
revision: cd166bcb59b5929fa75d33df22fd0896f33e3eb2
ref: v5.0.0
specs:
sisimai (4.25.16p1)
sisimai (5.0.0)
oj (>= 3.0.0)

GEM
Expand Down Expand Up @@ -33,19 +33,19 @@ GEM
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.1)
rspec-support (~> 3.13.0)
rspec-support (3.13.0)
ruby2_keywords (0.0.5)
sinatra (4.0.0)
mustermann (~> 3.0)
Expand Down
2 changes: 2 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require "sinatra"
require "sisimai"
require "sisimai/fact"
require "oj"

require_relative "lib/classifier"
Expand Down
19 changes: 13 additions & 6 deletions lib/classifier.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
require "sisimai"
require "sisimai/data"
require "sisimai/message"
require "sisimai/fact"

def classify(message)
msg = Sisimai::Message.new(data: message)
return if msg.void
fact = Sisimai::Fact.rise(data: message, vacation: true, delivered: true)&.first
return unless fact

result = Sisimai::Data.make(data: msg, origin: "<MEMORY>")
return result[0]
fact.damn.merge("softbounce" => to_softbounce(fact))
end

# Sisimai::Fact has deprecated and will remove #softbounce in v5.1.0.
# For backward compatibility we'll keep it though.
def to_softbounce(fact)
return 0 if fact.hardbounce
return -1 if %w[delivered feedback vacation].include?(fact.reason)

1
end

0 comments on commit 68cde90

Please sign in to comment.