Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/models/message.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
BLADE_BUCKET_REGION = 'ap-northeast-1'
BLADE_BUCKET_NAME = 'blade.ruby-lang.org'

require 'kconv'

class Message < ApplicationRecord
# Not really sure we will utlize this configuration,
# but I don't want to make this column.
Expand All @@ -19,8 +21,14 @@ def self.from_s3(list_name, list_seq)
end

def self.from_string(str)
hs, body = str.encode('utf-8', invalid: :replace).split(/\n\n/, 2)
headers = hs.split(/\n/).map { |line|
headers_str, body = str.split(/\n\n/, 2)

# Not really sure this is from the original email, or while making
# blade.ruby-lang.org's S3 archive, but there are emails without
# a proper Form header, such as ruby-list:2840.
headers_str = Kconv.toutf8(headers_str).gsub(/\r\n/, '')

headers = headers_str.split(/\n/).map { |line|
line.split(/:\s+/, 2)
}.to_h

Expand Down