mailr/app/models/imap_message.rb
Wojciech Todryk a7dd8c90c9 devel
2011-07-21 11:14:07 +02:00

44 lines
742 B
Ruby
Executable file

require 'mail2screen'
class ImapMessage < ActiveRecord::Base
include Mail2Screen
def set_folder(folder)
@folder = folder
end
def full_body
@folder.mailbox.imap.uid_fetch(uid, "BODY[]").first.attr["BODY[]"]
end
def from_addr=(fa)
self.from = fa.to_yaml
self.from_flat = short_address(fa)
end
def from_addr
begin
YAML::load(from)
rescue Object
from
end
end
def to_addr=(ta)
self.to = ta.to_yaml
self.to_flat = short_address(ta)
end
def to_addr
begin
YAML::load(to)
rescue Object
to
end
end
def self.getAll(userName,folderName,sortOrder='date desc')
self.all(:conditions => ["username = ? and folder_name = ?", userName, folderName],:order => sortOrder)
end
end