Gab-Social/app/models/link_block.rb
mgabdev 51fa8f2eb4 Added/Updated admin dashboard tables
• Added:
- New Account filtering
- PreviewCard viewing/sorting/filtering deleting (todo)
- DeletePreviewCardWorker, Service
- Status viewing/sorting/filtering deleting
- ChatMessage viewing/sorting/filtering deleting (todo)
- Account > Follows view

• Updated:
- LinkBlock to sort alphabetically
- Groups to be under "Moderation" instead of "Admin" in navigation.rb
- Status in admin to have group name/link
- Reports reset button
- Group filtering/sorting
- LinkBlock filtering/sorting
- Account now has bio and few more data points in dashboard
2021-01-19 01:25:25 -05:00

38 lines
949 B
Ruby

# frozen_string_literal: true
# == Schema Information
#
# Table name: link_blocks
#
# id :bigint(8) not null, primary key
# link :string default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
#
class LinkBlock < ApplicationRecord
include LinkNormalizable
validates :link, presence: true, uniqueness: true
scope :alphabetical, -> { reorder(link: :asc) }
def self.block?(text)
return false if text.nil?
return false if text.length < 1
return true if text.include? '.weebly.com'
urls = text.scan(FetchLinkCardService::URL_PATTERN).map {|array|
Addressable::URI.parse(array[0]).normalize
}
url = urls.first
return false if url.nil?
link_for_fetch = TagManager.instance.normalize_link(url)
link_for_fetch = link_for_fetch.chomp("/")
where("LOWER(link) LIKE LOWER(?)", "%#{link_for_fetch}%").exists?
end
end