Add service for posting statuses (normal and replies), mention regex to
fetch webfinger information of mentioned accounts
This commit is contained in:
parent
8da8387afe
commit
79609d6270
3 changed files with 32 additions and 0 deletions
19
app/services/post_status_service.rb
Normal file
19
app/services/post_status_service.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
class PostStatusService < BaseService
|
||||
def call(account, text, in_reply_to = nil)
|
||||
status = account.statuses.create!(text: text, thread: in_reply_to)
|
||||
|
||||
status.text.scan(Account::MENTION_RE).each do |match|
|
||||
next if match.first.split('@').size == 1
|
||||
username, domain = match.first.split('@')
|
||||
local_account = Account.find_by(username: username, domain: domain)
|
||||
next unless local_account.nil?
|
||||
follow_remote_account_service.("acct:#{match.first}")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def follow_remote_account_service
|
||||
@follow_remote_account_service ||= FollowRemoteAccountService.new
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue