mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-21 19:22:18 -05:00
49 lines
1.5 KiB
Ruby
49 lines
1.5 KiB
Ruby
class Creator < ApplicationRecord
|
|
include ApplicationUploader::Attachment(:avatar)
|
|
include ApplicationUploader::Attachment(:banner)
|
|
include Followable
|
|
include CaberObject
|
|
include Linkable
|
|
include Sluggable
|
|
include PublicIDable
|
|
include Commentable
|
|
include Indexable
|
|
include FaspClient::DataSharing::Lifecycle
|
|
|
|
broadcasts_refreshes
|
|
|
|
acts_as_federails_actor username_field: :slug, name_field: :name, profile_url_method: :url_for
|
|
fasp_share_lifecycle category: "account", uri_method: :fasp_uri, only_if: :public_and_indexable?
|
|
|
|
has_many :models, dependent: :nullify
|
|
has_many :collections, dependent: :nullify
|
|
has_many :groups, dependent: :destroy
|
|
|
|
validates :name, presence: true, uniqueness: {case_sensitive: false}, length: SAFE_NAME_LENGTH
|
|
validates :slug, presence: true, multimodel_uniqueness: {punctuation_sensitive: false, case_sensitive: false, check: FederailsCommon::FEDIVERSE_USERNAMES}, format: {with: /\A[[:alnum:]\-_]+\z/}, length: SAFE_NAME_LENGTH
|
|
|
|
# Explicitly explain serialization for MariaDB
|
|
serialize :avatar_data, coder: CrossDbJsonSerializer
|
|
serialize :banner_data, coder: CrossDbJsonSerializer
|
|
|
|
def fasp_uri
|
|
federails_actor&.federated_url
|
|
end
|
|
|
|
def name_with_domain
|
|
remote? ? name + " (#{federails_actor.server})" : name
|
|
end
|
|
|
|
def to_param
|
|
slug
|
|
end
|
|
|
|
def self.find_param(param)
|
|
find_by!(slug: param)
|
|
end
|
|
|
|
def to_activitypub_object
|
|
ActivityPub::CreatorSerializer.new(self).serialize
|
|
end
|
|
end
|