Albums almost done, group, chat moderation, photo, video page updates
This commit is contained in:
mgabdev
2020-12-21 13:25:05 -05:00
parent a2ffbadedb
commit ee91809e8d
45 changed files with 1013 additions and 509 deletions

View File

@@ -0,0 +1,44 @@
# frozen_string_literal: true
class CreateChatConversationService < BaseService
def call(current_account, other_accounts)
@current_account = current_account
@other_accounts = other_accounts
return nil if @other_accounts.nil? || @current_account.nil?
# check if already created
chat = ChatConversationAccount.find_by(account: current_account, participant_account_ids: account_ids_as_array)
return chat unless chat.nil?
# : todo :
# check if allow anyone to message then create with approved:true
# unique account id, participants
chat_conversation = ChatConversation.create
my_chat = ChatConversationAccount.create!(
account: current_account,
participant_account_ids: [@account.id.to_s],
chat_conversation: chat_conversation,
is_approved: true
)
# : todo : if multiple ids
if @account.id != current_account.id
their_chat = ChatConversationAccount.create!(
account: @account,
participant_account_ids: [current_account.id.to_s],
chat_conversation: chat_conversation,
is_approved: false # : todo : check if allow all else default as request
)
end
end
def account_ids_as_array
@other_accounts.map { |account| account.id.to_s }
end
end

View File

@@ -78,16 +78,12 @@ class FetchLinkCardService < BaseService
end
def parse_urls
# : todo :
if @status.local?
urls = @status.text.scan(URL_PATTERN).map { |array| Addressable::URI.parse(array[0]).normalize }
return urls.reject { |uri| bad_url?(uri) }.first
else
html = Nokogiri::HTML(@status.text)
links = html.css('a')
urls = links.map { |a| Addressable::URI.parse(a['href']).normalize unless skip_link?(a) }.compact
return nil
end
urls.reject { |uri| bad_url?(uri) }.first
end
def bad_url?(uri)