diaspora/app/models/request.rb
ilya 7eba033c0d Revert "RS IZ Friday night, key_fingerprint serialization weirdness"
This reverts commit c6e16835df9c5d46d0ec5e0f1860da1ef4c0986a.
2010-07-10 05:29:57 -04:00

34 lines
835 B
Ruby

class Request
require 'lib/common'
include MongoMapper::Document
include Diaspora::Webhooks
include ROXML
xml_accessor :_id
xml_accessor :person, :as => Person
xml_accessor :destination_url
xml_accessor :callback_url
key :destination_url, String
key :callback_url, String
key :person_id, ObjectId
belongs_to :person
validates_presence_of :destination_url, :callback_url
scope :for_user, lambda{ |user| where(:destination_url => user.url) }
scope :from_user, lambda{ |user| where(:destination_url.ne => user.url) }
def self.instantiate(options ={})
person = options[:from]
self.new(:destination_url => options[:to], :callback_url => person.url, :person => person)
end
def activate_friend
p = Person.where(:url => self.person.url).first
p.active = true
p.save
end
end