inital commit for mailqueue
This commit is contained in:
parent
693847480b
commit
d793bdc3c7
7 changed files with 23 additions and 7 deletions
|
|
@ -5,6 +5,7 @@ class Notifier < ActionMailer::Base
|
|||
ATTACHMENT = File.read("#{Rails.root}/public/images/diaspora_white_on_grey.png")
|
||||
|
||||
def new_request(recipient, sender)
|
||||
puts "I'm in new request"
|
||||
@receiver = recipient
|
||||
@sender = sender
|
||||
attachments.inline['diaspora_white_on_grey.png'] = ATTACHMENT
|
||||
|
|
@ -22,4 +23,13 @@ class Notifier < ActionMailer::Base
|
|||
mail(:to => "#{recipient.real_name} <#{recipient.email}>",
|
||||
:subject => "#{@sender.real_name} has accepted your friend request on Diaspora*", :host => APP_CONFIG[:terse_pod_url])
|
||||
end
|
||||
|
||||
|
||||
def self.send_request_accepted!(user, person, aspect)
|
||||
Notifier.async.request_accepted(user, person, aspect ).deliver.commit!
|
||||
end
|
||||
|
||||
def self.send_new_request!(user, person)
|
||||
Notifier.async.new_request(user, person).deliver.commit!
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ module Diaspora
|
|||
Rails.logger.info("#{self.real_name}'s friend request has been accepted")
|
||||
friend_request.destroy
|
||||
original_request.destroy
|
||||
Notifier.request_accepted(self, friend_request.person, destination_aspect)
|
||||
Notifier.send_request_accepted!(self, friend_request.person, destination_aspect)
|
||||
|
||||
#this is a new friend request
|
||||
elsif !request_from_me?(friend_request)
|
||||
|
|
@ -75,7 +75,7 @@ module Diaspora
|
|||
self.save
|
||||
Rails.logger.info("#{self.real_name} has received a friend request")
|
||||
friend_request.save
|
||||
Notifier.new_request(self, friend_request.person).deliver
|
||||
Notifier.send_new_request!(self, friend_request.person)
|
||||
else
|
||||
raise "#{self.real_name} is trying to receive a friend request from himself."
|
||||
end
|
||||
|
|
|
|||
2
script/mail_worker.rb
Normal file
2
script/mail_worker.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
require File.dirname(__FILE__) + '/../config/environment'
|
||||
Magent::Processor.new(Magent::AsyncChannel.new(:default)).run!
|
||||
|
|
@ -50,4 +50,5 @@ fi
|
|||
|
||||
mkdir -p -v log/thin/
|
||||
bundle exec ruby ./script/websocket_server.rb&
|
||||
bundle exec ruby ./script/mail_worker.rb&
|
||||
bundle exec thin start $args
|
||||
|
|
|
|||
|
|
@ -39,11 +39,12 @@ def process_message
|
|||
else
|
||||
EM::Timer.new(1){process_message}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
begin
|
||||
EM.run {
|
||||
|
||||
|
||||
Diaspora::WebSocket.initialize_channels
|
||||
|
||||
EventMachine::WebSocket.start(
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ describe Diaspora::UserModules::Friending do
|
|||
let(:user2) { make_user }
|
||||
let(:aspect2) { user2.aspects.create(:name => "aspect two") }
|
||||
|
||||
|
||||
context 'friend requesting' do
|
||||
it "should assign a request to a aspect for the user that sent it out" do
|
||||
aspect.requests.size.should == 0
|
||||
|
|
@ -87,7 +88,7 @@ describe Diaspora::UserModules::Friending do
|
|||
end
|
||||
|
||||
it 'should send an email on acceptance if a friend request' do
|
||||
Notifier.should_receive(:request_accepted)
|
||||
Notifier.should_receive(:send_request_accepted!)
|
||||
request = user.send_friend_request_to(user2.person, aspect)
|
||||
user.receive_friend_request(request.reverse_for(user2))
|
||||
end
|
||||
|
|
@ -133,9 +134,7 @@ describe Diaspora::UserModules::Friending do
|
|||
end
|
||||
|
||||
it 'sends an email to the receiving user' do
|
||||
mail_obj = mock("mailer")
|
||||
mail_obj.should_receive(:deliver)
|
||||
Notifier.should_receive(:new_request).and_return(mail_obj)
|
||||
Notifier.should_receive(:send_new_request!).and_return(true)
|
||||
user.receive @req_xml, person_one
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ RSpec.configure do |config|
|
|||
EventMachine::HttpRequest.any_instance.stubs(:get)
|
||||
DatabaseCleaner.clean
|
||||
UserFixer.load_user_fixtures
|
||||
Notifier.stub!(:send_request_accepted!).and_return(true)
|
||||
Notifier.stub!(:send_new_request!).and_return(true)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue