bonfire-app/flavours/classic/config/bonfire_data.exs

496 lines
22 KiB
Elixir
Raw Normal View History

2020-11-28 11:12:32 +00:00
import Config
2020-11-06 17:57:15 +00:00
2020-12-21 15:52:33 +00:00
#### Base configuration
# Choose password hashing backend
# Note that this corresponds with our dependencies in mix.exs
hasher = if config_env() in [:dev, :test], do: Pbkdf2, else: Argon2
config :bonfire_data_identity, Bonfire.Data.Identity.Credential,
hasher_module: hasher
2020-12-10 12:50:56 +00:00
#### Sentinel Data Services
2020-11-06 17:57:15 +00:00
2021-06-15 18:48:36 +00:00
# Search these apps/extensions for Pointable ecto schema definitions to index
pointable_schema_extensions = [
2020-11-28 11:12:32 +00:00
:bonfire_data_access_control,
2020-12-10 12:50:56 +00:00
:bonfire_data_activity_pub,
2020-11-28 11:12:32 +00:00
:bonfire_data_identity,
:bonfire_data_social,
2020-11-07 14:05:06 +00:00
:bonfire,
2020-12-29 11:31:27 +00:00
:bonfire_quantify,
:bonfire_geolocate,
:bonfire_valueflows,
:bonfire_tag,
2021-01-02 16:02:47 +00:00
:bonfire_classify,
:bonfire_data_shared_users,
2021-05-29 16:34:44 +00:00
:bonfire_files
2020-11-06 17:57:15 +00:00
]
2021-06-15 18:48:36 +00:00
config :pointers, :search_path, pointable_schema_extensions
# Search these apps/extensions for context or queries modules to index (i.e. they contain modules with a queries_module/0 or context_modules/0 function)
context_and_queries_extensions = pointable_schema_extensions ++ [
:bonfire_common,
:bonfire_me,
:bonfire_social,
:bonfire_valueflows
]
config :bonfire, :query_modules_search_path, context_and_queries_extensions
2021-06-15 18:48:36 +00:00
config :bonfire, :context_modules_search_path, context_and_queries_extensions
2020-11-06 17:57:15 +00:00
2021-06-15 18:48:36 +00:00
# Search these apps/extensions for Verbs to index (i.e. they contain modules with a declare_verbs/0 function)
2020-12-10 12:50:56 +00:00
config :bonfire_data_access_control,
search_path: [
2021-06-15 18:48:36 +00:00
# :bonfire_me,
2021-03-16 15:54:01 +00:00
:bonfire_boundaries,
2021-06-15 18:48:36 +00:00
# :bonfire_social,
# :bonfire,
2020-12-10 12:50:56 +00:00
]
2021-06-01 12:44:06 +00:00
#### Alias modules for readability
alias Pointers.{Pointer, Table}
alias Bonfire.Data.AccessControl.{
2022-01-17 20:38:02 +00:00
Acl, Circle, Encircle, Controlled, InstanceAdmin, Grant, Verb,
2021-06-01 12:44:06 +00:00
}
alias Bonfire.Data.ActivityPub.{Actor, Peer, Peered}
2022-02-28 09:39:28 +00:00
alias Bonfire.Boundaries.Stereotyped
alias Bonfire.Data.Edges.{Edge,EdgeTotal}
2021-06-01 12:44:06 +00:00
alias Bonfire.Data.Identity.{
2022-03-06 11:26:10 +00:00
Account, Accounted, Caretaker, CareClosure, Character, Credential, Email, Named, Self, User,
2021-06-01 12:44:06 +00:00
}
alias Bonfire.Data.Social.{
2022-01-21 22:04:26 +00:00
Activity, Article, Block, Bookmark, Created, Feed, FeedPublish, Message, Follow,
2022-03-12 08:32:42 +00:00
Boost, Like, Flag, Mention, Post, PostContent, Profile, Replied, Request
2021-06-01 12:44:06 +00:00
}
alias Bonfire.Classify.Category
alias Bonfire.Geolocate.Geolocation
alias Bonfire.Files.Media
2022-01-20 19:23:10 +00:00
alias Bonfire.{Tag, Tag.Tagged}
2020-12-10 12:50:56 +00:00
2020-11-06 17:57:15 +00:00
#### Flexto Stitching
## WARNING: This is the flaky magic bit. We use configuration to
## compile extra stuff into modules. If you add new fields or
## relations to ecto models in a dependency, you must recompile that
## dependency for it to show up! You will probably find you need to
2020-11-30 10:00:11 +00:00
## `rm -Rf _build/*/lib/bonfire_data_*` a lot.
2020-11-06 17:57:15 +00:00
## Note: This does not apply to configuration for
## `Pointers.Changesets`, which is read at runtime, not compile time
2022-01-25 05:05:42 +00:00
edge = quote do
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
has_many :activities, unquote(Activity), foreign_key: :object_id, references: :id
2022-03-12 08:32:42 +00:00
has_one :request, unquote(Request), foreign_key: :id, references: :id
2022-01-25 05:05:42 +00:00
end
edges = quote do
unquote(edge)
2022-03-12 08:32:42 +00:00
has_one :created, unquote(Created), foreign_key: :id
has_one :caretaker, unquote(Caretaker), foreign_key: :id
2022-01-25 05:05:42 +00:00
has_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause
end
2020-12-10 12:50:56 +00:00
# first up, pointers could have all the mixins we're using. TODO
2021-05-22 18:41:36 +00:00
config :pointers, Pointer,
[code: quote do
@like_ulid "11KES11KET0BE11KEDY0VKN0WS"
@boost_ulid "300STANN0VNCERESHARESH0VTS"
@follow_ulid "70110WTHE1EADER1EADER1EADE"
2022-01-08 19:00:07 +00:00
# pointables
has_one :circle, unquote(Circle), foreign_key: :id
has_one :user, unquote(User), foreign_key: :id
has_one :post, unquote(Post), foreign_key: :id
has_one :message, unquote(Message), foreign_key: :id
2022-01-21 07:40:00 +00:00
has_one :category, unquote(Category), references: :id, foreign_key: :id
has_one :geolocation, unquote(Geolocation), references: :id, foreign_key: :id
2022-01-09 21:53:17 +00:00
# mixins
2022-02-28 09:39:28 +00:00
has_one :stereotyped, unquote(Stereotyped), foreign_key: :id
has_one :named, unquote(Named), foreign_key: :id
has_one :caretaker, unquote(Caretaker), foreign_key: :id
2022-03-06 11:26:10 +00:00
has_many :care_closure, unquote(CareClosure), foreign_key: :branch_id
2022-01-25 05:05:42 +00:00
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
has_one :created, unquote(Created), foreign_key: :id
has_one :peered, unquote(Peered), foreign_key: :id, references: :id
has_one :activity, unquote(Activity), foreign_key: :object_id, references: :id
has_one :post_content, unquote(PostContent), foreign_key: :id
has_one :replied, unquote(Replied), foreign_key: :id
has_one :profile, unquote(Profile), foreign_key: :id
has_one :character, unquote(Character), foreign_key: :id
has_one :actor, unquote(Actor), foreign_key: :id
2022-01-08 19:00:07 +00:00
has_one :edge, unquote(Edge), foreign_key: :id
2022-01-25 05:05:42 +00:00
2022-01-17 20:38:02 +00:00
has_one :like_count, unquote(EdgeTotal),
foreign_key: :id, references: :id, where: [table_id: @like_ulid]
has_one :boost_count, unquote(EdgeTotal),
foreign_key: :id, references: :id, where: [table_id: @boost_ulid]
has_one :follow_count, unquote(EdgeTotal),
foreign_key: :id, references: :id, where: [table_id: @follow_ulid]
2022-01-25 05:05:42 +00:00
2022-01-08 19:00:07 +00:00
has_many :direct_replies, unquote(Replied), foreign_key: :reply_to_id
2022-01-25 05:05:42 +00:00
# add references of tags to any tagged Pointer
2022-01-20 19:23:10 +00:00
has_many :tagged, unquote(Tagged), foreign_key: :id, references: :id
2022-01-21 07:40:00 +00:00
many_to_many :tags, unquote(Pointer),
2022-01-21 02:11:03 +00:00
join_through: unquote(Tagged),
2021-05-22 18:41:36 +00:00
unique: true,
2022-01-20 19:23:10 +00:00
join_keys: [id: :id, tag_id: :id],
2021-05-22 18:41:36 +00:00
on_replace: :delete
end]
2021-05-22 18:41:36 +00:00
2020-12-10 12:50:56 +00:00
config :pointers, Table, []
# now let's weave everything else together for convenience
2020-11-28 11:12:32 +00:00
# bonfire_data_access_control
2020-11-06 17:57:15 +00:00
2020-12-10 12:50:56 +00:00
config :bonfire_data_access_control, Acl,
[code: quote do
2022-01-17 20:38:02 +00:00
# this allows us to identify acls for the user which have special
# meaning to the system, such as "public" or "private"
2022-02-28 09:39:28 +00:00
has_one :stereotyped, unquote(Stereotyped), foreign_key: :id
has_one :caretaker, unquote(Caretaker), foreign_key: :id
2022-01-17 20:38:02 +00:00
has_one :named, unquote(Named), foreign_key: :id
2022-01-19 20:08:58 +00:00
# has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
end]
2020-12-10 12:50:56 +00:00
2022-01-08 19:00:07 +00:00
config :bonfire_data_access_control, Circle,
[code: quote do
2022-01-08 19:00:07 +00:00
has_one :caretaker, unquote(Caretaker), foreign_key: :id
has_one :named, unquote(Named), foreign_key: :id
2022-01-19 20:08:58 +00:00
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
2022-02-28 09:39:28 +00:00
has_one :stereotyped, unquote(Stereotyped), foreign_key: :id
end]
2021-03-20 22:21:00 +00:00
2022-01-08 19:00:07 +00:00
config :bonfire_data_access_control, Controlled, []
config :bonfire_data_access_control, Encircle, []
2022-01-17 20:38:02 +00:00
config :bonfire_data_access_control, Grant,
[code: quote do
has_one :caretaker, unquote(Caretaker), foreign_key: :id
2022-01-19 20:08:58 +00:00
# has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
2022-01-17 20:38:02 +00:00
end]
2020-12-01 13:06:01 +00:00
config :bonfire_data_access_control, Verb, []
2020-11-28 14:22:03 +00:00
2022-02-28 09:39:28 +00:00
config :bonfire_boundaries, Stereotyped,
2022-02-16 09:54:39 +00:00
[code: quote do
2022-02-28 09:39:28 +00:00
has_one :named, unquote(Named), foreign_key: :id, references: :stereotype_id
2022-02-16 09:54:39 +00:00
end]
2020-11-28 14:22:03 +00:00
# bonfire_data_activity_pub
config :bonfire_data_activity_pub, Actor,
[code: quote do
2022-01-19 20:08:58 +00:00
belongs_to :character, unquote(Character), foreign_key: :id, define_field: false
belongs_to :user, unquote(User), foreign_key: :id, define_field: false
has_one :peered, unquote(Peered), foreign_key: :id, references: :id
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
end]
2020-12-10 12:50:56 +00:00
config :bonfire_data_activity_pub, Peer, []
config :bonfire_data_activity_pub, Peered, []
2020-11-28 11:12:32 +00:00
# bonfire_data_identity
2020-11-06 17:57:15 +00:00
2020-11-28 11:12:32 +00:00
config :bonfire_data_identity, Account,
[code: quote do
has_one :credential, unquote(Credential),foreign_key: :id
has_one :email, unquote(Email), foreign_key: :id
2022-01-17 20:38:02 +00:00
many_to_many :users, unquote(User),
join_through: "bonfire_data_identity_accounted",
join_keys: [account_id: :id, id: :id]
many_to_many :shared_users, unquote(User),
join_through: "bonfire_data_shared_user_accounts",
join_keys: [account_id: :id, shared_user_id: :id]
end]
2020-11-06 17:57:15 +00:00
2020-12-10 12:50:56 +00:00
config :bonfire_data_identity, Accounted,
[code: quote do
belongs_to :user, unquote(User), foreign_key: :id, define_field: false
end]
2020-12-10 12:50:56 +00:00
2022-03-06 11:30:33 +00:00
config :bonfire_data_identity, Caretaker,
[code: quote do
has_one :user, unquote(User), foreign_key: :id, references: :caretaker_id
has_one :profile, unquote(Profile), foreign_key: :id, references: :caretaker_id
has_one :character, unquote(Character), foreign_key: :id, references: :caretaker_id
end]
2020-12-10 12:50:56 +00:00
2021-01-30 15:48:59 +00:00
config :bonfire_data_identity, Character,
[code: quote do
@follow_ulid "70110WTHE1EADER1EADER1EADE"
has_one :peered, unquote(Peered), references: :id, foreign_key: :id
2022-03-06 11:26:10 +00:00
has_one :actor, unquote(Actor), foreign_key: :id, references: :id
has_one :profile, unquote(Profile), foreign_key: :id, references: :id
has_one :user, unquote(User), foreign_key: :id, references: :id
has_one :feed, unquote(Feed), foreign_key: :id, references: :id
has_many :followers, unquote(Follow), foreign_key: :following_id, references: :id
has_many :followed, unquote(Follow), foreign_key: :follower_id, references: :id
2022-01-17 20:38:02 +00:00
has_one :follow_count, unquote(EdgeTotal),
foreign_key: :id, references: :id, where: [table_id: @follow_ulid]
end]
2020-11-06 17:57:15 +00:00
2020-11-28 11:12:32 +00:00
config :bonfire_data_identity, Credential,
[code: quote do
belongs_to :account, unquote(Account), foreign_key: :id, define_field: false
end]
2020-11-06 17:57:15 +00:00
2020-11-28 11:12:32 +00:00
config :bonfire_data_identity, Email,
[must_confirm: true,
code: quote do
belongs_to :account, unquote(Account), foreign_key: :id, define_field: false
end]
2020-11-06 17:57:15 +00:00
2020-12-16 10:33:57 +00:00
config :bonfire_data_identity, Self, []
2020-11-28 11:12:32 +00:00
config :bonfire_data_identity, User,
[code: quote do
has_one :accounted, unquote(Accounted), foreign_key: :id
has_one :profile, unquote(Profile), foreign_key: :id
has_one :character, unquote(Character), foreign_key: :id
has_one :actor, unquote(Actor), foreign_key: :id
2022-01-17 20:38:02 +00:00
has_one :instance_admin, unquote(InstanceAdmin), foreign_key: :id, on_replace: :update
has_one :self, unquote(Self), foreign_key: :id
2022-01-27 19:38:25 +00:00
has_one :peered, unquote(Peered), references: :id, foreign_key: :id
has_many :encircles, unquote(Encircle), foreign_key: :subject_id
2022-02-12 05:54:56 +00:00
has_one :shared_user, unquote(Bonfire.Data.SharedUser), foreign_key: :id
has_many :created, unquote(Created), foreign_key: :creator_id
2022-01-19 20:08:58 +00:00
has_many :creations, through: [:created, :pointer] # todo: stop through
has_many :posts, through: [:created, :post] # todo: stop through
has_many :user_activities, unquote(Activity), foreign_key: :subject_id, references: :id
2022-01-19 20:08:58 +00:00
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
many_to_many :caretaker_accounts, unquote(Account),
2022-01-17 20:38:02 +00:00
join_through: "bonfire_data_shared_user_accounts",
join_keys: [shared_user_id: :id, account_id: :id]
# has_many :account, through: [:accounted, :account] # this is private info, do not expose
# has_one :geolocation, Bonfire.Geolocate.Geolocation
end]
2020-11-28 11:12:32 +00:00
2022-01-17 20:38:02 +00:00
### bonfire_data_social
2020-11-28 11:12:32 +00:00
2021-01-30 14:07:52 +00:00
config :bonfire_data_social, Activity,
[code: quote do
@like_ulid "11KES11KET0BE11KEDY0VKN0WS"
@boost_ulid "300STANN0VNCERESHARESH0VTS"
@follow_ulid "70110WTHE1EADER1EADER1EADE"
2022-01-11 01:35:18 +00:00
# has_one :object_created, unquote(Created), foreign_key: :id
2022-01-08 19:00:07 +00:00
# belongs_to :object_peered, unquote(Peered), foreign_key: :id, define_field: false
# belongs_to :object_post, unquote(Post), foreign_key: :id, define_field: false
2022-01-11 01:35:18 +00:00
# belongs_to :object_post_content, unquote(PostContent), foreign_key: :id, define_field: false
2022-01-08 19:00:07 +00:00
# belongs_to :object_message, unquote(Message), foreign_key: :id, define_field: false
2022-01-11 09:48:07 +00:00
has_one :replied, unquote(Replied), foreign_key: :id, references: :object_id
# has_one: [reply_to: {[through: [:replied, :reply_to]]}],
# has_one: [reply_to_post: {[through: [:replied, :reply_to_post]]}],
# has_one: [reply_to_post_content: {[through: [:replied, :reply_to_post_content]]}],
# has_one: [reply_to_creator_character: {[through: [:replied, :reply_to_creator_character]]}],
# has_one: [reply_to_creator_profile: {[through: [:replied, :reply_to_creator_profile]]}],
# has_one: [thread_post: {[through: [:replied, :thread_post]]}],
# has_one: [thread_post_content: {[through: [:replied, :thread_post_content]]}],
# has_one: [object_creator_user: {[through: [:object_created, :creator_user]]}],
# has_one: [object_creator_character: {[through: [:object_created, :creator_character]]}],
# has_one: [object_creator_profile: {[through: [:object_created, :creator_profile]]}],
# ugly workaround needed for querying
has_one :activity, unquote(Activity), foreign_key: :id, references: :id
2022-01-11 09:48:07 +00:00
has_one :like_count, unquote(EdgeTotal), foreign_key: :id, references: :object_id, where: [table_id: @like_ulid]
has_one :boost_count, unquote(EdgeTotal), foreign_key: :id, references: :object_id, where: [table_id: @boost_ulid]
has_one :follow_count, unquote(EdgeTotal), foreign_key: :id, references: :object_id, where: [table_id: @follow_ulid]
2022-01-25 09:01:42 +00:00
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :object_id
has_many :tagged, unquote(Tagged), foreign_key: :id, references: :object_id
2022-01-22 20:17:20 +00:00
has_many :feed_publishes, unquote(FeedPublish), references: :id, foreign_key: :activity_id
2022-01-21 07:40:00 +00:00
many_to_many :tags, unquote(Pointer),
join_through: unquote(Tagged),
unique: true,
join_keys: [id: :object_id, tag_id: :id],
on_replace: :delete
end]
2021-01-30 14:07:52 +00:00
2022-01-19 03:35:46 +00:00
config :bonfire_data_social, Edge,
[code: quote do
2022-01-25 05:05:42 +00:00
unquote(edge)
# TODO: requires composite foreign keys:
2022-01-19 03:35:46 +00:00
# has_one :activity, unquote(Activity),
# foreign_key: [:table_id, :object_id], references: [:table_id, :object_id]
end]
2021-12-24 09:44:29 +00:00
2021-01-30 15:48:59 +00:00
config :bonfire_data_social, Feed,
[code: quote do
2022-01-24 21:57:52 +00:00
# belongs_to :character, unquote(Character), foreign_key: :id, define_field: false
# belongs_to :user, unquote(User), foreign_key: :id, define_field: false
end]
2021-01-30 15:48:59 +00:00
2020-12-16 10:33:57 +00:00
config :bonfire_data_social, FeedPublish, []
2021-03-20 13:30:55 +00:00
config :bonfire_data_social, Follow,
[code: quote do
2022-01-25 05:05:42 +00:00
unquote(edges)
end]
2021-12-24 08:22:23 +00:00
# belongs_to: [follower_character: {Character, foreign_key: :follower_id, define_field: false}],
# belongs_to: [follower_profile: {Profile, foreign_key: :follower_id, define_field: false}],
# belongs_to: [followed_character: {Character, foreign_key: :followed_id, define_field: false}],
# belongs_to: [followed_profile: {Profile, foreign_key: :followed_id, define_field: false}]
2021-03-20 13:30:55 +00:00
config :bonfire_data_social, Block,
[code: quote do
2022-01-25 05:05:42 +00:00
unquote(edges)
end]
2021-11-30 08:07:14 +00:00
config :bonfire_data_social, Boost,
[code: quote do
2022-01-25 05:05:42 +00:00
unquote(edges)
end]
2021-12-24 08:22:23 +00:00
# has_one: [activity: {Activity, foreign_key: :object_id, references: :boosted_id}] # requires an ON clause
2021-11-30 08:07:14 +00:00
2021-06-12 13:51:39 +00:00
config :bonfire_data_social, Like,
[code: quote do
2022-01-25 05:05:42 +00:00
unquote(edges)
end]
2021-12-24 08:22:23 +00:00
# has_one: [activity: {Activity, foreign_key: :object_id, references: :liked_id}] # requires an ON clause
2021-06-12 13:51:39 +00:00
2022-01-09 21:53:17 +00:00
config :bonfire_data_social, Flag,
[code: quote do
2022-03-12 08:32:42 +00:00
unquote(edges)
end]
config :bonfire_data_social, Request,
[code: quote do
2022-01-25 05:05:42 +00:00
unquote(edges)
2022-01-09 21:53:17 +00:00
end]
2022-01-25 05:05:42 +00:00
config :bonfire_data_social, Bookmark,
[code: quote do
unquote(edges)
end]
2021-04-07 11:23:14 +00:00
config :bonfire_data_social, Message,
[code: quote do
@like_ulid "11KES11KET0BE11KEDY0VKN0WS"
@boost_ulid "300STANN0VNCERESHARESH0VTS"
has_one :post_content, unquote(PostContent), foreign_key: :id
has_one :created, unquote(Created), foreign_key: :id
has_one :peered, unquote(Peered), references: :id, foreign_key: :id
has_many :activities, unquote(Activity), foreign_key: :object_id, references: :id
2022-01-17 20:38:02 +00:00
has_one :activity, unquote(Activity), foreign_key: :object_id,
references: :id # requires an ON clause
has_one :replied, unquote(Replied), foreign_key: :id
2022-01-25 09:01:42 +00:00
has_one :like_count, unquote(EdgeTotal),
foreign_key: :id, references: :id, where: [table_id: @like_ulid]
has_one :boost_count, unquote(EdgeTotal),
foreign_key: :id, references: :id, where: [table_id: @boost_ulid]
has_many :direct_replies, unquote(Replied), foreign_key: :reply_to_id
2022-01-17 20:38:02 +00:00
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
2022-01-25 05:05:42 +00:00
has_one :caretaker, unquote(Caretaker), foreign_key: :id
2022-01-27 03:14:19 +00:00
has_many :tagged, unquote(Tagged), foreign_key: :id, references: :id
many_to_many :tags, unquote(Pointer),
join_through: unquote(Tagged),
unique: true,
join_keys: [id: :id, tag_id: :id],
on_replace: :delete
end]
2021-04-07 11:23:14 +00:00
2020-12-16 10:33:57 +00:00
config :bonfire_data_social, Mention, []
config :bonfire_data_social, Named, []
2020-11-28 11:12:32 +00:00
2020-12-01 13:12:03 +00:00
config :bonfire_data_social, Post,
[code: quote do
@like_ulid "11KES11KET0BE11KEDY0VKN0WS"
@boost_ulid "300STANN0VNCERESHARESH0VTS"
2022-01-22 20:17:20 +00:00
has_one :caretaker, unquote(Caretaker), foreign_key: :id
has_one :post_content, unquote(PostContent), foreign_key: :id
has_one :created, unquote(Created), foreign_key: :id
has_one :peered, unquote(Peered), references: :id, foreign_key: :id
# has_one: [creator_user: {[through: [:created, :creator_user]]}],
# has_one: [creator_character: {[through: [:created, :creator_character]]}],
# has_one: [creator_profile: {[through: [:created, :creator_profile]]}],
has_many :activities, unquote(Activity), foreign_key: :object_id, references: :id
has_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause
has_one :replied, unquote(Replied), foreign_key: :id
# has_one: [reply_to: {[through: [:replied, :reply_to]]}],
# has_one: [reply_to_post: {[through: [:replied, :reply_to_post]]}],
# has_one: [reply_to_post_content: {[through: [:replied, :reply_to_post_content]]}],
# has_one: [reply_to_creator_character: {[through: [:replied, :reply_to_creator_character]]}],
# has_one: [reply_to_creator_profile: {[through: [:replied, :reply_to_creator_profile]]}],
has_many :direct_replies, unquote(Replied), foreign_key: :reply_to_id
# has_one: [thread_post: {[through: [:replied, :thread_post]]}],
# has_one: [thread_post_content: {[through: [:replied, :thread_post_content]]}],
2022-01-17 20:38:02 +00:00
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
2022-01-25 09:01:42 +00:00
has_one :like_count, unquote(EdgeTotal),
foreign_key: :id, references: :id, where: [table_id: @like_ulid]
has_one :boost_count, unquote(EdgeTotal),
foreign_key: :id, references: :id, where: [table_id: @boost_ulid]
2022-01-21 02:11:03 +00:00
has_many :tagged, unquote(Tagged), foreign_key: :id, references: :id
2022-01-21 07:40:00 +00:00
many_to_many :tags, unquote(Pointer),
2022-01-21 02:11:03 +00:00
join_through: unquote(Tagged),
2022-01-20 06:03:48 +00:00
unique: true,
2022-01-20 19:23:10 +00:00
join_keys: [id: :id, tag_id: :id],
2022-01-20 06:03:48 +00:00
on_replace: :delete
end]
2020-12-01 13:12:03 +00:00
2022-01-19 20:08:58 +00:00
config :bonfire_data_social, PostContent,
[code: quote do
2022-02-17 02:02:46 +00:00
has_one :created, unquote(Created), foreign_key: :id, references: :id
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
2022-01-21 02:11:03 +00:00
field :hashtags, {:array, :any}, virtual: true # used in changesets
field :mentions, {:array, :any}, virtual: true # used in changesets
2022-01-19 20:08:58 +00:00
end]
2020-12-16 10:33:57 +00:00
2021-02-02 15:36:12 +00:00
config :bonfire_data_social, Replied,
[code: quote do
@like_ulid "11KES11KET0BE11KEDY0VKN0WS"
@boost_ulid "300STANN0VNCERESHARESH0VTS"
belongs_to :post, unquote(Post), foreign_key: :id, define_field: false
belongs_to :post_content,unquote(PostContent), foreign_key: :id, define_field: false
has_many :activities, unquote(Activity), foreign_key: :object_id, references: :id
has_one :activity, unquote(Activity), foreign_key: :object_id, references: :id
2022-01-21 02:11:03 +00:00
field :replying_to, :map, virtual: true # used in changesets
has_one :reply_to_post, unquote(Post), foreign_key: :id, references: :reply_to_id
has_one :reply_to_post_content, unquote(PostContent), foreign_key: :id, references: :reply_to_id
has_one :reply_to_created, unquote(Created), foreign_key: :id, references: :reply_to_id
# has_one :reply_to_creator_user, through: [:reply_to_created, :creator_user]
# has_one :reply_to_creator_character, through: [:reply_to_created, :creator_character]
# has_one :reply_to_creator_profile, through: [:reply_to_created, :creator_profile]
has_many :direct_replies, unquote(Replied), foreign_key: :reply_to_id, references: :id
has_many :thread_replies, unquote(Replied), foreign_key: :thread_id, references: :id
has_one :thread_post, unquote(Post), foreign_key: :id, references: :thread_id
has_one :thread_post_content, unquote(PostContent), foreign_key: :id, references: :thread_id
2022-01-17 20:38:02 +00:00
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
2022-01-25 09:01:42 +00:00
has_one :like_count, unquote(EdgeTotal),
foreign_key: :id, references: :id, where: [table_id: @like_ulid]
has_one :boost_count, unquote(EdgeTotal),
foreign_key: :id, references: :id, where: [table_id: @boost_ulid]
end]
2021-02-02 15:36:12 +00:00
2021-02-13 11:50:05 +00:00
config :bonfire_data_social, Created,
[code: quote do
belongs_to :creator_user, unquote(User), foreign_key: :creator_id, define_field: false
belongs_to :creator_character, unquote(Character), foreign_key: :creator_id, define_field: false
belongs_to :creator_profile, unquote(Profile), foreign_key: :creator_id, define_field: false
has_one :peered, unquote(Peered), foreign_key: :id, references: :id
has_one :post, unquote(Post), foreign_key: :id, references: :id
end]
2020-12-16 10:54:35 +00:00
2020-12-16 10:33:57 +00:00
config :bonfire_data_social, Profile,
[code: quote do
belongs_to :user, unquote(User), foreign_key: :id, define_field: false
2022-01-17 20:38:02 +00:00
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
end]
2022-01-17 20:38:02 +00:00
2021-04-13 19:24:31 +00:00
######### other extensions
# add references of tagged objects to any Category
config :bonfire_classify, Category,
[code: quote do
2022-01-19 20:08:58 +00:00
# has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
2022-01-21 07:40:00 +00:00
many_to_many :tags, unquote(Pointer),
join_through: unquote(Tagged),
2021-04-26 14:49:37 +00:00
unique: true,
2022-01-20 19:23:10 +00:00
join_keys: [tag_id: :id, id: :id],
2021-04-26 14:49:37 +00:00
on_replace: :delete
end]
2021-04-13 19:24:31 +00:00
config :bonfire_files, Media,
[code: quote do
field :url, :string, virtual: true
2022-01-19 20:08:58 +00:00
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
end]