mirror of
https://github.com/bonfire-networks/bonfire-app.git
synced 2024-05-15 07:32:42 +00:00
Mig & config
This commit is contained in:
parent
a1bfb76a30
commit
9eb82adcab
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -49,6 +49,7 @@ flavours/*/config/prod/
|
|||
/config
|
||||
priv/seed_data
|
||||
assets/static/data
|
||||
priv/repo
|
||||
|
||||
# user-local overrides for mess
|
||||
deps.path
|
||||
|
|
2
Makefile
2
Makefile
|
@ -56,6 +56,8 @@ pre-config: pre-init ## Initialise env files, and create some required folders,
|
|||
pre-init:
|
||||
@echo "Setting flavour to $(FLAVOUR_PATH)"
|
||||
@ln -sfn $(FLAVOUR_PATH)/config ./config
|
||||
@rm -rf ./priv/repo
|
||||
@cp -rn $(FLAVOUR_PATH)/repo ./priv/repo
|
||||
@mkdir -p data/
|
||||
@rm -rf ./data/current_flavour
|
||||
@ln -sf ../$(FLAVOUR_PATH) ./data/current_flavour
|
||||
|
|
|
@ -63,6 +63,7 @@ alias Bonfire.Data.Social.{
|
|||
}
|
||||
alias Bonfire.Classify.Category
|
||||
alias Bonfire.Geolocate.Geolocation
|
||||
alias Bonfire.Files
|
||||
alias Bonfire.Files.Media
|
||||
alias Bonfire.{Tag, Tag.Tagged}
|
||||
|
||||
|
@ -112,8 +113,17 @@ common_assocs = %{
|
|||
controlled: quote(do: has_many(:controlled, unquote(Controlled), unquote(mixin))),
|
||||
# Inserts the object into selected feeds.
|
||||
feed_publishes: quote(do: has_many(:feed_publishes, unquote(FeedPublish), unquote(mixin))),
|
||||
|
||||
# Information that this object has some files
|
||||
files: quote(do: has_many(:files, unquote(Files), unquote(mixin))),
|
||||
# The actual files
|
||||
media: quote(do: many_to_many(:media, unquote(Media), join_through: unquote(Files), unique: true, join_keys: [id: :id, media_id: :id], on_replace: :delete)),
|
||||
|
||||
# Information that this object tagged other objects.
|
||||
tagged: quote(do: has_many(:tagged, unquote(Tagged), unquote(mixin))),
|
||||
# The actual tags
|
||||
tags: quote(do: many_to_many(:tags, unquote(Pointer), join_through: unquote(Tagged), unique: true, join_keys: [id: :id, tag_id: :id], on_replace: :delete)),
|
||||
|
||||
|
||||
### Regular has_many associations
|
||||
|
||||
|
@ -165,7 +175,7 @@ config :pointers, Pointer,
|
|||
# mixins
|
||||
unquote_splicing(pointer_mixins)
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media]))
|
||||
# has_many
|
||||
unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes]))
|
||||
|
||||
|
@ -178,11 +188,6 @@ config :pointers, Pointer,
|
|||
has_one :follow_count, unquote(EdgeTotal), foreign_key: :id, references: :id,
|
||||
where: [table_id: @follow_ulid]
|
||||
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :pointers, Table, []
|
||||
|
@ -342,6 +347,7 @@ config :bonfire_data_social, Activity,
|
|||
# mixins linked to the object rather than the activity:
|
||||
has_one :created, unquote(Created), foreign_key: :id, references: :object_id
|
||||
has_one :replied, unquote(Replied), foreign_key: :id, references: :object_id
|
||||
field :path, EctoMaterializedPath.ULIDs, virtual: true
|
||||
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]
|
||||
|
@ -352,7 +358,12 @@ config :bonfire_data_social, Activity,
|
|||
unique: true,
|
||||
join_keys: [id: :object_id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
field :path, EctoMaterializedPath.ULIDs, virtual: true
|
||||
has_many :files, unquote(Files), foreign_key: :id, references: :object_id
|
||||
many_to_many :media, unquote(Media),
|
||||
join_through: unquote(Files),
|
||||
unique: true,
|
||||
join_keys: [id: :object_id, media_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_data_social, APActivity,
|
||||
|
@ -433,18 +444,12 @@ config :bonfire_data_social, Message,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :feed_publishes, :tagged, :tags, :files, :media]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
# special
|
||||
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 :tagged, unquote(Tagged), unquote(mixin)
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_data_social, Mention, []
|
||||
|
@ -457,7 +462,7 @@ config :bonfire_data_social, Post,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
# special
|
||||
|
@ -477,11 +482,6 @@ config :bonfire_data_social, Post,
|
|||
references: :id, foreign_key: :id, where: [table_id: @like_ulid]
|
||||
has_one :boost_count, unquote(EdgeTotal),
|
||||
references: :id, foreign_key: :id, where: [table_id: @boost_ulid]
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
|
||||
|
@ -569,13 +569,7 @@ config :bonfire_geolocate, Bonfire.Geolocate.Geolocation,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :actor, :peered, :profile, :character]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
# add references of tagged objects to any Geolocation
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
end]
|
||||
|
||||
config :bonfire_valueflows, ValueFlows.EconomicEvent,
|
||||
|
@ -583,7 +577,7 @@ config :bonfire_valueflows, ValueFlows.EconomicEvent,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) # TODO :caretaker
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -593,7 +587,7 @@ config :bonfire_valueflows, ValueFlows.EconomicResource,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -603,7 +597,7 @@ config :bonfire_valueflows, ValueFlows.Process,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -613,7 +607,7 @@ config :bonfire_valueflows, ValueFlows.Planning.Intent,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -623,7 +617,7 @@ config :bonfire_valueflows, ValueFlows.Proposal,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
|
|
@ -8,7 +8,7 @@ config :waffle,
|
|||
|
||||
image_media_types = ["image/png", "image/jpeg", "image/gif", "image/svg+xml", "image/tiff"]
|
||||
|
||||
all_media_types = image_media_types ++ [
|
||||
all_allowed_media_types = image_media_types ++ [
|
||||
"text/plain",
|
||||
# doc
|
||||
"text/csv",
|
||||
|
@ -43,6 +43,9 @@ all_media_types = image_media_types ++ [
|
|||
"video/webm",
|
||||
]
|
||||
|
||||
config :bonfire, Bonfire.Files, image_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files, all_allowed_media_types: all_allowed_media_types
|
||||
|
||||
config :bonfire, Bonfire.Files.IconUploader, allowed_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files.ImageUploader, allowed_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files.DocumentUploader, allowed_media_types: all_media_types
|
||||
config :bonfire, Bonfire.Files.DocumentUploader, allowed_media_types: all_allowed_media_types
|
||||
|
|
|
@ -13,6 +13,7 @@ alias Bonfire.Social.Acts.{
|
|||
Creator,
|
||||
Edges,
|
||||
Feeds,
|
||||
Files,
|
||||
LivePush,
|
||||
MeiliSearch,
|
||||
Posts,
|
||||
|
@ -55,6 +56,7 @@ config :bonfire_social, Bonfire.Social.Posts,
|
|||
PostContents, # with a sanitised body and tags extracted,
|
||||
{Caretaker, on: :post}, # a caretaker,
|
||||
{Creator, on: :post}, # and a creator,
|
||||
{Files, on: :post}, # possibly with uploaded files,
|
||||
{Threaded, on: :post}, # possibly occurring in a thread,
|
||||
{Tags, on: :post}, # with extracted tags fully hooked up,
|
||||
{Boundaries, on: :post}, # and the appropriate boundaries established,
|
||||
|
|
|
@ -50,7 +50,7 @@ config :ecto_sparkles, :otp_app, :bonfire
|
|||
config :bonfire, :ecto_repos, [Bonfire.Repo]
|
||||
config :bonfire, Bonfire.Repo,
|
||||
types: Bonfire.PostgresTypes, # point to the appropriate definition to support any Postgres extensions used by your Bonfire flavour or extensions
|
||||
priv: flavour_path <> "/repo",
|
||||
# priv: flavour_path <> "/repo",
|
||||
log: false
|
||||
config :ecto_sparkles, :otp_app, :bonfire
|
||||
config :ecto_shorts, repo: Bonfire.Repo, error_module: EctoShorts.Actions.Error
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
defmodule Bonfire.Repo.Migrations.AddFiles do
|
||||
use Ecto.Migration
|
||||
|
||||
import Bonfire.Files.Media.Migration
|
||||
import Bonfire.Files.Media.Migrations
|
||||
import Pointers.Migration
|
||||
|
||||
def up do
|
||||
Bonfire.Files.Media.Migration.migrate_media()
|
||||
Bonfire.Files.Media.Migrations.migrate_media()
|
||||
end
|
||||
|
||||
def down do
|
||||
Bonfire.Files.Media.Migration.migrate_media()
|
||||
Bonfire.Files.Media.Migrations.migrate_media()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
defmodule Bonfire.Repo.Migrations.AddFilesMixin do
|
||||
use Ecto.Migration
|
||||
|
||||
import Bonfire.Files.Migrations
|
||||
import Pointers.Migration
|
||||
|
||||
def up do
|
||||
alter table("bonfire_files_media") do # cleanup old stuff
|
||||
remove_if_exists :created_at, :utc_datetime_usec
|
||||
remove_if_exists :updated_at, :utc_datetime_usec
|
||||
end
|
||||
|
||||
Bonfire.Files.Migrations.migrate_files()
|
||||
end
|
||||
|
||||
def down do
|
||||
Bonfire.Files.Migrations.migrate_files()
|
||||
end
|
||||
end
|
|
@ -63,6 +63,7 @@ alias Bonfire.Data.Social.{
|
|||
}
|
||||
alias Bonfire.Classify.Category
|
||||
alias Bonfire.Geolocate.Geolocation
|
||||
alias Bonfire.Files
|
||||
alias Bonfire.Files.Media
|
||||
alias Bonfire.{Tag, Tag.Tagged}
|
||||
|
||||
|
@ -112,8 +113,17 @@ common_assocs = %{
|
|||
controlled: quote(do: has_many(:controlled, unquote(Controlled), unquote(mixin))),
|
||||
# Inserts the object into selected feeds.
|
||||
feed_publishes: quote(do: has_many(:feed_publishes, unquote(FeedPublish), unquote(mixin))),
|
||||
|
||||
# Information that this object has some files
|
||||
files: quote(do: has_many(:files, unquote(Files), unquote(mixin))),
|
||||
# The actual files
|
||||
media: quote(do: many_to_many(:media, unquote(Media), join_through: unquote(Files), unique: true, join_keys: [id: :id, media_id: :id], on_replace: :delete)),
|
||||
|
||||
# Information that this object tagged other objects.
|
||||
tagged: quote(do: has_many(:tagged, unquote(Tagged), unquote(mixin))),
|
||||
# The actual tags
|
||||
tags: quote(do: many_to_many(:tags, unquote(Pointer), join_through: unquote(Tagged), unique: true, join_keys: [id: :id, tag_id: :id], on_replace: :delete)),
|
||||
|
||||
|
||||
### Regular has_many associations
|
||||
|
||||
|
@ -165,7 +175,7 @@ config :pointers, Pointer,
|
|||
# mixins
|
||||
unquote_splicing(pointer_mixins)
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media]))
|
||||
# has_many
|
||||
unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes]))
|
||||
|
||||
|
@ -178,11 +188,6 @@ config :pointers, Pointer,
|
|||
has_one :follow_count, unquote(EdgeTotal), foreign_key: :id, references: :id,
|
||||
where: [table_id: @follow_ulid]
|
||||
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :pointers, Table, []
|
||||
|
@ -342,6 +347,7 @@ config :bonfire_data_social, Activity,
|
|||
# mixins linked to the object rather than the activity:
|
||||
has_one :created, unquote(Created), foreign_key: :id, references: :object_id
|
||||
has_one :replied, unquote(Replied), foreign_key: :id, references: :object_id
|
||||
field :path, EctoMaterializedPath.ULIDs, virtual: true
|
||||
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]
|
||||
|
@ -352,6 +358,12 @@ config :bonfire_data_social, Activity,
|
|||
unique: true,
|
||||
join_keys: [id: :object_id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
has_many :files, unquote(Files), foreign_key: :id, references: :object_id
|
||||
many_to_many :media, unquote(Media),
|
||||
join_through: unquote(Files),
|
||||
unique: true,
|
||||
join_keys: [id: :object_id, media_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_data_social, APActivity,
|
||||
|
@ -432,18 +444,12 @@ config :bonfire_data_social, Message,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :feed_publishes, :tagged, :tags, :files, :media]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
# special
|
||||
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 :tagged, unquote(Tagged), unquote(mixin)
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_data_social, Mention, []
|
||||
|
@ -456,7 +462,7 @@ config :bonfire_data_social, Post,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
# special
|
||||
|
@ -476,11 +482,6 @@ config :bonfire_data_social, Post,
|
|||
references: :id, foreign_key: :id, where: [table_id: @like_ulid]
|
||||
has_one :boost_count, unquote(EdgeTotal),
|
||||
references: :id, foreign_key: :id, where: [table_id: @boost_ulid]
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
|
||||
|
@ -568,13 +569,7 @@ config :bonfire_geolocate, Bonfire.Geolocate.Geolocation,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :actor, :peered, :profile, :character]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
# add references of tagged objects to any Geolocation
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
end]
|
||||
|
||||
config :bonfire_valueflows, ValueFlows.EconomicEvent,
|
||||
|
@ -582,7 +577,7 @@ config :bonfire_valueflows, ValueFlows.EconomicEvent,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) # TODO :caretaker
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -592,7 +587,7 @@ config :bonfire_valueflows, ValueFlows.EconomicResource,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -602,7 +597,7 @@ config :bonfire_valueflows, ValueFlows.Process,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -612,7 +607,7 @@ config :bonfire_valueflows, ValueFlows.Planning.Intent,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -622,7 +617,7 @@ config :bonfire_valueflows, ValueFlows.Proposal,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
|
|
@ -8,7 +8,7 @@ config :waffle,
|
|||
|
||||
image_media_types = ["image/png", "image/jpeg", "image/gif", "image/svg+xml", "image/tiff"]
|
||||
|
||||
all_media_types = image_media_types ++ [
|
||||
all_allowed_media_types = image_media_types ++ [
|
||||
"text/plain",
|
||||
# doc
|
||||
"text/csv",
|
||||
|
@ -43,6 +43,9 @@ all_media_types = image_media_types ++ [
|
|||
"video/webm",
|
||||
]
|
||||
|
||||
config :bonfire, Bonfire.Files, image_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files, all_allowed_media_types: all_allowed_media_types
|
||||
|
||||
config :bonfire, Bonfire.Files.IconUploader, allowed_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files.ImageUploader, allowed_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files.DocumentUploader, allowed_media_types: all_media_types
|
||||
config :bonfire, Bonfire.Files.DocumentUploader, allowed_media_types: all_allowed_media_types
|
||||
|
|
|
@ -13,6 +13,7 @@ alias Bonfire.Social.Acts.{
|
|||
Creator,
|
||||
Edges,
|
||||
Feeds,
|
||||
Files,
|
||||
LivePush,
|
||||
MeiliSearch,
|
||||
Posts,
|
||||
|
@ -55,6 +56,7 @@ config :bonfire_social, Bonfire.Social.Posts,
|
|||
PostContents, # with a sanitised body and tags extracted,
|
||||
{Caretaker, on: :post}, # a caretaker,
|
||||
{Creator, on: :post}, # and a creator,
|
||||
{Files, on: :post}, # possibly with uploaded files,
|
||||
{Threaded, on: :post}, # possibly occurring in a thread,
|
||||
{Tags, on: :post}, # with extracted tags fully hooked up,
|
||||
{Boundaries, on: :post}, # and the appropriate boundaries established,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
defmodule Bonfire.Repo.Migrations.AddFiles do
|
||||
use Ecto.Migration
|
||||
|
||||
import Bonfire.Files.Media.Migration
|
||||
import Bonfire.Files.Media.Migrations
|
||||
import Pointers.Migration
|
||||
|
||||
def up do
|
||||
Bonfire.Files.Media.Migration.migrate_media()
|
||||
Bonfire.Files.Media.Migrations.migrate_media()
|
||||
end
|
||||
|
||||
def down do
|
||||
Bonfire.Files.Media.Migration.migrate_media()
|
||||
Bonfire.Files.Media.Migrations.migrate_media()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -63,6 +63,7 @@ alias Bonfire.Data.Social.{
|
|||
}
|
||||
alias Bonfire.Classify.Category
|
||||
alias Bonfire.Geolocate.Geolocation
|
||||
alias Bonfire.Files
|
||||
alias Bonfire.Files.Media
|
||||
alias Bonfire.{Tag, Tag.Tagged}
|
||||
|
||||
|
@ -112,8 +113,17 @@ common_assocs = %{
|
|||
controlled: quote(do: has_many(:controlled, unquote(Controlled), unquote(mixin))),
|
||||
# Inserts the object into selected feeds.
|
||||
feed_publishes: quote(do: has_many(:feed_publishes, unquote(FeedPublish), unquote(mixin))),
|
||||
|
||||
# Information that this object has some files
|
||||
files: quote(do: has_many(:files, unquote(Files), unquote(mixin))),
|
||||
# The actual files
|
||||
media: quote(do: many_to_many(:media, unquote(Media), join_through: unquote(Files), unique: true, join_keys: [id: :id, media_id: :id], on_replace: :delete)),
|
||||
|
||||
# Information that this object tagged other objects.
|
||||
tagged: quote(do: has_many(:tagged, unquote(Tagged), unquote(mixin))),
|
||||
# The actual tags
|
||||
tags: quote(do: many_to_many(:tags, unquote(Pointer), join_through: unquote(Tagged), unique: true, join_keys: [id: :id, tag_id: :id], on_replace: :delete)),
|
||||
|
||||
|
||||
### Regular has_many associations
|
||||
|
||||
|
@ -165,7 +175,7 @@ config :pointers, Pointer,
|
|||
# mixins
|
||||
unquote_splicing(pointer_mixins)
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media]))
|
||||
# has_many
|
||||
unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes]))
|
||||
|
||||
|
@ -178,11 +188,6 @@ config :pointers, Pointer,
|
|||
has_one :follow_count, unquote(EdgeTotal), foreign_key: :id, references: :id,
|
||||
where: [table_id: @follow_ulid]
|
||||
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :pointers, Table, []
|
||||
|
@ -342,6 +347,7 @@ config :bonfire_data_social, Activity,
|
|||
# mixins linked to the object rather than the activity:
|
||||
has_one :created, unquote(Created), foreign_key: :id, references: :object_id
|
||||
has_one :replied, unquote(Replied), foreign_key: :id, references: :object_id
|
||||
field :path, EctoMaterializedPath.ULIDs, virtual: true
|
||||
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]
|
||||
|
@ -352,6 +358,12 @@ config :bonfire_data_social, Activity,
|
|||
unique: true,
|
||||
join_keys: [id: :object_id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
has_many :files, unquote(Files), foreign_key: :id, references: :object_id
|
||||
many_to_many :media, unquote(Media),
|
||||
join_through: unquote(Files),
|
||||
unique: true,
|
||||
join_keys: [id: :object_id, media_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_data_social, APActivity,
|
||||
|
@ -432,18 +444,12 @@ config :bonfire_data_social, Message,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :feed_publishes, :tagged, :tags, :files, :media]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
# special
|
||||
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 :tagged, unquote(Tagged), unquote(mixin)
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_data_social, Mention, []
|
||||
|
@ -456,7 +462,7 @@ config :bonfire_data_social, Post,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
# special
|
||||
|
@ -476,11 +482,6 @@ config :bonfire_data_social, Post,
|
|||
references: :id, foreign_key: :id, where: [table_id: @like_ulid]
|
||||
has_one :boost_count, unquote(EdgeTotal),
|
||||
references: :id, foreign_key: :id, where: [table_id: @boost_ulid]
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
|
||||
|
@ -563,12 +564,20 @@ config :bonfire_classify, Category,
|
|||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_geolocate, Bonfire.Geolocate.Geolocation,
|
||||
[code: quote do
|
||||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :actor, :peered, :profile, :character]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
end]
|
||||
|
||||
config :bonfire_valueflows, ValueFlows.EconomicEvent,
|
||||
[code: quote do
|
||||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) # TODO :caretaker
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -578,7 +587,7 @@ config :bonfire_valueflows, ValueFlows.EconomicResource,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -588,7 +597,7 @@ config :bonfire_valueflows, ValueFlows.Process,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -598,7 +607,7 @@ config :bonfire_valueflows, ValueFlows.Planning.Intent,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -608,7 +617,7 @@ config :bonfire_valueflows, ValueFlows.Proposal,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
|
|
@ -8,7 +8,7 @@ config :waffle,
|
|||
|
||||
image_media_types = ["image/png", "image/jpeg", "image/gif", "image/svg+xml", "image/tiff"]
|
||||
|
||||
all_media_types = image_media_types ++ [
|
||||
all_allowed_media_types = image_media_types ++ [
|
||||
"text/plain",
|
||||
# doc
|
||||
"text/csv",
|
||||
|
@ -43,6 +43,9 @@ all_media_types = image_media_types ++ [
|
|||
"video/webm",
|
||||
]
|
||||
|
||||
config :bonfire, Bonfire.Files, image_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files, all_allowed_media_types: all_allowed_media_types
|
||||
|
||||
config :bonfire, Bonfire.Files.IconUploader, allowed_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files.ImageUploader, allowed_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files.DocumentUploader, allowed_media_types: all_media_types
|
||||
config :bonfire, Bonfire.Files.DocumentUploader, allowed_media_types: all_allowed_media_types
|
||||
|
|
|
@ -13,14 +13,39 @@ alias Bonfire.Social.Acts.{
|
|||
Creator,
|
||||
Edges,
|
||||
Feeds,
|
||||
Files,
|
||||
LivePush,
|
||||
MeiliSearch,
|
||||
Posts,
|
||||
Objects,
|
||||
PostContents,
|
||||
Tags,
|
||||
Threaded,
|
||||
}
|
||||
|
||||
delete_object = [
|
||||
# Create a changeset for deletion
|
||||
{Objects.Delete, on: :object},
|
||||
|
||||
# mark for deletion
|
||||
{Bonfire.Ecto.Acts.Delete, on: :object,
|
||||
delete_extra_associations: [
|
||||
:tagged,
|
||||
]
|
||||
},
|
||||
|
||||
# Now we have a short critical section
|
||||
Ecto.Begin,
|
||||
Ecto.Work, # Run our deletes
|
||||
Ecto.Commit,
|
||||
|
||||
{MeiliSearch.Queue, on: :object}, # Enqueue for un-indexing by meilisearch
|
||||
|
||||
# Oban would rather we put these here than in the transaction
|
||||
# above because it knows better than us, obviously.
|
||||
{ActivityPub, on: :object}, # Prepare for federation and add to deletion queue (oban).
|
||||
]
|
||||
|
||||
config :bonfire_social, Bonfire.Social.Follows, []
|
||||
|
||||
config :bonfire_social, Bonfire.Social.Posts,
|
||||
|
@ -31,14 +56,13 @@ config :bonfire_social, Bonfire.Social.Posts,
|
|||
PostContents, # with a sanitised body and tags extracted,
|
||||
{Caretaker, on: :post}, # a caretaker,
|
||||
{Creator, on: :post}, # and a creator,
|
||||
{Files, on: :post}, # possibly with uploaded files,
|
||||
{Threaded, on: :post}, # possibly occurring in a thread,
|
||||
{Tags, on: :post}, # with extracted tags fully hooked up,
|
||||
{Boundaries, on: :post}, # and the appropriate boundaries established,
|
||||
{Activity, on: :post}, # summarised by an activity,
|
||||
{Feeds, on: :post}, # appearing in feeds.
|
||||
|
||||
MeiliSearch.Prepare, # Prepare for search indexing or undexing
|
||||
|
||||
# Now we have a short critical section
|
||||
Ecto.Begin,
|
||||
Ecto.Work, # Run our inserts
|
||||
|
@ -53,4 +77,11 @@ config :bonfire_social, Bonfire.Social.Posts,
|
|||
# above because it knows better than us, obviously.
|
||||
{ActivityPub, on: :post}, # Prepare for federation and do the queue insert (oban).
|
||||
],
|
||||
|
||||
delete: delete_object,
|
||||
]
|
||||
|
||||
config :bonfire_social, Bonfire.Social.Objects,
|
||||
epics: [
|
||||
delete: delete_object,
|
||||
]
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
defmodule Bonfire.Repo.Migrations.AddFiles do
|
||||
use Ecto.Migration
|
||||
|
||||
import Bonfire.Files.Media.Migration
|
||||
import Bonfire.Files.Media.Migrations
|
||||
import Pointers.Migration
|
||||
|
||||
def up do
|
||||
Bonfire.Files.Media.Migration.migrate_media()
|
||||
Bonfire.Files.Media.Migrations.migrate_media()
|
||||
end
|
||||
|
||||
def down do
|
||||
Bonfire.Files.Media.Migration.migrate_media()
|
||||
Bonfire.Files.Media.Migrations.migrate_media()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -63,6 +63,7 @@ alias Bonfire.Data.Social.{
|
|||
}
|
||||
alias Bonfire.Classify.Category
|
||||
alias Bonfire.Geolocate.Geolocation
|
||||
alias Bonfire.Files
|
||||
alias Bonfire.Files.Media
|
||||
alias Bonfire.{Tag, Tag.Tagged}
|
||||
|
||||
|
@ -112,8 +113,17 @@ common_assocs = %{
|
|||
controlled: quote(do: has_many(:controlled, unquote(Controlled), unquote(mixin))),
|
||||
# Inserts the object into selected feeds.
|
||||
feed_publishes: quote(do: has_many(:feed_publishes, unquote(FeedPublish), unquote(mixin))),
|
||||
|
||||
# Information that this object has some files
|
||||
files: quote(do: has_many(:files, unquote(Files), unquote(mixin))),
|
||||
# The actual files
|
||||
media: quote(do: many_to_many(:media, unquote(Media), join_through: unquote(Files), unique: true, join_keys: [id: :id, media_id: :id], on_replace: :delete)),
|
||||
|
||||
# Information that this object tagged other objects.
|
||||
tagged: quote(do: has_many(:tagged, unquote(Tagged), unquote(mixin))),
|
||||
# The actual tags
|
||||
tags: quote(do: many_to_many(:tags, unquote(Pointer), join_through: unquote(Tagged), unique: true, join_keys: [id: :id, tag_id: :id], on_replace: :delete)),
|
||||
|
||||
|
||||
### Regular has_many associations
|
||||
|
||||
|
@ -165,7 +175,7 @@ config :pointers, Pointer,
|
|||
# mixins
|
||||
unquote_splicing(pointer_mixins)
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media]))
|
||||
# has_many
|
||||
unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes]))
|
||||
|
||||
|
@ -178,11 +188,6 @@ config :pointers, Pointer,
|
|||
has_one :follow_count, unquote(EdgeTotal), foreign_key: :id, references: :id,
|
||||
where: [table_id: @follow_ulid]
|
||||
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :pointers, Table, []
|
||||
|
@ -342,6 +347,7 @@ config :bonfire_data_social, Activity,
|
|||
# mixins linked to the object rather than the activity:
|
||||
has_one :created, unquote(Created), foreign_key: :id, references: :object_id
|
||||
has_one :replied, unquote(Replied), foreign_key: :id, references: :object_id
|
||||
field :path, EctoMaterializedPath.ULIDs, virtual: true
|
||||
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]
|
||||
|
@ -352,6 +358,12 @@ config :bonfire_data_social, Activity,
|
|||
unique: true,
|
||||
join_keys: [id: :object_id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
has_many :files, unquote(Files), foreign_key: :id, references: :object_id
|
||||
many_to_many :media, unquote(Media),
|
||||
join_through: unquote(Files),
|
||||
unique: true,
|
||||
join_keys: [id: :object_id, media_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_data_social, APActivity,
|
||||
|
@ -432,18 +444,12 @@ config :bonfire_data_social, Message,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :feed_publishes, :tagged, :tags, :files, :media]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
# special
|
||||
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 :tagged, unquote(Tagged), unquote(mixin)
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_data_social, Mention, []
|
||||
|
@ -456,7 +462,7 @@ config :bonfire_data_social, Post,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
# special
|
||||
|
@ -476,11 +482,6 @@ config :bonfire_data_social, Post,
|
|||
references: :id, foreign_key: :id, where: [table_id: @like_ulid]
|
||||
has_one :boost_count, unquote(EdgeTotal),
|
||||
references: :id, foreign_key: :id, where: [table_id: @boost_ulid]
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
|
||||
|
@ -563,12 +564,20 @@ config :bonfire_classify, Category,
|
|||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_geolocate, Bonfire.Geolocate.Geolocation,
|
||||
[code: quote do
|
||||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :actor, :peered, :profile, :character]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
end]
|
||||
|
||||
config :bonfire_valueflows, ValueFlows.EconomicEvent,
|
||||
[code: quote do
|
||||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) # TODO :caretaker
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -578,7 +587,7 @@ config :bonfire_valueflows, ValueFlows.EconomicResource,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -588,7 +597,7 @@ config :bonfire_valueflows, ValueFlows.Process,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -598,7 +607,7 @@ config :bonfire_valueflows, ValueFlows.Planning.Intent,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -608,7 +617,7 @@ config :bonfire_valueflows, ValueFlows.Proposal,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
|
|
@ -8,7 +8,7 @@ config :waffle,
|
|||
|
||||
image_media_types = ["image/png", "image/jpeg", "image/gif", "image/svg+xml", "image/tiff"]
|
||||
|
||||
all_media_types = image_media_types ++ [
|
||||
all_allowed_media_types = image_media_types ++ [
|
||||
"text/plain",
|
||||
# doc
|
||||
"text/csv",
|
||||
|
@ -43,6 +43,9 @@ all_media_types = image_media_types ++ [
|
|||
"video/webm",
|
||||
]
|
||||
|
||||
config :bonfire, Bonfire.Files, image_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files, all_allowed_media_types: all_allowed_media_types
|
||||
|
||||
config :bonfire, Bonfire.Files.IconUploader, allowed_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files.ImageUploader, allowed_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files.DocumentUploader, allowed_media_types: all_media_types
|
||||
config :bonfire, Bonfire.Files.DocumentUploader, allowed_media_types: all_allowed_media_types
|
||||
|
|
|
@ -13,14 +13,39 @@ alias Bonfire.Social.Acts.{
|
|||
Creator,
|
||||
Edges,
|
||||
Feeds,
|
||||
Files,
|
||||
LivePush,
|
||||
MeiliSearch,
|
||||
Posts,
|
||||
Objects,
|
||||
PostContents,
|
||||
Tags,
|
||||
Threaded,
|
||||
}
|
||||
|
||||
delete_object = [
|
||||
# Create a changeset for deletion
|
||||
{Objects.Delete, on: :object},
|
||||
|
||||
# mark for deletion
|
||||
{Bonfire.Ecto.Acts.Delete, on: :object,
|
||||
delete_extra_associations: [
|
||||
:tagged,
|
||||
]
|
||||
},
|
||||
|
||||
# Now we have a short critical section
|
||||
Ecto.Begin,
|
||||
Ecto.Work, # Run our deletes
|
||||
Ecto.Commit,
|
||||
|
||||
{MeiliSearch.Queue, on: :object}, # Enqueue for un-indexing by meilisearch
|
||||
|
||||
# Oban would rather we put these here than in the transaction
|
||||
# above because it knows better than us, obviously.
|
||||
{ActivityPub, on: :object}, # Prepare for federation and add to deletion queue (oban).
|
||||
]
|
||||
|
||||
config :bonfire_social, Bonfire.Social.Follows, []
|
||||
|
||||
config :bonfire_social, Bonfire.Social.Posts,
|
||||
|
@ -31,14 +56,13 @@ config :bonfire_social, Bonfire.Social.Posts,
|
|||
PostContents, # with a sanitised body and tags extracted,
|
||||
{Caretaker, on: :post}, # a caretaker,
|
||||
{Creator, on: :post}, # and a creator,
|
||||
{Files, on: :post}, # possibly with uploaded files,
|
||||
{Threaded, on: :post}, # possibly occurring in a thread,
|
||||
{Tags, on: :post}, # with extracted tags fully hooked up,
|
||||
{Boundaries, on: :post}, # and the appropriate boundaries established,
|
||||
{Activity, on: :post}, # summarised by an activity,
|
||||
{Feeds, on: :post}, # appearing in feeds.
|
||||
|
||||
MeiliSearch.Prepare, # Prepare for search indexing or undexing
|
||||
|
||||
# Now we have a short critical section
|
||||
Ecto.Begin,
|
||||
Ecto.Work, # Run our inserts
|
||||
|
@ -53,4 +77,11 @@ config :bonfire_social, Bonfire.Social.Posts,
|
|||
# above because it knows better than us, obviously.
|
||||
{ActivityPub, on: :post}, # Prepare for federation and do the queue insert (oban).
|
||||
],
|
||||
|
||||
delete: delete_object,
|
||||
]
|
||||
|
||||
config :bonfire_social, Bonfire.Social.Objects,
|
||||
epics: [
|
||||
delete: delete_object,
|
||||
]
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
defmodule Bonfire.Repo.Migrations.AddFiles do
|
||||
use Ecto.Migration
|
||||
|
||||
import Bonfire.Files.Media.Migration
|
||||
import Bonfire.Files.Media.Migrations
|
||||
import Pointers.Migration
|
||||
|
||||
def up do
|
||||
Bonfire.Files.Media.Migration.migrate_media()
|
||||
Bonfire.Files.Media.Migrations.migrate_media()
|
||||
end
|
||||
|
||||
def down do
|
||||
Bonfire.Files.Media.Migration.migrate_media()
|
||||
Bonfire.Files.Media.Migrations.migrate_media()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -63,6 +63,7 @@ alias Bonfire.Data.Social.{
|
|||
}
|
||||
alias Bonfire.Classify.Category
|
||||
alias Bonfire.Geolocate.Geolocation
|
||||
alias Bonfire.Files
|
||||
alias Bonfire.Files.Media
|
||||
alias Bonfire.{Tag, Tag.Tagged}
|
||||
|
||||
|
@ -112,8 +113,17 @@ common_assocs = %{
|
|||
controlled: quote(do: has_many(:controlled, unquote(Controlled), unquote(mixin))),
|
||||
# Inserts the object into selected feeds.
|
||||
feed_publishes: quote(do: has_many(:feed_publishes, unquote(FeedPublish), unquote(mixin))),
|
||||
|
||||
# Information that this object has some files
|
||||
files: quote(do: has_many(:files, unquote(Files), unquote(mixin))),
|
||||
# The actual files
|
||||
media: quote(do: many_to_many(:media, unquote(Media), join_through: unquote(Files), unique: true, join_keys: [id: :id, media_id: :id], on_replace: :delete)),
|
||||
|
||||
# Information that this object tagged other objects.
|
||||
tagged: quote(do: has_many(:tagged, unquote(Tagged), unquote(mixin))),
|
||||
# The actual tags
|
||||
tags: quote(do: many_to_many(:tags, unquote(Pointer), join_through: unquote(Tagged), unique: true, join_keys: [id: :id, tag_id: :id], on_replace: :delete)),
|
||||
|
||||
|
||||
### Regular has_many associations
|
||||
|
||||
|
@ -165,7 +175,7 @@ config :pointers, Pointer,
|
|||
# mixins
|
||||
unquote_splicing(pointer_mixins)
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media]))
|
||||
# has_many
|
||||
unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes]))
|
||||
|
||||
|
@ -178,11 +188,6 @@ config :pointers, Pointer,
|
|||
has_one :follow_count, unquote(EdgeTotal), foreign_key: :id, references: :id,
|
||||
where: [table_id: @follow_ulid]
|
||||
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :pointers, Table, []
|
||||
|
@ -342,6 +347,7 @@ config :bonfire_data_social, Activity,
|
|||
# mixins linked to the object rather than the activity:
|
||||
has_one :created, unquote(Created), foreign_key: :id, references: :object_id
|
||||
has_one :replied, unquote(Replied), foreign_key: :id, references: :object_id
|
||||
field :path, EctoMaterializedPath.ULIDs, virtual: true
|
||||
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]
|
||||
|
@ -352,6 +358,12 @@ config :bonfire_data_social, Activity,
|
|||
unique: true,
|
||||
join_keys: [id: :object_id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
has_many :files, unquote(Files), foreign_key: :id, references: :object_id
|
||||
many_to_many :media, unquote(Media),
|
||||
join_through: unquote(Files),
|
||||
unique: true,
|
||||
join_keys: [id: :object_id, media_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_data_social, APActivity,
|
||||
|
@ -432,18 +444,12 @@ config :bonfire_data_social, Message,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :feed_publishes, :tagged, :tags, :files, :media]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
# special
|
||||
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 :tagged, unquote(Tagged), unquote(mixin)
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_data_social, Mention, []
|
||||
|
@ -456,7 +462,7 @@ config :bonfire_data_social, Post,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
# special
|
||||
|
@ -476,11 +482,6 @@ config :bonfire_data_social, Post,
|
|||
references: :id, foreign_key: :id, where: [table_id: @like_ulid]
|
||||
has_one :boost_count, unquote(EdgeTotal),
|
||||
references: :id, foreign_key: :id, where: [table_id: @boost_ulid]
|
||||
many_to_many :tags, unquote(Pointer),
|
||||
join_through: unquote(Tagged),
|
||||
unique: true,
|
||||
join_keys: [id: :id, tag_id: :id],
|
||||
on_replace: :delete
|
||||
end]
|
||||
|
||||
|
||||
|
@ -563,12 +564,20 @@ config :bonfire_classify, Category,
|
|||
on_replace: :delete
|
||||
end]
|
||||
|
||||
config :bonfire_geolocate, Bonfire.Geolocate.Geolocation,
|
||||
[code: quote do
|
||||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :created, :actor, :peered, :profile, :character]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
end]
|
||||
|
||||
config :bonfire_valueflows, ValueFlows.EconomicEvent,
|
||||
[code: quote do
|
||||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) # TODO :caretaker
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -578,7 +587,7 @@ config :bonfire_valueflows, ValueFlows.EconomicResource,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -588,7 +597,7 @@ config :bonfire_valueflows, ValueFlows.Process,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -598,7 +607,7 @@ config :bonfire_valueflows, ValueFlows.Planning.Intent,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
@ -608,7 +617,7 @@ config :bonfire_valueflows, ValueFlows.Proposal,
|
|||
# mixins
|
||||
unquote_splicing(common.([:activity, :caretaker, :peered, :replied]))
|
||||
# multimixins
|
||||
unquote_splicing(common.([:controlled, :tagged, :feed_publishes]))
|
||||
unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes]))
|
||||
# has
|
||||
unquote_splicing(common.([:direct_replies]))
|
||||
end]
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../classic/config/bonfire_files.exs
|
51
flavours/upcycle/config/bonfire_files.exs
Normal file
51
flavours/upcycle/config/bonfire_files.exs
Normal file
|
@ -0,0 +1,51 @@
|
|||
import Config
|
||||
|
||||
# where do you want to store files? supports local storage, s3-compatible services, and more
|
||||
# see https://hexdocs.pm/waffle/Waffle.html#module-setup-a-storage-provider
|
||||
config :waffle,
|
||||
storage: Waffle.Storage.Local,
|
||||
asset_host: "/" # or {:system, "ASSET_HOST"}
|
||||
|
||||
image_media_types = ["image/png", "image/jpeg", "image/gif", "image/svg+xml", "image/tiff"]
|
||||
|
||||
all_allowed_media_types = image_media_types ++ [
|
||||
"text/plain",
|
||||
# doc
|
||||
"text/csv",
|
||||
"application/pdf",
|
||||
"application/rtf",
|
||||
"application/msword",
|
||||
"application/vnd.ms-excel",
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
"application/vnd.oasis.opendocument.presentation",
|
||||
"application/vnd.oasis.opendocument.spreadsheet",
|
||||
"application/vnd.oasis.opendocument.text",
|
||||
"application/epub+zip",
|
||||
# archives
|
||||
"application/x-tar",
|
||||
"application/x-bzip",
|
||||
"application/x-bzip2",
|
||||
"application/gzip",
|
||||
"application/zip",
|
||||
"application/rar",
|
||||
"application/x-7z-compressed",
|
||||
# audio
|
||||
"audio/mpeg",
|
||||
"audio/ogg",
|
||||
"audio/wav",
|
||||
"audio/webm",
|
||||
"audio/opus",
|
||||
# video
|
||||
"video/mp4",
|
||||
"video/mpeg",
|
||||
"video/ogg",
|
||||
"video/webm",
|
||||
]
|
||||
|
||||
config :bonfire, Bonfire.Files, image_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files, all_allowed_media_types: all_allowed_media_types
|
||||
|
||||
config :bonfire, Bonfire.Files.IconUploader, allowed_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files.ImageUploader, allowed_media_types: image_media_types
|
||||
config :bonfire, Bonfire.Files.DocumentUploader, allowed_media_types: all_allowed_media_types
|
|
@ -1 +0,0 @@
|
|||
../../classic/config/bonfire_social.exs
|
87
flavours/upcycle/config/bonfire_social.exs
Normal file
87
flavours/upcycle/config/bonfire_social.exs
Normal file
|
@ -0,0 +1,87 @@
|
|||
import Config
|
||||
|
||||
config :bonfire_social,
|
||||
disabled: false
|
||||
|
||||
alias Bonfire.Data.Social.Post
|
||||
alias Bonfire.Ecto.Acts, as: Ecto
|
||||
alias Bonfire.Social.Acts.{
|
||||
Activity,
|
||||
ActivityPub,
|
||||
Boundaries,
|
||||
Caretaker,
|
||||
Creator,
|
||||
Edges,
|
||||
Feeds,
|
||||
Files,
|
||||
LivePush,
|
||||
MeiliSearch,
|
||||
Posts,
|
||||
Objects,
|
||||
PostContents,
|
||||
Tags,
|
||||
Threaded,
|
||||
}
|
||||
|
||||
delete_object = [
|
||||
# Create a changeset for deletion
|
||||
{Objects.Delete, on: :object},
|
||||
|
||||
# mark for deletion
|
||||
{Bonfire.Ecto.Acts.Delete, on: :object,
|
||||
delete_extra_associations: [
|
||||
:tagged,
|
||||
]
|
||||
},
|
||||
|
||||
# Now we have a short critical section
|
||||
Ecto.Begin,
|
||||
Ecto.Work, # Run our deletes
|
||||
Ecto.Commit,
|
||||
|
||||
{MeiliSearch.Queue, on: :object}, # Enqueue for un-indexing by meilisearch
|
||||
|
||||
# Oban would rather we put these here than in the transaction
|
||||
# above because it knows better than us, obviously.
|
||||
{ActivityPub, on: :object}, # Prepare for federation and add to deletion queue (oban).
|
||||
]
|
||||
|
||||
config :bonfire_social, Bonfire.Social.Follows, []
|
||||
|
||||
config :bonfire_social, Bonfire.Social.Posts,
|
||||
epics: [
|
||||
publish: [
|
||||
# Prep: a little bit of querying and a lot of preparing changesets
|
||||
Posts.Publish, # Create a changeset for insertion
|
||||
PostContents, # with a sanitised body and tags extracted,
|
||||
{Caretaker, on: :post}, # a caretaker,
|
||||
{Creator, on: :post}, # and a creator,
|
||||
{Files, on: :post}, # possibly with uploaded files,
|
||||
{Threaded, on: :post}, # possibly occurring in a thread,
|
||||
{Tags, on: :post}, # with extracted tags fully hooked up,
|
||||
{Boundaries, on: :post}, # and the appropriate boundaries established,
|
||||
{Activity, on: :post}, # summarised by an activity,
|
||||
{Feeds, on: :post}, # appearing in feeds.
|
||||
|
||||
# Now we have a short critical section
|
||||
Ecto.Begin,
|
||||
Ecto.Work, # Run our inserts
|
||||
Ecto.Commit,
|
||||
|
||||
# These things are free to happen casually in the background.
|
||||
{LivePush, on: :post}, # Publish live feed updates via (in-memory) pubsub.
|
||||
|
||||
{MeiliSearch.Queue, on: :post}, # Enqueue for indexing by meilisearch
|
||||
|
||||
# Oban would rather we put these here than in the transaction
|
||||
# above because it knows better than us, obviously.
|
||||
{ActivityPub, on: :post}, # Prepare for federation and do the queue insert (oban).
|
||||
],
|
||||
|
||||
delete: delete_object,
|
||||
]
|
||||
|
||||
config :bonfire_social, Bonfire.Social.Objects,
|
||||
epics: [
|
||||
delete: delete_object,
|
||||
]
|
|
@ -1,14 +1,14 @@
|
|||
defmodule Bonfire.Repo.Migrations.AddFiles do
|
||||
use Ecto.Migration
|
||||
|
||||
import Bonfire.Files.Media.Migration
|
||||
import Bonfire.Files.Media.Migrations
|
||||
import Pointers.Migration
|
||||
|
||||
def up do
|
||||
Bonfire.Files.Media.Migration.migrate_media()
|
||||
Bonfire.Files.Media.Migrations.migrate_media()
|
||||
end
|
||||
|
||||
def down do
|
||||
Bonfire.Files.Media.Migration.migrate_media()
|
||||
Bonfire.Files.Media.Migrations.migrate_media()
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue