Skip to content

Commit

Permalink
Service to reblog statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Feb 24, 2016
1 parent c967802 commit 42eeecb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/services/post_status_service.rb
@@ -1,4 +1,9 @@
class PostStatusService < BaseService
# Post a text status update, fetch and notify remote users mentioned
# @param [Account] account Account from which to post
# @param [String] text Message
# @param [Status] in_reply_to Optional status to reply to
# @return [Status]
def call(account, text, in_reply_to = nil)
status = account.statuses.create!(text: text, thread: in_reply_to)

Expand All @@ -14,6 +19,8 @@ def call(account, text, in_reply_to = nil)
next if mentioned_account.local?
send_interaction_service.(status.stream_entry, mentioned_account)
end

status
end

private
Expand Down
18 changes: 18 additions & 0 deletions app/services/reblog_service.rb
@@ -0,0 +1,18 @@
class ReblogService < BaseService
# Reblog a status and notify its remote author
# @param [Account] account Account to reblog from
# @param [Status] reblogged_status Status to be reblogged
# @return [Status]
def call(account, reblogged_status)
reblog = account.statuses.create!(reblog: reblogged_status, text: '')
return reblog if reblogged_status.local?
send_interaction_service.(reblog.stream_entry, reblogged_status.account)
reblog
end

private

def send_interaction_service
@send_interaction_service ||= SendInteractionService.new
end
end

0 comments on commit 42eeecb

Please sign in to comment.