Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
diaspora
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
diasporg
diaspora
Commits
97f80272
Commit
97f80272
authored
Sep 15, 2011
by
danielgrippi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DG MS; changed Job:: to Jobs::; require all mail jobs from Job base class
parent
ec011f08
Changes
67
Hide whitespace changes
Inline
Side-by-side
Showing
67 changed files
with
132 additions
and
127 deletions
+132
-127
app/controllers/invitations_controller.rb
app/controllers/invitations_controller.rb
+1
-1
app/controllers/people_controller.rb
app/controllers/people_controller.rb
+1
-1
app/controllers/publics_controller.rb
app/controllers/publics_controller.rb
+2
-2
app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
+1
-1
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+1
-1
app/models/invitation.rb
app/models/invitation.rb
+1
-1
app/models/job/base.rb
app/models/job/base.rb
+0
-5
app/models/jobs/base.rb
app/models/jobs/base.rb
+10
-0
app/models/jobs/delete_account.rb
app/models/jobs/delete_account.rb
+1
-1
app/models/jobs/http_multi.rb
app/models/jobs/http_multi.rb
+2
-2
app/models/jobs/mail/also_commented.rb
app/models/jobs/mail/also_commented.rb
+1
-1
app/models/jobs/mail/comment_on_post.rb
app/models/jobs/mail/comment_on_post.rb
+1
-1
app/models/jobs/mail/confirm_email.rb
app/models/jobs/mail/confirm_email.rb
+1
-1
app/models/jobs/mail/invite_user_by_email.rb
app/models/jobs/mail/invite_user_by_email.rb
+1
-1
app/models/jobs/mail/liked.rb
app/models/jobs/mail/liked.rb
+1
-1
app/models/jobs/mail/mentioned.rb
app/models/jobs/mail/mentioned.rb
+1
-1
app/models/jobs/mail/private_message.rb
app/models/jobs/mail/private_message.rb
+1
-1
app/models/jobs/mail/reshared.rb
app/models/jobs/mail/reshared.rb
+1
-1
app/models/jobs/mail/started_sharing.rb
app/models/jobs/mail/started_sharing.rb
+1
-1
app/models/jobs/notify_local_users.rb
app/models/jobs/notify_local_users.rb
+1
-1
app/models/jobs/post_to_service.rb
app/models/jobs/post_to_service.rb
+1
-1
app/models/jobs/process_photo.rb
app/models/jobs/process_photo.rb
+1
-1
app/models/jobs/publish_to_hub.rb
app/models/jobs/publish_to_hub.rb
+1
-1
app/models/jobs/receive.rb
app/models/jobs/receive.rb
+1
-1
app/models/jobs/receive_local_batch.rb
app/models/jobs/receive_local_batch.rb
+1
-1
app/models/jobs/receive_public_salmon.rb
app/models/jobs/receive_public_salmon.rb
+1
-1
app/models/jobs/receive_salmon.rb
app/models/jobs/receive_salmon.rb
+1
-1
app/models/jobs/resend_invitation.rb
app/models/jobs/resend_invitation.rb
+1
-1
app/models/jobs/socket_webfinger.rb
app/models/jobs/socket_webfinger.rb
+1
-1
app/models/jobs/update_service_users.rb
app/models/jobs/update_service_users.rb
+1
-1
app/models/notifications/also_commented.rb
app/models/notifications/also_commented.rb
+1
-1
app/models/notifications/comment_on_post.rb
app/models/notifications/comment_on_post.rb
+1
-1
app/models/notifications/liked.rb
app/models/notifications/liked.rb
+1
-1
app/models/notifications/mentioned.rb
app/models/notifications/mentioned.rb
+1
-1
app/models/notifications/private_message.rb
app/models/notifications/private_message.rb
+1
-1
app/models/notifications/request_accepted.rb
app/models/notifications/request_accepted.rb
+1
-1
app/models/notifications/reshared.rb
app/models/notifications/reshared.rb
+2
-2
app/models/notifications/started_sharing.rb
app/models/notifications/started_sharing.rb
+1
-1
app/models/photo.rb
app/models/photo.rb
+1
-1
app/models/user.rb
app/models/user.rb
+2
-2
lib/postzord/dispatcher.rb
lib/postzord/dispatcher.rb
+6
-6
lib/postzord/receiver/public.rb
lib/postzord/receiver/public.rb
+1
-1
spec/controllers/people_controller_spec.rb
spec/controllers/people_controller_spec.rb
+1
-1
spec/controllers/publics_controller_spec.rb
spec/controllers/publics_controller_spec.rb
+3
-3
spec/controllers/sessions_controller_spec.rb
spec/controllers/sessions_controller_spec.rb
+1
-1
spec/controllers/users_controller_spec.rb
spec/controllers/users_controller_spec.rb
+2
-2
spec/lib/postzord/dispatcher_spec.rb
spec/lib/postzord/dispatcher_spec.rb
+10
-10
spec/lib/postzord/receiver/public_spec.rb
spec/lib/postzord/receiver/public_spec.rb
+2
-2
spec/models/jobs/delete_account_spec.rb
spec/models/jobs/delete_account_spec.rb
+3
-3
spec/models/jobs/http_multi_spec.rb
spec/models/jobs/http_multi_spec.rb
+8
-8
spec/models/jobs/mail/invite_user_by_email_spec.rb
spec/models/jobs/mail/invite_user_by_email_spec.rb
+2
-2
spec/models/jobs/mail/mail_mentioned_spec.rb
spec/models/jobs/mail/mail_mentioned_spec.rb
+2
-2
spec/models/jobs/mail/mail_private_message.rb
spec/models/jobs/mail/mail_private_message.rb
+2
-2
spec/models/jobs/mail/mail_reshared_spec.rb
spec/models/jobs/mail/mail_reshared_spec.rb
+2
-2
spec/models/jobs/notify_local_users_spec.rb
spec/models/jobs/notify_local_users_spec.rb
+2
-2
spec/models/jobs/post_to_service_spec.rb
spec/models/jobs/post_to_service_spec.rb
+2
-2
spec/models/jobs/process_photo_spec.rb
spec/models/jobs/process_photo_spec.rb
+2
-2
spec/models/jobs/publish_to_hub_spec.rb
spec/models/jobs/publish_to_hub_spec.rb
+2
-2
spec/models/jobs/receive_local_batch_spec.rb
spec/models/jobs/receive_local_batch_spec.rb
+1
-1
spec/models/jobs/receive_salmon_spec.rb
spec/models/jobs/receive_salmon_spec.rb
+2
-2
spec/models/jobs/receive_spec.rb
spec/models/jobs/receive_spec.rb
+2
-2
spec/models/jobs/resend_invitation_spec.rb
spec/models/jobs/resend_invitation_spec.rb
+2
-2
spec/models/jobs/socket_webfinger_spec.rb
spec/models/jobs/socket_webfinger_spec.rb
+6
-6
spec/models/jobs/update_service_users_spec.rb
spec/models/jobs/update_service_users_spec.rb
+2
-2
spec/models/photo_spec.rb
spec/models/photo_spec.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+7
-7
spec/support/fake_typhoeus.rb
spec/support/fake_typhoeus.rb
+4
-4
No files found.
app/controllers/invitations_controller.rb
View file @
97f80272
...
...
@@ -56,7 +56,7 @@ class InvitationsController < Devise::InvitationsController
def
resend
invitation
=
current_user
.
invitations_from_me
.
where
(
:id
=>
params
[
:id
]).
first
if
invitation
Resque
.
enqueue
(
Job
::
ResendInvitation
,
invitation
.
id
)
Resque
.
enqueue
(
Job
s
::
ResendInvitation
,
invitation
.
id
)
flash
[
:notice
]
=
I18n
.
t
(
'invitations.create.sent'
)
+
invitation
.
recipient
.
email
end
redirect_to
:back
...
...
app/controllers/people_controller.rb
View file @
97f80272
...
...
@@ -171,7 +171,7 @@ class PeopleController < ApplicationController
private
def
webfinger
(
account
,
opts
=
{})
Resque
.
enqueue
(
Job
::
SocketWebfinger
,
current_user
.
id
,
account
,
opts
)
Resque
.
enqueue
(
Job
s
::
SocketWebfinger
,
current_user
.
id
,
account
,
opts
)
end
def
remote_profile_with_no_user_session?
...
...
app/controllers/publics_controller.rb
View file @
97f80272
...
...
@@ -50,7 +50,7 @@ class PublicsController < ApplicationController
end
def
receive_public
Resque
.
enqueue
(
Job
::
ReceivePublicSalmon
,
params
[
:xml
])
Resque
.
enqueue
(
Job
s
::
ReceivePublicSalmon
,
params
[
:xml
])
render
:nothing
=>
true
,
:status
=>
:ok
end
...
...
@@ -64,7 +64,7 @@ class PublicsController < ApplicationController
end
@user
=
person
.
owner
Resque
.
enqueue
(
Job
::
ReceiveSalmon
,
@user
.
id
,
CGI
::
unescape
(
params
[
:xml
]))
Resque
.
enqueue
(
Job
s
::
ReceiveSalmon
,
@user
.
id
,
CGI
::
unescape
(
params
[
:xml
]))
render
:nothing
=>
true
,
:status
=>
202
end
...
...
app/controllers/sessions_controller.rb
View file @
97f80272
...
...
@@ -10,7 +10,7 @@ class SessionsController < Devise::SessionsController
def
enqueue_update
if
current_user
current_user
.
services
.
each
do
|
s
|
Resque
.
enqueue
(
Job
::
UpdateServiceUsers
,
s
.
id
)
if
s
.
respond_to?
:save_friends
Resque
.
enqueue
(
Job
s
::
UpdateServiceUsers
,
s
.
id
)
if
s
.
respond_to?
:save_friends
end
end
end
...
...
app/controllers/users_controller.rb
View file @
97f80272
...
...
@@ -68,7 +68,7 @@ class UsersController < ApplicationController
end
def
destroy
Resque
.
enqueue
(
Job
::
DeleteAccount
,
current_user
.
id
)
Resque
.
enqueue
(
Job
s
::
DeleteAccount
,
current_user
.
id
)
current_user
.
lock_access!
sign_out
current_user
flash
[
:notice
]
=
I18n
.
t
'users.destroy'
...
...
app/models/invitation.rb
View file @
97f80272
...
...
@@ -135,7 +135,7 @@ class Invitation < ActiveRecord::Base
def
queue_send!
unless
self
.
recipient
.
present?
Resque
.
enqueue
(
Job
::
Mail
::
InviteUserByEmail
,
self
.
id
)
Resque
.
enqueue
(
Job
s
::
Mail
::
InviteUserByEmail
,
self
.
id
)
end
end
...
...
app/models/job/base.rb
deleted
100644 → 0
View file @
ec011f08
module
Job
class
Base
extend
ResqueJobLogging
end
end
app/models/jobs/base.rb
0 → 100644
View file @
97f80272
# Copyright (c) 2010-2011, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module
Jobs
class
Base
Dir
[
"
#{
Rails
.
root
}
/app/models/jobs/mail/*.rb"
].
each
{
|
file
|
require
file
}
extend
ResqueJobLogging
end
end
app/models/job/delete_account.rb
→
app/models/job
s
/delete_account.rb
View file @
97f80272
...
...
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
module
Job
module
Job
s
class
DeleteAccount
<
Base
@queue
=
:delete_account
def
self
.
perform
(
user_id
)
...
...
app/models/job/http_multi.rb
→
app/models/job
s
/http_multi.rb
View file @
97f80272
...
...
@@ -5,7 +5,7 @@
require
'uri'
require
File
.
join
(
Rails
.
root
,
'lib/hydra_wrapper'
)
module
Job
module
Job
s
class
HttpMulti
<
Base
@queue
=
:http
...
...
@@ -26,7 +26,7 @@ module Job
unless
hydra
.
failed_people
.
empty?
if
retry_count
<
MAX_RETRIES
Resque
.
enqueue
(
Job
::
HttpMulti
,
user_id
,
encoded_object_xml
,
hydra
.
failed_people
,
dispatcher_class_as_string
,
retry_count
+
1
)
Resque
.
enqueue
(
Job
s
::
HttpMulti
,
user_id
,
encoded_object_xml
,
hydra
.
failed_people
,
dispatcher_class_as_string
,
retry_count
+
1
)
else
Rails
.
logger
.
info
(
"event=http_multi_abandon sender_id=
#{
user_id
}
failed_recipient_ids='[
#{
person_ids
.
join
(
', '
)
}
] '"
)
end
...
...
app/models/job/mail/also_commented.rb
→
app/models/job
s
/mail/also_commented.rb
View file @
97f80272
module
Job
module
Job
s
module
Mail
class
AlsoCommented
<
Base
@queue
=
:mail
...
...
app/models/job/mail/comment_on_post.rb
→
app/models/job
s
/mail/comment_on_post.rb
View file @
97f80272
module
Job
module
Job
s
module
Mail
class
CommentOnPost
<
Base
@queue
=
:mail
...
...
app/models/job/mail/confirm_email.rb
→
app/models/job
s
/mail/confirm_email.rb
View file @
97f80272
module
Job
module
Job
s
module
Mail
class
ConfirmEmail
<
Base
@queue
=
:mail
...
...
app/models/job/mail/invite_user_by_email.rb
→
app/models/job
s
/mail/invite_user_by_email.rb
View file @
97f80272
...
...
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
module
Job
module
Job
s
module
Mail
class
InviteUserByEmail
<
Base
@queue
=
:mail
...
...
app/models/job/mail/liked.rb
→
app/models/job
s
/mail/liked.rb
View file @
97f80272
module
Job
module
Job
s
module
Mail
class
Liked
<
Base
@queue
=
:mail
...
...
app/models/job/mail/mentioned.rb
→
app/models/job
s
/mail/mentioned.rb
View file @
97f80272
...
...
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
module
Job
module
Job
s
module
Mail
class
Mentioned
<
Base
@queue
=
:mail
...
...
app/models/job/mail/private_message.rb
→
app/models/job
s
/mail/private_message.rb
View file @
97f80272
...
...
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
module
Job
module
Job
s
module
Mail
class
PrivateMessage
<
Base
@queue
=
:mail
...
...
app/models/job/mail/reshared.rb
→
app/models/job
s
/mail/reshared.rb
View file @
97f80272
module
Job
module
Job
s
module
Mail
class
Reshared
<
Base
@queue
=
:mail
...
...
app/models/job/mail/started_sharing.rb
→
app/models/job
s
/mail/started_sharing.rb
View file @
97f80272
...
...
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
module
Job
module
Job
s
module
Mail
class
StartedSharing
<
Base
@queue
=
:mail
...
...
app/models/job/notify_local_users.rb
→
app/models/job
s
/notify_local_users.rb
View file @
97f80272
...
...
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module
Job
module
Job
s
class
NotifyLocalUsers
<
Base
@queue
=
:receive_local
...
...
app/models/job/post_to_service.rb
→
app/models/job
s
/post_to_service.rb
View file @
97f80272
...
...
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
#
module
Job
module
Job
s
class
PostToService
<
Base
@queue
=
:http_service
...
...
app/models/job/process_photo.rb
→
app/models/job
s
/process_photo.rb
View file @
97f80272
...
...
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
module
Job
module
Job
s
class
ProcessPhoto
<
Base
@queue
=
:photos
def
self
.
perform
(
photo_id
)
...
...
app/models/job/publish_to_hub.rb
→
app/models/job
s
/publish_to_hub.rb
View file @
97f80272
...
...
@@ -2,7 +2,7 @@
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
module
Job
module
Job
s
class
PublishToHub
<
Base
@queue
=
:http_service
...
...
app/models/job/receive.rb
→
app/models/job
s
/receive.rb
View file @
97f80272
...
...
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
module
Job
module
Job
s
class
Receive
<
Base
@queue
=
:receive
...
...
app/models/job/receive_local_batch.rb
→
app/models/job
s
/receive_local_batch.rb
View file @
97f80272
...
...
@@ -5,7 +5,7 @@
require
File
.
join
(
Rails
.
root
,
'lib/postzord/receiver/private'
)
require
File
.
join
(
Rails
.
root
,
'lib/postzord/receiver/local_post_batch'
)
module
Job
module
Job
s
class
ReceiveLocalBatch
<
Base
@queue
=
:receive
...
...
app/models/job/receive_public_salmon.rb
→
app/models/job
s
/receive_public_salmon.rb
View file @
97f80272
...
...
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
require
File
.
join
(
Rails
.
root
,
'lib/postzord/receiver/private'
)
module
Job
module
Job
s
class
ReceivePublicSalmon
<
Base
@queue
=
:receive
...
...
app/models/job/receive_salmon.rb
→
app/models/job
s
/receive_salmon.rb
View file @
97f80272
...
...
@@ -4,7 +4,7 @@
require
File
.
join
(
Rails
.
root
,
'lib/postzord/receiver/private'
)
module
Job
module
Job
s
class
ReceiveSalmon
<
Base
@queue
=
:receive_salmon
...
...
app/models/job/resend_invitation.rb
→
app/models/job
s
/resend_invitation.rb
View file @
97f80272
...
...
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
module
Job
module
Job
s
class
ResendInvitation
<
Base
@queue
=
:mail
def
self
.
perform
(
invitation_id
)
...
...
app/models/job/socket_webfinger.rb
→
app/models/job
s
/socket_webfinger.rb
View file @
97f80272
...
...
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
module
Job
module
Job
s
class
SocketWebfinger
<
Base
@queue
=
:socket_webfinger
...
...
app/models/job/update_service_users.rb
→
app/models/job
s
/update_service_users.rb
View file @
97f80272
...
...
@@ -3,7 +3,7 @@
# the COPYRIGHT file.
module
Job
module
Job
s
class
UpdateServiceUsers
<
Base
@queue
=
:http_service
def
self
.
perform
(
service_id
)
...
...
app/models/notifications/also_commented.rb
View file @
97f80272
class
Notifications::AlsoCommented
<
Notification
def
mail_job
Job
::
Mail
::
AlsoCommented
Job
s
::
Mail
::
AlsoCommented
end
def
popup_translation_key
...
...
app/models/notifications/comment_on_post.rb
View file @
97f80272
class
Notifications::CommentOnPost
<
Notification
def
mail_job
Job
::
Mail
::
CommentOnPost
Job
s
::
Mail
::
CommentOnPost
end
def
popup_translation_key
...
...
app/models/notifications/liked.rb
View file @
97f80272
class
Notifications::Liked
<
Notification
def
mail_job
Job
::
Mail
::
Liked
Job
s
::
Mail
::
Liked
end
def
popup_translation_key
...
...
app/models/notifications/mentioned.rb
View file @
97f80272
class
Notifications::Mentioned
<
Notification
def
mail_job
Job
::
Mail
::
Mentioned
Job
s
::
Mail
::
Mentioned
end
def
popup_translation_key
...
...
app/models/notifications/private_message.rb
View file @
97f80272
class
Notifications::PrivateMessage
<
Notification
def
mail_job
Job
::
Mail
::
PrivateMessage
Job
s
::
Mail
::
PrivateMessage
end
def
popup_translation_key
'notifications.private_message'
...
...
app/models/notifications/request_accepted.rb
View file @
97f80272
class
Notifications::RequestAccepted
<
Notification
def
mail_job
Job
::
Mail
::
RequestAcceptance
Job
s
::
Mail
::
RequestAcceptance
end
def
popup_translation_key
'notifications.request_accepted'
...
...
app/models/notifications/reshared.rb
View file @
97f80272
class
Notifications::Reshared
<
Notification
def
mail_job
Job
::
Mail
::
Reshared
#Job::Mail::Liked
Job
s
::
Mail
::
Reshared
#Job
s
::Mail::Liked
end
def
popup_translation_key
...
...
app/models/notifications/started_sharing.rb
View file @
97f80272
class
Notifications::StartedSharing
<
Notification
def
mail_job
Job
::
Mail
::
StartedSharing
Job
s
::
Mail
::
StartedSharing
end
def
popup_translation_key
...
...
app/models/photo.rb
View file @
97f80272
...
...
@@ -94,7 +94,7 @@ class Photo < Post
end
def
queue_processing_job
Resque
.
enqueue
(
Job
::
ProcessPhoto
,
self
.
id
)
Resque
.
enqueue
(
Job
s
::
ProcessPhoto
,
self
.
id
)
end
def
process
...
...
app/models/user.rb
View file @
97f80272
...
...
@@ -266,7 +266,7 @@ class User < ActiveRecord::Base
######### Mailer #######################
def
mail
(
job
,
*
args
)
pref
=
job
.
to_s
.
gsub
(
'Job::Mail::'
,
''
).
underscore
pref
=
job
.
to_s
.
gsub
(
'Job
s
::Mail::'
,
''
).
underscore
if
(
self
.
disable_mail
==
false
&&
!
self
.
user_preferences
.
exists?
(
:email_type
=>
pref
))
Resque
.
enqueue
(
job
,
*
args
)
end
...
...
@@ -274,7 +274,7 @@ class User < ActiveRecord::Base
def
mail_confirm_email
return
false
if
unconfirmed_email
.
blank?
Resque
.
enqueue
(
Job
::
Mail
::
ConfirmEmail
,
id
)
Resque
.
enqueue
(
Job
s
::
Mail
::
ConfirmEmail
,
id
)
true
end
...
...
lib/postzord/dispatcher.rb
View file @
97f80272
...
...
@@ -96,7 +96,7 @@ class Postzord::Dispatcher
else
people
.
each
do
|
person
|
Rails
.
logger
.
info
(
"event=push route=local sender=
#{
@sender
.
person
.
diaspora_handle
}
recipient=
#{
person
.
diaspora_handle
}
payload_type=
#{
@object
.
class
}
"
)
Resque
.
enqueue
(
Job
::
Receive
,
person
.
owner_id
,
@xml
,
@sender
.
person
.
id
)
Resque
.
enqueue
(
Job
s
::
Receive
,
person
.
owner_id
,
@xml
,
@sender
.
person
.
id
)
end
end
end
...
...
@@ -104,13 +104,13 @@ class Postzord::Dispatcher
# @param people [Array<Person>] Recipients of the post
def
batch_deliver_to_local
(
people
)
ids
=
people
.
map
{
|
p
|
p
.
owner_id
}
Resque
.
enqueue
(
Job
::
ReceiveLocalBatch
,
@object
.
class
.
to_s
,
@object
.
id
,
ids
)
Resque
.
enqueue
(
Job
s
::
ReceiveLocalBatch
,
@object
.
class
.
to_s
,
@object
.
id
,
ids
)
Rails
.
logger
.
info
(
"event=push route=local sender=
#{
@sender
.
person
.
diaspora_handle
}
recipients=
#{
ids
.
join
(
','
)
}
payload_type=
#{
@object
.
class
}
"
)
end
def
deliver_to_hub
Rails
.
logger
.
debug
(
"event=post_to_service type=pubsub sender_handle=
#{
@sender
.
diaspora_handle
}
"
)
Resque
.
enqueue
(
Job
::
PublishToHub
,
@sender
.
public_url
)
Resque
.
enqueue
(
Job
s
::
PublishToHub
,
@sender
.
public_url
)
end
# @param url [String]
...
...
@@ -121,7 +121,7 @@ class Postzord::Dispatcher
end
if
@object
.
instance_of?
(
StatusMessage
)
services
.
each
do
|
service
|
Resque
.
enqueue
(
Job
::
PostToService
,
service
.
id
,
@object
.
id
,
url
)
Resque
.
enqueue
(
Job
s
::
PostToService
,
service
.
id
,
@object
.
id
,
url
)
end
end
end
...
...
@@ -137,7 +137,7 @@ class Postzord::Dispatcher
# @param services [Array<User>]
def
notify_users
(
users
)
return
unless
users
.
present?
&&
@object
.
respond_to?
(
:persisted?
)
Resque
.
enqueue
(
Job
::
NotifyLocalUsers
,
users
.
map
{
|
u
|
u
.
id
},
@object
.
class
.
to_s
,
@object
.
id
,
@object
.
author
.
id
)
Resque
.
enqueue
(
Job
s
::
NotifyLocalUsers
,
users
.
map
{
|
u
|
u
.
id
},
@object
.
class
.
to_s
,
@object
.
id
,
@object
.
author
.
id
)
end
# @param services [Array<User>]
...
...
@@ -152,7 +152,7 @@ class Postzord::Dispatcher
# @param remote_people [Array<Person>] Recipients of the post on other pods
# @return [void]
def
queue_remote_delivery_job
(
remote_people
)
Resque
.
enqueue
(
Job
::
HttpMulti
,
@sender
.
id
,
Base64
.
encode64
(
@object
.
to_diaspora_xml
),
remote_people
.
map
{
|
p
|
p
.
id
},
self
.
class
.
to_s
)
Resque
.
enqueue
(
Job
s
::
HttpMulti
,
@sender
.
id
,
Base64
.
encode64
(
@object
.
to_diaspora_xml
),
remote_people
.
map
{
|
p
|
p
.
id
},
self
.
class
.
to_s
)
end
end
lib/postzord/receiver/public.rb
View file @
97f80272
...
...
@@ -25,7 +25,7 @@ module Postzord
if
@object
.
respond_to?
(
:relayable?
)
receive_relayable
else
Resque
.
enqueue
(
Job
::
ReceiveLocalBatch
,
@object
.
id
,
self
.
recipient_user_ids
)
Resque
.
enqueue
(
Job
s
::
ReceiveLocalBatch
,
@object
.
id
,
self
.
recipient_user_ids
)
end
end
...
...
spec/controllers/people_controller_spec.rb
View file @
97f80272
...
...
@@ -387,7 +387,7 @@ describe PeopleController do
describe
'#webfinger'
do
it
'enqueues a webfinger job'
do
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
SocketWebfinger
,
@user
.
id
,
@user
.
diaspora_handle
,
anything
).
once
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
SocketWebfinger
,
@user
.
id
,
@user
.
diaspora_handle
,
anything
).
once
get
:retrieve_remote
,
:diaspora_handle
=>
@user
.
diaspora_handle
end
end
...
...
spec/controllers/publics_controller_spec.rb
View file @
97f80272
...
...
@@ -33,7 +33,7 @@ describe PublicsController do
it
'enqueues a ReceivePublicSalmon job'
do
xml
=
"stuff"
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
ReceivePublicSalmon
,
xml
)
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
ReceivePublicSalmon
,
xml
)
post
:receive_public
,
:xml
=>
xml
end
end
...
...
@@ -47,7 +47,7 @@ describe PublicsController do
end
it
'enqueues a receive job'
do
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
ReceiveSalmon
,
@user
.
id
,
xml
).
once
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
ReceiveSalmon
,
@user
.
id
,
xml
).
once
post
:receive
,
"guid"
=>
@user
.
person
.
guid
.
to_s
,
"xml"
=>
xml
end
...
...
@@ -60,7 +60,7 @@ describe PublicsController do
salmon_factory
=
Salmon
::
EncryptedSlap
.
create_by_user_and_activity
(
@user
,
xml2
)
enc_xml
=
salmon_factory
.
xml_for
(
user2
.
person
)
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
ReceiveSalmon
,
@user
.
id
,
enc_xml
).
once
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
ReceiveSalmon
,
@user
.
id
,
enc_xml
).
once
post
:receive
,
"guid"
=>
@user
.
person
.
guid
.
to_s
,
"xml"
=>
CGI
::
escape
(
enc_xml
)
end
...
...
spec/controllers/sessions_controller_spec.rb
View file @
97f80272
...
...
@@ -40,7 +40,7 @@ describe SessionsController do
it
'queues up an update job'
do
service
=
Services
::
Facebook
.
new
(
:access_token
=>
"yeah"
)
@user
.
services
<<
service
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
UpdateServiceUsers
,
service
.
id
)
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
UpdateServiceUsers
,
service
.
id
)
post
:create
,
{
"user"
=>
{
"remember_me"
=>
"0"
,
"username"
=>
@user
.
username
,
"password"
=>
"evankorth"
}}
end
...
...
spec/controllers/users_controller_spec.rb
View file @
97f80272
...
...
@@ -124,7 +124,7 @@ describe UsersController do
end
it
'sends out activation email on success'
do
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
Mail
::
ConfirmEmail
,
@user
.
id
).
once
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
Mail
::
ConfirmEmail
,
@user
.
id
).
once
put
(
:update
,
:id
=>
@user
.
id
,
:user
=>
{
:email
=>
"my@newemail.com"
})
end
end
...
...
@@ -169,7 +169,7 @@ describe UsersController do
describe
'#destroy'
do
it
'enqueues a delete job'
do
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
DeleteAccount
,
alice
.
id
)
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
DeleteAccount
,
alice
.
id
)
delete
:destroy
end
...
...
spec/lib/postzord/dispatcher_spec.rb
View file @
97f80272
...
...
@@ -227,7 +227,7 @@ describe Postzord::Dispatcher do
end
it
'should queue an HttpPost job for each remote person'
do
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
HttpMulti
,
alice
.
id
,
anything
,
@remote_people
.
map
{
|
p
|
p
.
id
},
anything
).
once
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
HttpMulti
,
alice
.
id
,
anything
,
@remote_people
.
map
{
|
p
|
p
.
id
},
anything
).
once
@mailman
.
send
(
:deliver_to_remote
,
@remote_people
)
end
end
...
...
@@ -240,7 +240,7 @@ describe Postzord::Dispatcher do
it
'queues a batch receive'
do
local_people
=
[]
local_people
<<
alice
.
person
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
ReceiveLocalBatch
,
@sm
.
class
.
to_s
,
@sm
.
id
,
[
alice
.
id
]).
once
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
ReceiveLocalBatch
,
@sm
.
class
.
to_s
,
@sm
.
id
,
[
alice
.
id
]).
once
@mailman
.
send
(
:deliver_to_local
,
local_people
)
end
...
...
@@ -264,8 +264,8 @@ describe Postzord::Dispatcher do
end
it
'queues a job to notify the hub'
do
Resque
.
stub!
(
:enqueue
).
with
(
Job
::
PostToService
,
anything
,
anything
,
anything
)
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
PublishToHub
,
alice
.
public_url
)
Resque
.
stub!
(
:enqueue
).
with
(
Job
s
::
PostToService
,
anything
,
anything
,
anything
)
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
PublishToHub
,
alice
.
public_url
)
@zord
.
send
(
:deliver_to_services
,
nil
,
[])
end
...
...
@@ -284,17 +284,17 @@ describe Postzord::Dispatcher do
alice
.
services
<<
@s2
mailman
=
Postzord
::
Dispatcher
.
build
(
alice
,
Factory
(
:status_message
))
Resque
.
stub!
(
:enqueue
).
with
(
Job
::
PublishToHub
,
anything
)
Resque
.
stub!
(
:enqueue
).
with
(
Job
::
HttpMulti
,
anything
,
anything
,
anything
)
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
PostToService
,
@s1
.
id
,
anything
,
anything
)
Resque
.
stub!
(
:enqueue
).
with
(
Job
s
::
PublishToHub
,
anything
)
Resque
.
stub!
(
:enqueue
).
with
(
Job
s
::
HttpMulti
,
anything
,
anything
,
anything
)
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
PostToService
,
@s1
.
id
,
anything
,
anything
)
mailman
.
post
(
:url
=>
"http://joindiaspora.com/p/123"
,
:services
=>
[
@s1
])
end
it
'does not push to services if none are specified'
do
mailman
=
Postzord
::
Dispatcher
.
build
(
alice
,
Factory
(
:status_message
))
Resque
.
stub!
(
:enqueue
).
with
(
Job
::
PublishToHub
,
anything
)
Resque
.
should_not_receive
(
:enqueue
).
with
(
Job
::
PostToService
,
anything
,
anything
,
anything
)
Resque
.
stub!
(
:enqueue
).
with
(
Job
s
::
PublishToHub
,
anything
)
Resque
.
should_not_receive
(
:enqueue
).
with
(
Job
s
::
PostToService
,
anything
,
anything
,
anything
)
mailman
.
post
(
:url
=>
"http://joindiaspora.com/p/123"
)
end
end
...
...
@@ -313,7 +313,7 @@ describe Postzord::Dispatcher do
describe
'#notify_users'
do
it
'enqueues a NotifyLocalUsers job'
do
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
NotifyLocalUsers
,
[
bob
.
id
],
@zord
.
object
.
class
.
to_s
,
@zord
.
object
.
id
,
@zord
.
object
.
author
.
id
)
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
NotifyLocalUsers
,
[
bob
.
id
],
@zord
.
object
.
class
.
to_s
,
@zord
.
object
.
id
,
@zord
.
object
.
author
.
id
)
@zord
.
send
(
:notify_users
,
[
bob
])
end
end
...
...
spec/lib/postzord/receiver/public_spec.rb
View file @
97f80272
...
...
@@ -55,8 +55,8 @@ describe Postzord::Receiver::Public do
@receiver
.
perform!
end
it
'enqueues a Job::ReceiveLocalBatch'
do
Resque
.
should_receive
(
:enqueue
).
with
(
Job
::
ReceiveLocalBatch
,
anything
,
anything
)
it
'enqueues a Job
s
::ReceiveLocalBatch'
do
Resque
.
should_receive
(
:enqueue
).
with
(
Job
s
::
ReceiveLocalBatch
,
anything
,
anything
)
@receiver
.
perform!
end
end
...
...
spec/models/job/delete_account_spec.rb
→
spec/models/job
s
/delete_account_spec.rb
View file @
97f80272
...
...
@@ -4,18 +4,18 @@
require
'spec_helper'
describe
Job
::
DeleteAccount
do
describe
Job
s
::
DeleteAccount
do
describe
'#perform'
do
it
'calls remove_all_traces'
do
stub_find_for
(
bob
)
bob
.
should_receive
(
:remove_all_traces
)
Job
::
DeleteAccount
.
perform
(
bob
.
id
)
Job
s
::
DeleteAccount
.
perform
(
bob
.
id
)
end
it
'calls destroy'
do
stub_find_for
(
bob
)
bob
.
should_receive
(
:destroy
)
Job
::
DeleteAccount
.
perform
(
bob
.
id
)
Job
s
::
DeleteAccount
.
perform
(
bob
.
id
)
end
def
stub_find_for
model
model
.
class
.
stub!
(
:find
)
do
|
id
,
conditions
|
...
...
spec/models/job/http_multi_spec.rb
→
spec/models/job
s
/http_multi_spec.rb
View file @
97f80272
require
'spec_helper'