]> git.openstreetmap.org Git - rails.git/blob - app/models/message.rb
Add a 30 second timeout to all data browser requests to avoid attempts
[rails.git] / app / models / message.rb
1 require 'validators'
2
3 class Message < ActiveRecord::Base
4   belongs_to :sender, :class_name => "User", :foreign_key => :from_user_id
5   belongs_to :recipient, :class_name => "User", :foreign_key => :to_user_id
6
7   validates_presence_of :title, :body, :sent_on, :sender, :recipient
8   validates_length_of :title, :within => 1..255
9   validates_inclusion_of :message_read, :in => [ true, false ]
10   validates_associated :sender, :recipient
11   validates_as_utf8 :title
12
13   def digest
14     md5 = Digest::MD5.new
15     md5 << from_user_id.to_s
16     md5 << to_user_id.to_s
17     md5 << sent_on.xmlschema
18     md5 << title
19     md5 << body
20     md5.hexdigest
21   end
22 end