From 0ef85e77f922902342aa1026b808b5ff33cdb5ec Mon Sep 17 00:00:00 2001 From: Mayel de Borniol Date: Mon, 12 Sep 2022 16:34:14 +1200 Subject: [PATCH] auto-format --- .credo.exs | 10 +- .formatter.exs | 12 +- .iex.exs | 6 +- .recode.exs | 32 + assets/package.json | 2 +- assets/yarn.lock | 347 +++-- docs/CHANGELOG-autogenerated.md | 2 +- flavours/classic/config/activity_pub.exs | 16 +- flavours/classic/config/activity_pub_test.exs | 5 +- flavours/classic/config/bonfire_common.exs | 6 +- flavours/classic/config/bonfire_data.exs | 1368 +++++++++++------ flavours/classic/config/bonfire_fail.exs | 6 +- flavours/classic/config/bonfire_gc.exs | 2 +- flavours/classic/config/bonfire_geolocate.exs | 3 +- flavours/classic/config/bonfire_open_id.exs | 19 +- flavours/classic/config/bonfire_ui.exs | 247 +-- flavours/classic/config/config.exs | 39 +- flavours/classic/config/dev.exs | 73 +- flavours/classic/config/prod.exs | 7 +- flavours/classic/config/runtime.exs | 47 +- flavours/classic/config/test.exs | 18 +- .../repo/migrations/20200523081010_citext.exs | 5 +- .../20200523081012_init_pointers.exs | 2 +- .../migrations/20200523081014_init_edges.exs | 2 - .../migrations/20200818094943_import_ap.exs | 1 - .../20200820094941_import_boundaries.exs | 1 - .../migrations/20200828094944_import_me.exs | 1 - .../20200828094945_import_social.exs | 4 +- .../20200829004946_boundaries_fixtures.exs | 1 - .../20201205094943_import_quantify.exs | 8 +- .../20201208094940_import_geolocation.exs | 4 +- .../20210102094944_import_shared_user.exs | 1 - .../20210402105128_ap_test_table.exs | 12 +- .../20210410094945_profile_images.exs | 14 +- .../repo/migrations/20210412094946_fp.exs | 13 +- .../migrations/20210618094945_peered_uri.exs | 4 +- .../20210925094942_import_classify.exs | 4 +- .../20220208094942_import_invite_link.exs | 4 +- .../20220304081300_care_closure.exs | 1 - .../20220428094200_add_files_mixin.exs | 7 +- .../20220802004946_boundaries_fixtures_up.exs | 1 - flavours/classic/repo/seeds.exs | 41 +- flavours/cooperation/config/activity_pub.exs | 8 +- .../cooperation/config/activity_pub_test.exs | 5 +- .../cooperation/config/bonfire_common.exs | 3 +- flavours/cooperation/config/bonfire_data.exs | 1246 +++++++++------ flavours/cooperation/config/bonfire_fail.exs | 6 +- .../config/bonfire_federate_activitypub.exs | 9 +- flavours/cooperation/config/bonfire_files.exs | 77 +- .../cooperation/config/bonfire_geolocate.exs | 3 +- .../cooperation/config/bonfire_quantify.exs | 3 +- .../cooperation/config/bonfire_search.exs | 6 +- flavours/cooperation/config/bonfire_ui.exs | 216 +-- flavours/cooperation/config/config.exs | 10 +- flavours/cooperation/config/dev.exs | 44 +- flavours/cooperation/config/prod.exs | 7 +- flavours/cooperation/config/runtime.exs | 40 +- flavours/cooperation/config/test.exs | 2 +- .../repo/migrations/20200523081010_citext.exs | 5 +- .../20200523081012_init_pointers.exs | 2 +- .../migrations/20200523081014_init_edges.exs | 2 - .../migrations/20200818094943_import_ap.exs | 1 - .../20200820094941_import_boundaries.exs | 1 - .../migrations/20200828094944_import_me.exs | 1 - .../20200828094945_import_social.exs | 4 +- .../20200829004946_boundaries_fixtures.exs | 1 - .../20201205094943_import_quantify.exs | 8 +- .../20201208094940_import_geolocation.exs | 4 +- .../20201212094942_import_valueflows.exs | 4 +- .../20210102094944_import_shared_user.exs | 1 - ...210113094942_import_valueflows_observe.exs | 4 +- .../20210402105128_ap_test_table.exs | 12 +- .../migrations/20210407094946_message.exs | 1 - .../20210410094945_profile_images.exs | 14 +- .../repo/migrations/20210412094946_fp.exs | 13 +- .../migrations/20210618094945_peered_uri.exs | 4 +- .../20210925094942_import_classify.exs | 4 +- .../20211001094942_import_assort_ranked.exs | 5 +- ...2094942_import_commitment_satisfaction.exs | 2 +- .../20220208094942_import_invite_link.exs | 4 +- .../20220304081300_care_closure.exs | 1 - .../migrations/20220408094940_settings.exs | 2 +- .../20220428094200_add_files_mixin.exs | 7 +- .../20220701004946_boundaries_fixtures_up.exs | 1 - flavours/cooperation/repo/seeds.exs | 62 +- ...20210122131234_observe_classifications.exs | 2 +- flavours/haha/config/activity_pub_test.exs | 5 +- flavours/haha/config/bonfire_common.exs | 3 +- flavours/haha/config/bonfire_data.exs | 1185 ++++++++------ flavours/haha/config/bonfire_fail.exs | 6 +- .../config/bonfire_federate_activitypub.exs | 9 +- flavours/haha/config/bonfire_files.exs | 77 +- flavours/haha/config/bonfire_flavour_haha.exs | 3 +- flavours/haha/config/bonfire_search.exs | 6 +- flavours/haha/config/bonfire_ui.exs | 90 +- flavours/haha/config/config.exs | 10 +- flavours/haha/config/dev.exs | 41 +- flavours/haha/config/prod.exs | 7 +- flavours/haha/config/runtime.exs | 40 +- flavours/haha/config/test.exs | 2 +- .../repo/migrations/20200523081010_citext.exs | 5 +- .../20200523081012_init_pointers.exs | 2 +- .../migrations/20200523081014_init_edges.exs | 2 - .../migrations/20200818094943_import_ap.exs | 1 - .../20200820094941_import_boundaries.exs | 1 - .../migrations/20200828094944_import_me.exs | 1 - .../20200828094945_import_social.exs | 4 +- .../20200829004946_boundaries_fixtures.exs | 1 - .../20210402105128_ap_test_table.exs | 12 +- .../20210410094945_profile_images.exs | 14 +- .../repo/migrations/20210412094946_fp.exs | 13 +- .../migrations/20210618094945_peered_uri.exs | 4 +- .../20210924094943_taxonomy_seeder.exs | 1 - .../20210925094942_import_classify.exs | 4 +- .../20220208094942_import_invite_link.exs | 4 +- .../20220304081300_care_closure.exs | 1 - .../migrations/20220408094940_settings.exs | 2 +- .../20220428094200_add_files_mixin.exs | 7 +- ...1234_taxonomy_seeder_create_categories.exs | 2 +- flavours/haha/repo/seeds.exs | 22 +- flavours/reflow/config/activity_pub.exs | 8 +- flavours/reflow/config/activity_pub_test.exs | 6 +- flavours/reflow/config/bonfire_common.exs | 3 +- flavours/reflow/config/bonfire_data.exs | 1207 +++++++++------ flavours/reflow/config/bonfire_fail.exs | 6 +- .../config/bonfire_federate_activitypub.exs | 9 +- flavours/reflow/config/bonfire_files.exs | 77 +- flavours/reflow/config/bonfire_geolocate.exs | 3 +- flavours/reflow/config/bonfire_quantify.exs | 3 +- flavours/reflow/config/bonfire_search.exs | 6 +- flavours/reflow/config/bonfire_ui.exs | 182 +-- flavours/reflow/config/config.exs | 10 +- flavours/reflow/config/dev.exs | 38 +- flavours/reflow/config/prod.exs | 6 +- flavours/reflow/config/runtime.exs | 40 +- flavours/reflow/config/test.exs | 8 +- .../repo/migrations/20200523081010_citext.exs | 5 +- .../20200523081012_init_pointers.exs | 2 +- .../migrations/20200523081014_init_edges.exs | 2 - .../migrations/20200818094943_import_ap.exs | 1 - .../20200820094941_import_boundaries.exs | 1 - .../migrations/20200828094944_import_me.exs | 1 - .../20200828094945_import_social.exs | 4 +- .../20200829004946_boundaries_fixtures.exs | 1 - .../20201205094943_import_quantify.exs | 8 +- .../20201208094940_import_geolocation.exs | 4 +- .../20201212094942_import_valueflows.exs | 4 +- .../20210102094944_import_shared_user.exs | 1 - ...210113094942_import_valueflows_observe.exs | 4 +- .../20210402105128_ap_test_table.exs | 12 +- .../migrations/20210407094946_message.exs | 1 - .../20210410094945_profile_images.exs | 14 +- .../repo/migrations/20210412094946_fp.exs | 13 +- .../migrations/20210618094945_peered_uri.exs | 4 +- .../20210925094942_import_classify.exs | 4 +- .../20211001094942_import_assort_ranked.exs | 5 +- ...2094942_import_commitment_satisfaction.exs | 2 +- .../20220208094942_import_invite_link.exs | 4 +- .../20220304081300_care_closure.exs | 1 - .../migrations/20220408094940_settings.exs | 2 +- .../20220428094200_add_files_mixin.exs | 7 +- flavours/reflow/repo/seeds.exs | 62 +- ...20210122131234_observe_classifications.exs | 2 +- flavours/upcycle/config/bonfire_data.exs | 1207 +++++++++------ flavours/upcycle/config/bonfire_files.exs | 77 +- flavours/upcycle/config/bonfire_quantify.exs | 3 +- flavours/upcycle/config/bonfire_ui.exs | 178 +-- .../migrations/20200523081010_hello_world.exs | 5 +- .../20200523081012_init_pointers.exs | 1 + .../20200523081013_init_pointers_ulid.exs | 1 - .../migrations/20200523081014_init_edges.exs | 2 - .../migrations/20200818094943_import_ap.exs | 1 - .../20200820094941_import_boundaries.exs | 1 - .../migrations/20200828094944_import_me.exs | 1 - .../20200828094945_import_social.exs | 4 +- .../20200829004946_boundaries_fixtures.exs | 1 - .../20201205094943_import_quantify.exs | 8 +- .../20201208094940_import_geolocation.exs | 4 +- .../20201212094942_import_valueflows.exs | 4 +- .../20210102094944_import_shared_user.exs | 1 - ...210113094942_import_valueflows_observe.exs | 4 +- .../20210302094944_import_boost.exs | 2 +- .../migrations/20210302094945_import_flag.exs | 1 - .../20210302094946_import_inbox.exs | 1 - .../20210402105128_ap_test_table.exs | 12 +- .../migrations/20210407094946_message.exs | 1 - .../20210410094945_profile_images.exs | 14 +- .../repo/migrations/20210412094946_fp.exs | 13 +- .../migrations/20210618094945_peered_uri.exs | 4 +- .../20210925094942_import_classify.exs | 4 +- .../20211001094942_import_assort_ranked.exs | 5 +- ...2094942_import_commitment_satisfaction.exs | 2 +- .../20220304081300_care_closure.exs | 1 - .../migrations/20220408094940_settings.exs | 2 +- .../20220428094200_add_files_mixin.exs | 7 +- flavours/upcycle/repo/seeds.exs | 62 +- ...20210122131234_observe_classifications.exs | 2 +- justfile | 3 +- lib/application.ex | 86 +- lib/error_reporting.ex | 7 +- lib/localise.ex | 10 +- lib/mix/tasks/account/account.new.ex | 38 +- lib/mix/tasks/dep.compile.ex | 104 +- lib/mix/tasks/docs/deps.ex | 54 +- lib/mix/tasks/localise/localise.extract.ex | 35 +- lib/mix/tasks/release/lib/release.ex | 71 +- lib/mix/tasks/release/mix.exs | 1 - lib/mix/tasks/secrets/lib/secrets.ex | 22 +- lib/mix/tasks/secrets/mix.exs | 1 - lib/mix/tasks/users/user.admin.promote.ex | 8 +- lib/oban_logger.ex | 8 +- lib/repo/postgres_types.ex | 6 +- lib/web/endpoint.ex | 36 +- lib/web/endpoint_template.ex | 57 +- lib/web/graphql_schema.ex | 356 ++--- lib/web/home/home_live.ex | 93 +- lib/web/home/home_live.sface | 77 +- lib/web/icons/bi/kanban-fill.ex | 15 +- lib/web/icons/bi/stars.ex | 15 +- lib/web/icons/bx/at.ex | 15 +- lib/web/icons/bx/block.ex | 15 +- lib/web/icons/bx/check-shield.ex | 18 +- lib/web/icons/bx/comment-edit.ex | 18 +- lib/web/icons/bx/gift.ex | 15 +- lib/web/icons/bx/highlight.ex | 15 +- lib/web/icons/bx/key.ex | 15 +- lib/web/icons/bx/question-mark.ex | 15 +- lib/web/icons/bx/reply.ex | 12 +- lib/web/icons/bx/repost.ex | 15 +- lib/web/icons/bx/search-alt.ex | 18 +- lib/web/icons/bx/shape-circle.ex | 15 +- lib/web/icons/bx/shield-x.ex | 18 +- lib/web/icons/bx/shield.ex | 15 +- lib/web/icons/bx/toggle-right.ex | 15 +- lib/web/icons/bx/walk.ex | 15 +- lib/web/icons/bxs/book-reader.ex | 15 +- lib/web/icons/bxs/edit-location.ex | 15 +- lib/web/icons/bxs/flag-alt.ex | 12 +- lib/web/icons/bxs/flag-checkered.ex | 15 +- lib/web/icons/bxs/pen.ex | 15 +- lib/web/icons/bxs/purchase-tag.ex | 15 +- lib/web/icons/bxs/send.ex | 15 +- lib/web/icons/bxs/star.ex | 15 +- lib/web/icons/bxs/trash-alt.ex | 15 +- lib/web/icons/bxs/user-badge.ex | 15 +- lib/web/icons/ci/label.ex | 15 +- lib/web/icons/cil/recycle.ex | 15 +- lib/web/icons/el/network.ex | 15 +- lib/web/icons/emojione/eyes.ex | 21 +- lib/web/icons/fa-solid/tasks.ex | 15 +- lib/web/icons/fa/recycle.ex | 15 +- lib/web/icons/fluent/laser-tool-20-filled.ex | 15 +- lib/web/icons/gis/world-map.ex | 17 +- .../icons/heroicons-outline/adjustments.ex | 19 +- .../heroicons-outline/arrow-narrow-right.ex | 19 +- .../icons/heroicons-outline/arrows-expand.ex | 19 +- lib/web/icons/heroicons-outline/bell.ex | 20 +- lib/web/icons/heroicons-outline/chat-alt.ex | 19 +- .../icons/heroicons-outline/check-circle.ex | 19 +- lib/web/icons/heroicons-outline/check.ex | 19 +- .../heroicons-outline/chevron-double-down.ex | 19 +- .../heroicons-outline/chevron-double-up.ex | 19 +- .../icons/heroicons-outline/chevron-down.ex | 20 +- .../icons/heroicons-outline/chevron-left.ex | 19 +- .../icons/heroicons-outline/chevron-right.ex | 19 +- lib/web/icons/heroicons-outline/cog.ex | 20 +- lib/web/icons/heroicons-outline/collection.ex | 19 +- .../icons/heroicons-outline/exclamation.ex | 19 +- .../icons/heroicons-outline/finger-print.ex | 19 +- lib/web/icons/heroicons-outline/fire.ex | 21 +- lib/web/icons/heroicons-outline/flag.ex | 19 +- lib/web/icons/heroicons-outline/globe.ex | 19 +- lib/web/icons/heroicons-outline/key.ex | 19 +- .../icons/heroicons-outline/lightning-bolt.ex | 19 +- .../heroicons-outline/location-marker.ex | 20 +- .../icons/heroicons-outline/lock-closed.ex | 19 +- lib/web/icons/heroicons-outline/logout.ex | 19 +- lib/web/icons/heroicons-outline/mail.ex | 20 +- lib/web/icons/heroicons-outline/menu-alt-2.ex | 19 +- lib/web/icons/heroicons-outline/menu.ex | 19 +- .../icons/heroicons-outline/minus-circle.ex | 19 +- lib/web/icons/heroicons-outline/newspaper.ex | 19 +- lib/web/icons/heroicons-outline/pencil.ex | 19 +- lib/web/icons/heroicons-outline/plus.ex | 20 +- lib/web/icons/heroicons-outline/puzzle.ex | 19 +- lib/web/icons/heroicons-outline/reply.ex | 19 +- lib/web/icons/heroicons-outline/scale.ex | 20 +- lib/web/icons/heroicons-outline/star.ex | 19 +- lib/web/icons/heroicons-outline/trash.ex | 19 +- lib/web/icons/heroicons-outline/user-group.ex | 19 +- lib/web/icons/heroicons-outline/user.ex | 19 +- .../icons/heroicons-outline/view-grid-add.ex | 19 +- lib/web/icons/heroicons-outline/view-grid.ex | 19 +- lib/web/icons/heroicons-outline/volume-off.ex | 23 +- lib/web/icons/heroicons-outline/x.ex | 19 +- lib/web/icons/heroicons-solid/adjustments.ex | 15 +- lib/web/icons/heroicons-solid/ban.ex | 17 +- lib/web/icons/heroicons-solid/bell.ex | 15 +- lib/web/icons/heroicons-solid/check-circle.ex | 17 +- lib/web/icons/heroicons-solid/chevron-down.ex | 17 +- lib/web/icons/heroicons-solid/chevron-left.ex | 17 +- .../icons/heroicons-solid/chevron-right.ex | 17 +- lib/web/icons/heroicons-solid/cog.ex | 17 +- lib/web/icons/heroicons-solid/collection.ex | 15 +- .../icons/heroicons-solid/dots-horizontal.ex | 15 +- .../icons/heroicons-solid/dots-vertical.ex | 15 +- lib/web/icons/heroicons-solid/exclamation.ex | 17 +- .../icons/heroicons-solid/external-link.ex | 14 +- lib/web/icons/heroicons-solid/eye-off.ex | 19 +- lib/web/icons/heroicons-solid/eye.ex | 18 +- lib/web/icons/heroicons-solid/fire.ex | 17 +- lib/web/icons/heroicons-solid/flag.ex | 17 +- lib/web/icons/heroicons-solid/globe.ex | 17 +- lib/web/icons/heroicons-solid/home.ex | 15 +- lib/web/icons/heroicons-solid/inbox-in.ex | 14 +- lib/web/icons/heroicons-solid/inbox.ex | 17 +- .../heroicons-solid/information-circle.ex | 17 +- lib/web/icons/heroicons-solid/key.ex | 17 +- .../icons/heroicons-solid/lightning-bolt.ex | 17 +- lib/web/icons/heroicons-solid/link.ex | 18 +- .../icons/heroicons-solid/location-marker.ex | 17 +- lib/web/icons/heroicons-solid/lock-closed.ex | 17 +- lib/web/icons/heroicons-solid/login.ex | 17 +- lib/web/icons/heroicons-solid/logout.ex | 17 +- lib/web/icons/heroicons-solid/mail.ex | 14 +- lib/web/icons/heroicons-solid/minus-circle.ex | 17 +- lib/web/icons/heroicons-solid/minus.ex | 17 +- lib/web/icons/heroicons-solid/newspaper.ex | 18 +- lib/web/icons/heroicons-solid/paper-clip.ex | 17 +- lib/web/icons/heroicons-solid/pencil-alt.ex | 18 +- lib/web/icons/heroicons-solid/pencil.ex | 15 +- lib/web/icons/heroicons-solid/plus.ex | 17 +- lib/web/icons/heroicons-solid/puzzle.ex | 15 +- .../heroicons-solid/question-mark-circle.ex | 18 +- lib/web/icons/heroicons-solid/scale.ex | 17 +- lib/web/icons/heroicons-solid/search.ex | 17 +- lib/web/icons/heroicons-solid/star.ex | 15 +- lib/web/icons/heroicons-solid/trash.ex | 17 +- lib/web/icons/heroicons-solid/user-add.ex | 15 +- lib/web/icons/heroicons-solid/user-group.ex | 15 +- lib/web/icons/heroicons-solid/user-remove.ex | 15 +- lib/web/icons/heroicons-solid/user.ex | 17 +- lib/web/icons/heroicons-solid/users.ex | 15 +- lib/web/icons/heroicons-solid/volume-off.ex | 17 +- lib/web/icons/heroicons-solid/x.ex | 17 +- lib/web/icons/icon-park-outline/cycle-one.ex | 19 +- lib/web/icons/icon-park/cycle-arrow.ex | 14 +- .../icons/material-symbols/camping-rounded.ex | 15 +- .../edit-location-alt-rounded.ex | 15 +- lib/web/icons/mdi/bicycle-penny-farthing.ex | 15 +- lib/web/icons/mingcute/bread-fill.ex | 17 +- lib/web/icons/twemoji/newspaper.ex | 18 +- .../vscode-icons/file-type-light-todo.ex | 15 +- lib/web/icons/vscode-icons/file-type-todo.ex | 18 +- lib/web/router.ex | 95 +- lib/web/web_telemetry.ex | 13 +- mess.exs | 40 +- mix.exs | 399 +++-- mix.lock | 2 + test/support/conn_case.ex | 1 - test/support/data_case.ex | 1 - test/support/data_helpers.ex | 2 - test/support/fake_helpers.ex | 2 - test/test_helper.exs | 18 +- 364 files changed, 8650 insertions(+), 4590 deletions(-) create mode 100644 .recode.exs diff --git a/.credo.exs b/.credo.exs index efffde0645..41eee1c96a 100644 --- a/.credo.exs +++ b/.credo.exs @@ -3,14 +3,20 @@ %{ name: "default", files: %{ - included: ["mix.exs", "flavours/", "lib/", "forks/*/mix.exs", "forks/*/lib"], + included: [ + "mix.exs", + "flavours/", + "lib/", + "forks/*/mix.exs", + "forks/*/lib" + ], excluded: [~r"/_build/", "**/*_test.exs"] }, plugins: [], requires: [], strict: false, parse_timeout: 5000, - color: true, + color: true # checks: [ # {Credo.Check.Design.AliasUsage, priority: :low}, # # ... other checks omitted for readability ... diff --git a/.formatter.exs b/.formatter.exs index cfb0d1c774..d809dff8f5 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,15 +1,21 @@ [ import_deps: [:surface], - plugins: [Surface.Formatter.Plugin], + plugins: [Phoenix.LiveView.HTMLFormatter, Surface.Formatter.Plugin], # add patterns matching all .sface files and all .ex files with ~F sigils - inputs: ["*.{ex,exs}", "{config,lib,test,forks}/**/*.{ex,exs,sface}"], + inputs: [ + "{mix,.formatter,mess}.exs", + "{flavours,lib,test}/**/*.{ex,exs,sface,heex}", + "forks/bonfire*/{config,lib,test}/**/*.{ex,exs,sface,heex}" + ], # THE FOLLOWING ARE OPTIONAL: # set desired line length for both Elixir's code formatter and this one # (only affects opening tags in Surface) - line_length: 80, + line_length: 98 + + # heex_line_length: 84, # or, set line length only for Surface code (overrides `line_length`) # surface_line_length: 84 diff --git a/.iex.exs b/.iex.exs index d6e60a4215..53fca2a1df 100755 --- a/.iex.exs +++ b/.iex.exs @@ -24,9 +24,9 @@ if module_enabled?(Bonfire.Common.Test.Interactive) && Mix.env() == :test do Process.unlink(pid) end - Bonfire.Common.Test.Interactive.Helpers.ready - + Bonfire.Common.Test.Interactive.Helpers.ready() else info("IExWatchTests is not running") end -import_if_enabled Bonfire.Common.Test.Interactive.Helpers + +import_if_enabled(Bonfire.Common.Test.Interactive.Helpers) diff --git a/.recode.exs b/.recode.exs new file mode 100644 index 0000000000..14718d49f4 --- /dev/null +++ b/.recode.exs @@ -0,0 +1,32 @@ +alias Recode.Task + +[ + version: "0.4.0", + # Can also be set/reset with "--autocorrect"/"--no-autocorrect". + autocorrect: true, + # With "--dry" no changes will be written to the files. + # Can also be set/reset with "--dry"/"--no-dry". + # If dry is true then verbose is also active. + dry: true, + # Can also be set/reset with "--verbose"/"--no-verbose". + verbose: true, + # Can be overwriten by calling `mix recode "lib/**/*.ex"`. + inputs: [ + "{flavours,lib,test}/**/*.{ex,exs}", + "forks/bonfire*/{config,lib,test}/**/*.{ex,exs}" + ], + formatter: {Recode.Formatter, []}, + tasks: [ + # Tasks could be added by a tuple of the tasks module name and an options + # keyword list. A task can be deactived by `active: false`. The execution of + # a deactivated task can be forced by calling `mix recode --task ModuleName`. + {Task.AliasExpansion, []}, + {Task.AliasOrder, active: false}, + {Task.EnforceLineLength, active: false}, + {Task.PipeFunOne, []}, + {Task.SinglePipe, active: false}, # Note: does not known how to handle `Arrows` + {Task.Specs, active: false, exclude: "{test}/**/*.{ex,exs}", config: [only: :visible]}, + {Task.TestFileExt, []}, + {Task.UnusedVariable, active: false} + ] +] diff --git a/assets/package.json b/assets/package.json index b4d6e07d53..01f8b94d9f 100755 --- a/assets/package.json +++ b/assets/package.json @@ -49,7 +49,7 @@ "tailwindcss-debug-screens": "^2.2.1" }, "optionalDependencies": { - "chromedriver": "^103.0.0" + "chromedriver": "^105.0.0" }, "disabledDependencies": { "@rtvision/esbuild-dynamic-import": "^0.2.0", diff --git a/assets/yarn.lock b/assets/yarn.lock index 75ac753e8c..2ad2056868 100644 --- a/assets/yarn.lock +++ b/assets/yarn.lock @@ -12,6 +12,11 @@ resolved "https://registry.yarnpkg.com/@alpinejs/intersect/-/intersect-3.10.3.tgz#9aebf43b40e02b0f53e244229472cc3f1d1ed304" integrity sha512-vMRvhbMJzS1tupb2a/3GF5H+gLxxWaXJpcxJlfSHrV2JTb+RFWOJIkL/63JpPPGibtpaNBDrx3hsRN0CJ4d5mw== +"@esbuild/linux-loong64@0.14.54": + version "0.14.54" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.14.54.tgz#de2a4be678bd4d0d1ffbb86e6de779cde5999028" + integrity sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -34,25 +39,26 @@ fastq "^1.6.0" "@tailwindcss/forms@^0.5.2": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@tailwindcss/forms/-/forms-0.5.2.tgz#4ef45f9916dcb37838cbe7fecdcc4ba7a7c2ab59" - integrity sha512-pSrFeJB6Bg1Mrg9CdQW3+hqZXAKsBrSG9MAfFLKy1pVA4Mb4W7C0k7mEhlmS2Dfo/otxrQOET7NJiJ9RrS563w== + version "0.5.3" + resolved "https://registry.yarnpkg.com/@tailwindcss/forms/-/forms-0.5.3.tgz#e4d7989686cbcaf416c53f1523df5225332a86e7" + integrity sha512-y5mb86JUoiUgBjY/o6FJSFZSEttfb3Q5gllE4xoKjAAD+vBrnIhE4dViwUuow3va8mpH4s9jyUbUbrRGoRdc2Q== dependencies: mini-svg-data-uri "^1.2.3" "@tailwindcss/line-clamp@^0.4.0": - version "0.4.0" - resolved "https://registry.yarnpkg.com/@tailwindcss/line-clamp/-/line-clamp-0.4.0.tgz#03353e31e77636b785f2336e8c978502cec1de81" - integrity sha512-HQZo6gfx1D0+DU3nWlNLD5iA6Ef4JAXh0LeD8lOGrJwEDBwwJNKQza6WoXhhY1uQrxOuU8ROxV7CqiQV4CoiLw== + version "0.4.2" + resolved "https://registry.yarnpkg.com/@tailwindcss/line-clamp/-/line-clamp-0.4.2.tgz#f353c5a8ab2c939c6267ac5b907f012e5ee130f9" + integrity sha512-HFzAQuqYCjyy/SX9sLGB1lroPzmcnWv1FHkIpmypte10hptf4oPUfucryMKovZh2u0uiS9U5Ty3GghWfEJGwVw== "@tailwindcss/typography@^0.5.2": - version "0.5.4" - resolved "https://registry.yarnpkg.com/@tailwindcss/typography/-/typography-0.5.4.tgz#ad8c9e6808bae297bb7826742e4789f2a9f09a48" - integrity sha512-QEdg40EmGvE7kKoDei8zr5sf4D1pIayHj4R31bH3lX8x2BtTiR+jNejYPOkhbmy3DXgkMF9jC8xqNiGFAuL9Sg== + version "0.5.7" + resolved "https://registry.yarnpkg.com/@tailwindcss/typography/-/typography-0.5.7.tgz#e0b95bea787ee14c5a34a74fc824e6fe86ea8855" + integrity sha512-JTTSTrgZfp6Ki4svhPA4mkd9nmQ/j9EfE7SbHJ1cLtthKkpW2OxsFXzSmxbhYbEkfNIyAyhle5p4SYyKRbz/jg== dependencies: lodash.castarray "^4.4.0" lodash.isplainobject "^4.0.6" lodash.merge "^4.6.2" + postcss-selector-parser "6.0.10" "@testim/chrome-version@^1.1.2": version "1.1.2" @@ -60,9 +66,9 @@ integrity sha512-1c4ZOETSRpI0iBfIFUqU4KqwBAB2lHUAlBjZz/YqOHqwM9dTTzjV6Km0ZkiEiSCx/tLr1BtESIKyWWMww+RUqw== "@types/node@*": - version "18.6.1" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.6.1.tgz#828e4785ccca13f44e2fb6852ae0ef11e3e20ba5" - integrity sha512-z+2vB6yDt1fNwKOeGbckpmirO+VBDuQqecXkgeIqDlaOtmKn6hPR/viQ8cxCfqLU4fTlvM3+YjM367TukWdxpg== + version "18.7.16" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.16.tgz#0eb3cce1e37c79619943d2fd903919fc30850601" + integrity sha512-EQHhixfu+mkqHMZl1R2Ovuvn47PUw18azMJOTwSZr9/fhzHNGXAJ0ma0dayRVchprpCj0Kc1K1xKoWaATWF1qg== "@types/yauzl@^2.9.1": version "2.10.0" @@ -84,9 +90,9 @@ integrity sha512-oJ4F3TnvpXaQwZJNF3ZK+kLPHKarDmJjJ6jyzVNDKH9md1dptjC7lWR//jrGuLdek/U6iltWxqAnYOu8gCiOvA== "@yaireo/tagify@^4.12.0": - version "4.14.1" - resolved "https://registry.yarnpkg.com/@yaireo/tagify/-/tagify-4.14.1.tgz#2657426ec64a12f1a1000400a7be6bba319a2657" - integrity sha512-Yo/keCvgGRNV2KA6M8W/A2XUV4S9lTX+VYWwErWMJxKgzfMlZmhaOqkmuQBbGCvSS/GcLW4lzcV+IxPd+yPEXA== + version "4.16.4" + resolved "https://registry.yarnpkg.com/@yaireo/tagify/-/tagify-4.16.4.tgz#78d2cbb56cd083af175d3cb48178ada0b37d9872" + integrity sha512-7x13aVfYPGUUMXWkV11/Zw4w1RkkTWtaO/rEAkaOFNwGIFXDBeG5Wr4gWF6JSHXLZAreS53nHq6b6mJrtpUgYA== acorn-node@^1.8.2: version "1.8.2" @@ -165,12 +171,12 @@ asynckit@^0.4.0: integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== autoprefixer@^10.4.7: - version "10.4.7" - resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.7.tgz#1db8d195f41a52ca5069b7593be167618edbbedf" - integrity sha512-ypHju4Y2Oav95SipEcCcI5J7CGPuvz8oat7sUtYj3ClK44bldfvtvcxK6IEK++7rqB7YchDGzweZIBG+SD0ZAA== + version "10.4.9" + resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.9.tgz#40f932f7d0535264823882031f9254ea72c693e5" + integrity sha512-Uu67eduPEmOeA0vyJby5ghu1AAELCCNSsLAjK+lz6kYzNM5sqnBO36MqfsjhPjQF/BaJM5U/UuFYyl7PavY/wQ== dependencies: - browserslist "^4.20.3" - caniuse-lite "^1.0.30001335" + browserslist "^4.21.3" + caniuse-lite "^1.0.30001394" fraction.js "^4.2.0" normalize-range "^0.1.2" picocolors "^1.0.0" @@ -214,15 +220,15 @@ braces@^3.0.2, braces@~3.0.2: dependencies: fill-range "^7.0.1" -browserslist@^4.20.3: - version "4.21.2" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.2.tgz#59a400757465535954946a400b841ed37e2b4ecf" - integrity sha512-MonuOgAtUB46uP5CezYbRaYKBNt2LxP0yX+Pmj4LkcDFGkn9Cbpi83d9sCjwQDErXsIJSzY5oKGDbgOlF/LPAA== +browserslist@^4.21.3: + version "4.21.3" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.3.tgz#5df277694eb3c48bc5c4b05af3e8b7e09c5a6d1a" + integrity sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ== dependencies: - caniuse-lite "^1.0.30001366" - electron-to-chromium "^1.4.188" + caniuse-lite "^1.0.30001370" + electron-to-chromium "^1.4.202" node-releases "^2.0.6" - update-browserslist-db "^1.0.4" + update-browserslist-db "^1.0.5" buffer-crc32@~0.2.3: version "0.2.13" @@ -242,10 +248,10 @@ camelcase-css@^2.0.1: resolved "https://registry.yarnpkg.com/camelcase-css/-/camelcase-css-2.0.1.tgz#ee978f6947914cc30c6b44741b6ed1df7f043fd5" integrity sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA== -caniuse-lite@^1.0.30001335, caniuse-lite@^1.0.30001366: - version "1.0.30001370" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001370.tgz#0a30d4f20d38b9e108cc5ae7cc62df9fe66cd5ba" - integrity sha512-3PDmaP56wz/qz7G508xzjx8C+MC2qEm4SYhSEzC9IBROo+dGXFWRuaXkWti0A9tuI00g+toiriVqxtWMgl350g== +caniuse-lite@^1.0.30001370, caniuse-lite@^1.0.30001394: + version "1.0.30001397" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001397.tgz#010d9d56e3b8abcd8df261d0a94b22426271a15f" + integrity sha512-SW9N2TbCdLf0eiNDRrrQXx2sOkaakNZbCjgNpPyMJJbiOrU5QzMIrXOVMRM1myBXTD5iTkdrtU/EguCrBocHlA== chokidar@^3.3.0, chokidar@^3.5.3: version "3.5.3" @@ -262,10 +268,10 @@ chokidar@^3.3.0, chokidar@^3.5.3: optionalDependencies: fsevents "~2.3.2" -chromedriver@^103.0.0: - version "103.0.0" - resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-103.0.0.tgz#2ef086d62076e3ff6df6cfb84895d11d2c18d9cf" - integrity sha512-7BHf6HWt0PeOHCzWO8qlnD13sARzr5AKTtG8Csn+czsuAsajwPxdLNtry5GPh8HYFyl+i0M+yg3bT43AGfgU9w== +chromedriver@^105.0.0: + version "105.0.0" + resolved "https://registry.yarnpkg.com/chromedriver/-/chromedriver-105.0.0.tgz#81a68e2bc0618a640defd7317ddf6ae9127fc5e4" + integrity sha512-BX3GOUW5m6eiW9cVVF8hw+EFxvrGqYCxbwOqnpk8PjbNFqL5xjy7yel+e6ilJPjckAYFutMKs8XJvOs/W85vvg== dependencies: "@testim/chrome-version" "^1.1.2" axios "^0.27.2" @@ -362,9 +368,9 @@ cssesc@^3.0.0: integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg== daisyui@^2.24.0: - version "2.24.0" - resolved "https://registry.yarnpkg.com/daisyui/-/daisyui-2.24.0.tgz#7eacfc943815979227cf50b98f7df622c2814118" - integrity sha512-Fdu/4LCdTfWLWAbCuPxvnaRotEfJ+hVPgZ2kv/aUk9RZ00Yk8fGdJtIf0kXJ3IgUKOr8rCXUpfQY6DQU9usPCQ== + version "2.27.0" + resolved "https://registry.yarnpkg.com/daisyui/-/daisyui-2.27.0.tgz#145e75e17529f81a113c84e86cc5312e01799f88" + integrity sha512-AhFGhTore1Kdnae+5RGc2PGESSXOjAQDHJfvryP+KY41gxMcNErtuaGZG+nOmvOzNKgxViSDSaOn/VZq6H8kxA== dependencies: color "^4.2" css-selector-tokenizer "^0.8.0" @@ -455,10 +461,10 @@ duplexer@^0.1.1: resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg== -electron-to-chromium@^1.4.188: - version "1.4.202" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.202.tgz#0c2ed733f42b02ec49a955c5badfcc65888c390b" - integrity sha512-JYsK2ex9lmQD27kj19fhXYxzFJ/phLAkLKHv49A5UY6kMRV2xED3qMMLg/voW/+0AR6wMiI+VxlmK9NDtdxlPA== +electron-to-chromium@^1.4.202: + version "1.4.247" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.247.tgz#cc93859bc5fc521f611656e65ce17eae26a0fd3d" + integrity sha512-FLs6R4FQE+1JHM0hh3sfdxnYjKvJpHZyhQDjc2qFq/xFvmmRt/TATNToZhrcGUFzpF2XjeiuozrA8lI0PZmYYw== emoji-regex@^8.0.0: version "8.0.0" @@ -472,131 +478,132 @@ end-of-stream@^1.1.0: dependencies: once "^1.4.0" -esbuild-android-64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-android-64/-/esbuild-android-64-0.14.50.tgz#a46fc80fa2007690e647680d837483a750a3097f" - integrity sha512-H7iUEm7gUJHzidsBlFPGF6FTExazcgXL/46xxLo6i6bMtPim6ZmXyTccS8yOMpy6HAC6dPZ/JCQqrkkin69n6Q== +esbuild-android-64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-android-64/-/esbuild-android-64-0.14.54.tgz#505f41832884313bbaffb27704b8bcaa2d8616be" + integrity sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ== -esbuild-android-arm64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.14.50.tgz#bdda7851fa7f5f770d6ff0ad593a8945d3a0fcdd" - integrity sha512-NFaoqEwa+OYfoYVpQWDMdKII7wZZkAjtJFo1WdnBeCYlYikvUhTnf2aPwPu5qEAw/ie1NYK0yn3cafwP+kP+OQ== +esbuild-android-arm64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.14.54.tgz#8ce69d7caba49646e009968fe5754a21a9871771" + integrity sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg== -esbuild-darwin-64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-darwin-64/-/esbuild-darwin-64-0.14.50.tgz#f0535435f9760766f30db14a991ee5ca94c022a4" - integrity sha512-gDQsCvGnZiJv9cfdO48QqxkRV8oKAXgR2CGp7TdIpccwFdJMHf8hyIJhMW/05b/HJjET/26Us27Jx91BFfEVSA== +esbuild-darwin-64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-darwin-64/-/esbuild-darwin-64-0.14.54.tgz#24ba67b9a8cb890a3c08d9018f887cc221cdda25" + integrity sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug== -esbuild-darwin-arm64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.50.tgz#76a41a40e8947a15ae62970e9ed2853883c4b16c" - integrity sha512-36nNs5OjKIb/Q50Sgp8+rYW/PqirRiFN0NFc9hEvgPzNJxeJedktXwzfJSln4EcRFRh5Vz4IlqFRScp+aiBBzA== +esbuild-darwin-arm64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.54.tgz#3f7cdb78888ee05e488d250a2bdaab1fa671bf73" + integrity sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw== -esbuild-freebsd-64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.50.tgz#2ed6633c17ed42c20a1bd68e82c4bbc75ea4fb57" - integrity sha512-/1pHHCUem8e/R86/uR+4v5diI2CtBdiWKiqGuPa9b/0x3Nwdh5AOH7lj+8823C6uX1e0ufwkSLkS+aFZiBCWxA== +esbuild-freebsd-64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.54.tgz#09250f997a56ed4650f3e1979c905ffc40bbe94d" + integrity sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg== -esbuild-freebsd-arm64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.50.tgz#cb115f4cdafe9cdbe58875ba482fccc54d32aa43" - integrity sha512-iKwUVMQztnPZe5pUYHdMkRc9aSpvoV1mkuHlCoPtxZA3V+Kg/ptpzkcSY+fKd0kuom+l6Rc93k0UPVkP7xoqrw== +esbuild-freebsd-arm64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.54.tgz#bafb46ed04fc5f97cbdb016d86947a79579f8e48" + integrity sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q== -esbuild-linux-32@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-linux-32/-/esbuild-linux-32-0.14.50.tgz#fe2b724994dcf1d4e48dc4832ff008ad7d00bcfd" - integrity sha512-sWUwvf3uz7dFOpLzYuih+WQ7dRycrBWHCdoXJ4I4XdMxEHCECd8b7a9N9u7FzT6XR2gHPk9EzvchQUtiEMRwqw== +esbuild-linux-32@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-linux-32/-/esbuild-linux-32-0.14.54.tgz#e2a8c4a8efdc355405325033fcebeb941f781fe5" + integrity sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw== -esbuild-linux-64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-linux-64/-/esbuild-linux-64-0.14.50.tgz#7851ab5151df9501a2187bd4909c594ad232b623" - integrity sha512-u0PQxPhaeI629t4Y3EEcQ0wmWG+tC/LpP2K7yDFvwuPq0jSQ8SIN+ARNYfRjGW15O2we3XJvklbGV0wRuUCPig== +esbuild-linux-64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-linux-64/-/esbuild-linux-64-0.14.54.tgz#de5fdba1c95666cf72369f52b40b03be71226652" + integrity sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg== -esbuild-linux-arm64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.50.tgz#76a76afef484a0512f1fbbcc762edd705dee8892" - integrity sha512-ZyfoNgsTftD7Rp5S7La5auomKdNeB3Ck+kSKXC4pp96VnHyYGjHHXWIlcbH8i+efRn9brszo1/Thl1qn8RqmhQ== +esbuild-linux-arm64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.54.tgz#dae4cd42ae9787468b6a5c158da4c84e83b0ce8b" + integrity sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig== -esbuild-linux-arm@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-linux-arm/-/esbuild-linux-arm-0.14.50.tgz#6d7a8c0712091b0c3a668dd5d8b5c924adbaeb12" - integrity sha512-VALZq13bhmFJYFE/mLEb+9A0w5vo8z+YDVOWeaf9vOTrSC31RohRIwtxXBnVJ7YKLYfEMzcgFYf+OFln3Y0cWg== +esbuild-linux-arm@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-linux-arm/-/esbuild-linux-arm-0.14.54.tgz#a2c1dff6d0f21dbe8fc6998a122675533ddfcd59" + integrity sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw== -esbuild-linux-mips64le@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.50.tgz#43426909c1884c5dc6b40765673a08a7ec1d2064" - integrity sha512-ygo31Vxn/WrmjKCHkBoutOlFG5yM9J2UhzHb0oWD9O61dGg+Hzjz9hjf5cmM7FBhAzdpOdEWHIrVOg2YAi6rTw== +esbuild-linux-mips64le@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.54.tgz#d9918e9e4cb972f8d6dae8e8655bf9ee131eda34" + integrity sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw== -esbuild-linux-ppc64le@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.50.tgz#c754ea3da1dd180c6e9b6b508dc18ce983d92b11" - integrity sha512-xWCKU5UaiTUT6Wz/O7GKP9KWdfbsb7vhfgQzRfX4ahh5NZV4ozZ4+SdzYG8WxetsLy84UzLX3Pi++xpVn1OkFQ== +esbuild-linux-ppc64le@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.54.tgz#3f9a0f6d41073fb1a640680845c7de52995f137e" + integrity sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ== -esbuild-linux-riscv64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.50.tgz#f3b2dd3c4c2b91bf191d3b98a9819c8aa6f5ad7f" - integrity sha512-0+dsneSEihZTopoO9B6Z6K4j3uI7EdxBP7YSF5rTwUgCID+wHD3vM1gGT0m+pjCW+NOacU9kH/WE9N686FHAJg== +esbuild-linux-riscv64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.54.tgz#618853c028178a61837bc799d2013d4695e451c8" + integrity sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg== -esbuild-linux-s390x@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.50.tgz#3dfbc4578b2a81995caabb79df2b628ea86a5390" - integrity sha512-tVjqcu8o0P9H4StwbIhL1sQYm5mWATlodKB6dpEZFkcyTI8kfIGWiWcrGmkNGH2i1kBUOsdlBafPxR3nzp3TDA== +esbuild-linux-s390x@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.54.tgz#d1885c4c5a76bbb5a0fe182e2c8c60eb9e29f2a6" + integrity sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA== -esbuild-netbsd-64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.50.tgz#17dbf51eaa48d983e794b588d195415410ef8c85" - integrity sha512-0R/glfqAQ2q6MHDf7YJw/TulibugjizBxyPvZIcorH0Mb7vSimdHy0XF5uCba5CKt+r4wjax1mvO9lZ4jiAhEg== +esbuild-netbsd-64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.54.tgz#69ae917a2ff241b7df1dbf22baf04bd330349e81" + integrity sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w== -esbuild-openbsd-64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.50.tgz#cf6b1a50c8cf67b0725aaa4bce9773976168c50e" - integrity sha512-7PAtmrR5mDOFubXIkuxYQ4bdNS6XCK8AIIHUiZxq1kL8cFIH5731jPcXQ4JNy/wbj1C9sZ8rzD8BIM80Tqk29w== +esbuild-openbsd-64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.54.tgz#db4c8495287a350a6790de22edea247a57c5d47b" + integrity sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw== -esbuild-sunos-64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-sunos-64/-/esbuild-sunos-64-0.14.50.tgz#f705ae0dd914c3b45dc43319c4f532216c3d841f" - integrity sha512-gBxNY/wyptvD7PkHIYcq7se6SQEXcSC8Y7mE0FJB+CGgssEWf6vBPfTTZ2b6BWKnmaP6P6qb7s/KRIV5T2PxsQ== +esbuild-sunos-64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-sunos-64/-/esbuild-sunos-64-0.14.54.tgz#54287ee3da73d3844b721c21bc80c1dc7e1bf7da" + integrity sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw== -esbuild-windows-32@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-windows-32/-/esbuild-windows-32-0.14.50.tgz#6364905a99c1e6c1e2fe7bfccebd958131b1cd6c" - integrity sha512-MOOe6J9cqe/iW1qbIVYSAqzJFh0p2LBLhVUIWdMVnNUNjvg2/4QNX4oT4IzgDeldU+Bym9/Tn6+DxvUHJXL5Zw== +esbuild-windows-32@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-windows-32/-/esbuild-windows-32-0.14.54.tgz#f8aaf9a5667630b40f0fb3aa37bf01bbd340ce31" + integrity sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w== -esbuild-windows-64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-windows-64/-/esbuild-windows-64-0.14.50.tgz#56603cb6367e30d14098deb77de6aa18d76dd89b" - integrity sha512-r/qE5Ex3w1jjGv/JlpPoWB365ldkppUlnizhMxJgojp907ZF1PgLTuW207kgzZcSCXyquL9qJkMsY+MRtaZ5yQ== +esbuild-windows-64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-windows-64/-/esbuild-windows-64-0.14.54.tgz#bf54b51bd3e9b0f1886ffdb224a4176031ea0af4" + integrity sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ== -esbuild-windows-arm64@0.14.50: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.50.tgz#e7ddde6a97194051a5a4ac05f4f5900e922a7ea5" - integrity sha512-EMS4lQnsIe12ZyAinOINx7eq2mjpDdhGZZWDwPZE/yUTN9cnc2Ze/xUTYIAyaJqrqQda3LnDpADKpvLvol6ENQ== +esbuild-windows-arm64@0.14.54: + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.54.tgz#937d15675a15e4b0e4fafdbaa3a01a776a2be982" + integrity sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg== esbuild@^0.14.47: - version "0.14.50" - resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.14.50.tgz#7a665392c8df94bf6e1ae1e999966a5ee62c6cbc" - integrity sha512-SbC3k35Ih2IC6trhbMYW7hYeGdjPKf9atTKwBUHqMCYFZZ9z8zhuvfnZihsnJypl74FjiAKjBRqFkBkAd0rS/w== + version "0.14.54" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.14.54.tgz#8b44dcf2b0f1a66fc22459943dccf477535e9aa2" + integrity sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA== optionalDependencies: - esbuild-android-64 "0.14.50" - esbuild-android-arm64 "0.14.50" - esbuild-darwin-64 "0.14.50" - esbuild-darwin-arm64 "0.14.50" - esbuild-freebsd-64 "0.14.50" - esbuild-freebsd-arm64 "0.14.50" - esbuild-linux-32 "0.14.50" - esbuild-linux-64 "0.14.50" - esbuild-linux-arm "0.14.50" - esbuild-linux-arm64 "0.14.50" - esbuild-linux-mips64le "0.14.50" - esbuild-linux-ppc64le "0.14.50" - esbuild-linux-riscv64 "0.14.50" - esbuild-linux-s390x "0.14.50" - esbuild-netbsd-64 "0.14.50" - esbuild-openbsd-64 "0.14.50" - esbuild-sunos-64 "0.14.50" - esbuild-windows-32 "0.14.50" - esbuild-windows-64 "0.14.50" - esbuild-windows-arm64 "0.14.50" + "@esbuild/linux-loong64" "0.14.54" + esbuild-android-64 "0.14.54" + esbuild-android-arm64 "0.14.54" + esbuild-darwin-64 "0.14.54" + esbuild-darwin-arm64 "0.14.54" + esbuild-freebsd-64 "0.14.54" + esbuild-freebsd-arm64 "0.14.54" + esbuild-linux-32 "0.14.54" + esbuild-linux-64 "0.14.54" + esbuild-linux-arm "0.14.54" + esbuild-linux-arm64 "0.14.54" + esbuild-linux-mips64le "0.14.54" + esbuild-linux-ppc64le "0.14.54" + esbuild-linux-riscv64 "0.14.54" + esbuild-linux-s390x "0.14.54" + esbuild-netbsd-64 "0.14.54" + esbuild-openbsd-64 "0.14.54" + esbuild-sunos-64 "0.14.54" + esbuild-windows-32 "0.14.54" + esbuild-windows-64 "0.14.54" + esbuild-windows-arm64 "0.14.54" escalade@^3.1.1: version "3.1.1" @@ -615,9 +622,9 @@ extract-zip@^2.0.1: "@types/yauzl" "^2.9.1" fast-glob@^3.2.11, fast-glob@^3.2.9: - version "3.2.11" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.11.tgz#a1172ad95ceb8a16e20caa5c5e56480e5129c1d9" - integrity sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew== + version "3.2.12" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" + integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== dependencies: "@nodelib/fs.stat" "^2.0.2" "@nodelib/fs.walk" "^1.2.3" @@ -850,9 +857,9 @@ is-binary-path@~2.1.0: binary-extensions "^2.0.0" is-core-module@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.9.0.tgz#e1c34429cd51c6dd9e09e0799e396e27b19a9c69" - integrity sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A== + version "2.10.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.10.0.tgz#9012ede0a91c69587e647514e1d5277019e728ed" + integrity sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg== dependencies: has "^1.0.3" @@ -894,9 +901,9 @@ is-url@^1.2.4: integrity sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww== is2@^2.0.6: - version "2.0.7" - resolved "https://registry.yarnpkg.com/is2/-/is2-2.0.7.tgz#d084e10cab3bd45d6c9dfde7a48599fcbb93fcac" - integrity sha512-4vBQoURAXC6hnLFxD4VW7uc04XiwTTl/8ydYJxKvPwkWQrSjInkuM5VZVg6BGr1/natq69zDuvO9lGpLClJqvA== + version "2.0.9" + resolved "https://registry.yarnpkg.com/is2/-/is2-2.0.9.tgz#ff63b441f90de343fa8fac2125ee170da8e8240d" + integrity sha512-rZkHeBn9Zzq52sd9IUIV3a5mfwBY+o2HePMh0wkGBM4z4qjvy2GwVxQ6nNXSfw6MmVP6gf1QIlWjiOavhM3x5g== dependencies: deep-is "^0.1.3" ip-regex "^4.1.0" @@ -916,7 +923,7 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" -lilconfig@^2.0.5: +lilconfig@^2.0.5, lilconfig@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.6.tgz#32a384558bd58af3d4c6e077dd1ad1d397bc69d4" integrity sha512-9JROoBW7pobfsx+Sq2JsASvCo6Pfo6WWoUW79HuB1BCoBXD4PLWJPqDF6fNj67pqBYTbAHkE57M1kS/+L1neOg== @@ -1166,7 +1173,7 @@ postcss-reporter@^7.0.0: picocolors "^1.0.0" thenby "^1.3.4" -postcss-selector-parser@^6.0.10, postcss-selector-parser@^6.0.6: +postcss-selector-parser@6.0.10, postcss-selector-parser@^6.0.10, postcss-selector-parser@^6.0.6: version "6.0.10" resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.10.tgz#79b61e2c0d1bfc2602d549e11d0876256f8df88d" integrity sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w== @@ -1180,9 +1187,9 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.2.0: integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== postcss@^8.4.14: - version "8.4.14" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.14.tgz#ee9274d5622b4858c1007a74d76e42e56fd21caf" - integrity sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig== + version "8.4.16" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.16.tgz#33a1d675fac39941f5f445db0de4db2b6e01d43c" + integrity sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ== dependencies: nanoid "^3.3.4" picocolors "^1.0.0" @@ -1343,9 +1350,9 @@ tailwindcss-debug-screens@^2.2.1: integrity sha512-EMyA0CYBzqcZJHtVDvBfmYzfx3NxuK4qDyVO5wnzcGOrmJsv25D9xPpWefVTORTvhE6pCh90Z1WYnLUKsg3yMw== tailwindcss@^3, tailwindcss@~3.1.4: - version "3.1.6" - resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.1.6.tgz#bcb719357776c39e6376a8d84e9834b2b19a49f1" - integrity sha512-7skAOY56erZAFQssT1xkpk+kWt2NrO45kORlxFPXUt3CiGsVPhH1smuH5XoDH6sGPXLyBv+zgCKA2HWBsgCytg== + version "3.1.8" + resolved "https://registry.yarnpkg.com/tailwindcss/-/tailwindcss-3.1.8.tgz#4f8520550d67a835d32f2f4021580f9fddb7b741" + integrity sha512-YSneUCZSFDYMwk+TGq8qYFdCA3yfBRdBlS7txSq0LUmzyeqRe3a8fBQzbz9M3WS/iFT4BNf/nmw9mEzrnSaC0g== dependencies: arg "^5.0.2" chokidar "^3.5.3" @@ -1356,7 +1363,7 @@ tailwindcss@^3, tailwindcss@~3.1.4: fast-glob "^3.2.11" glob-parent "^6.0.2" is-glob "^4.0.3" - lilconfig "^2.0.5" + lilconfig "^2.0.6" normalize-path "^3.0.0" object-hash "^3.0.0" picocolors "^1.0.0" @@ -1395,10 +1402,10 @@ universalify@^2.0.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== -update-browserslist-db@^1.0.4: - version "1.0.5" - resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.5.tgz#be06a5eedd62f107b7c19eb5bcefb194411abf38" - integrity sha512-dteFFpCyvuDdr9S/ff1ISkKt/9YZxKjI9WlRR99c180GaztJtRa/fn18FdxGVKVsnPY7/a/FDN68mcvUmP4U7Q== +update-browserslist-db@^1.0.5: + version "1.0.7" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.7.tgz#16279639cff1d0f800b14792de43d97df2d11b7d" + integrity sha512-iN/XYesmZ2RmmWAiI4Z5rq0YqSiv0brj9Ce9CfhNE4xIW2h+MFxcgkxIzZ+ShkFPUkjU3gQ+3oypadD3RAMtrg== dependencies: escalade "^3.1.1" picocolors "^1.0.0" @@ -1448,9 +1455,9 @@ yaml@^2.1.1: integrity sha512-o96x3OPo8GjWeSLF+wOAbrPfhFOGY0W00GNaxCDv+9hkcDJEnev1yh8S7pgHF0ik6zc8sQLuL8hjHjJULZp8bw== yargs-parser@^21.0.0: - version "21.0.1" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.0.1.tgz#0267f286c877a4f0f728fceb6f8a3e4cb95c6e35" - integrity sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg== + version "21.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" + integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== yargs@^17.0.0: version "17.5.1" diff --git a/docs/CHANGELOG-autogenerated.md b/docs/CHANGELOG-autogenerated.md index 2e7e1e853f..3d27a11811 100644 --- a/docs/CHANGELOG-autogenerated.md +++ b/docs/CHANGELOG-autogenerated.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) -## [Unreleased (2022-09-09)] +## [Unreleased (2022-09-12)] ### Added - Static page generator [#444](https://github.com/bonfire-networks/bonfire-app/issues/444) diff --git a/flavours/classic/config/activity_pub.exs b/flavours/classic/config/activity_pub.exs index b092ea9e6d..8ede0034fc 100755 --- a/flavours/classic/config/activity_pub.exs +++ b/flavours/classic/config/activity_pub.exs @@ -5,7 +5,6 @@ config :activity_pub, :repo, Bonfire.Common.Repo config :nodeinfo, :adapter, Bonfire.Federate.ActivityPub.NodeinfoAdapter - config :activity_pub, :instance, hostname: "localhost", federation_publisher_modules: [ActivityPubWeb.Publisher], @@ -29,6 +28,7 @@ config :activity_pub, :mrf_simple, banner_removal: [] config :http_signatures, adapter: ActivityPub.Signature + config :activity_pub, :http, proxy_url: nil, send_user_agent: true, @@ -42,10 +42,14 @@ config :activity_pub, :http, ] config :activity_pub, ActivityPubWeb.Endpoint, - render_errors: [view: ActivityPubWeb.ErrorView, accepts: ~w(json), layout: false] + render_errors: [ + view: ActivityPubWeb.ErrorView, + accepts: ~w(json), + layout: false + ] config :activity_pub, :json_contexts, %{ - "Hashtag"=> "as:Hashtag", - "ValueFlows" => "https://w3id.org/valueflows#", - "om2" => "http://www.ontology-of-units-of-measure.org/resource/om-2/" - } + "Hashtag" => "as:Hashtag", + "ValueFlows" => "https://w3id.org/valueflows#", + "om2" => "http://www.ontology-of-units-of-measure.org/resource/om-2/" +} diff --git a/flavours/classic/config/activity_pub_test.exs b/flavours/classic/config/activity_pub_test.exs index 323eacd6fd..ac343b578e 100755 --- a/flavours/classic/config/activity_pub_test.exs +++ b/flavours/classic/config/activity_pub_test.exs @@ -12,9 +12,8 @@ config :activity_pub, Oban, repo: Bonfire.Common.Repo, queues: false -config :activity_pub, :instance, - federating: false - # rewrite_policy: [ActivityPub.MRF.SimplePolicy] +config :activity_pub, :instance, federating: false +# rewrite_policy: [ActivityPub.MRF.SimplePolicy] config :tesla, adapter: Tesla.Mock diff --git a/flavours/classic/config/bonfire_common.exs b/flavours/classic/config/bonfire_common.exs index bea861feb9..2554516914 100755 --- a/flavours/classic/config/bonfire_common.exs +++ b/flavours/classic/config/bonfire_common.exs @@ -13,10 +13,12 @@ config :bonfire_common, config :bonfire_common, Bonfire.Common.Localise.Cldr, default_locale: default_locale, - locales: ["fr", "en", "es", "it", "vi"], # locales that will be made available on top of those for which gettext localisation files are available + # locales that will be made available on top of those for which gettext localisation files are available + locales: ["fr", "en", "es", "it", "vi"], providers: [Cldr.Language], gettext: Bonfire.Common.Localise.Gettext, - extra_gettext: [Timex.Gettext], # extra Gettex modules from dependencies not using the one from Bonfire.Common, so we can change their locale too + # extra Gettex modules from dependencies not using the one from Bonfire.Common, so we can change their locale too + extra_gettext: [Timex.Gettext], data_dir: "priv/cldr", add_fallback_locales: true, # precompile_number_formats: ["¤¤#,##0.##"], diff --git a/flavours/classic/config/bonfire_data.exs b/flavours/classic/config/bonfire_data.exs index da7c58ad8d..5a91074f44 100755 --- a/flavours/classic/config/bonfire_data.exs +++ b/flavours/classic/config/bonfire_data.exs @@ -2,63 +2,83 @@ import Config #### Base configuration -verbs = ["Boost", "Create", "Delete", "Edit", "Flag", "Follow", "Like", "Mention", - "Message", "Read", "Reply", "Request", "See", "Tag"] +verbs = [ + "Boost", + "Create", + "Delete", + "Edit", + "Flag", + "Follow", + "Like", + "Mention", + "Message", + "Read", + "Reply", + "Request", + "See", + "Tag" +] # 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 +config :bonfire_data_identity, Bonfire.Data.Identity.Credential, hasher_module: hasher #### Sentinel Data Services # Search these apps/extensions for Pointable ecto schema definitions to index pointable_schema_extensions = [ - :bonfire, - :bonfire_data_access_control, - :bonfire_data_activity_pub, - :bonfire_data_identity, - :bonfire_data_social, - :bonfire_data_edges, - :bonfire_tag, - :bonfire_classify, - :bonfire_data_shared_users, - :bonfire_files, - :bonfire_quantify, - :bonfire_geolocate, - :bonfire_valueflows, - :bonfire_valueflows_observe, - ] + :bonfire, + :bonfire_data_access_control, + :bonfire_data_activity_pub, + :bonfire_data_identity, + :bonfire_data_social, + :bonfire_data_edges, + :bonfire_tag, + :bonfire_classify, + :bonfire_data_shared_users, + :bonfire_files, + :bonfire_quantify, + :bonfire_geolocate, + :bonfire_valueflows, + :bonfire_valueflows_observe +] + 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, - ] +context_and_queries_extensions = + pointable_schema_extensions ++ + [ + :bonfire_common, + :bonfire_me, + :bonfire_social + ] -extensions_with_config = context_and_queries_extensions ++ [ - :bonfire_boundaries, - :bonfire_federate_activitypub, - :bonfire_search, - :bonfire_mailer - ] +extensions_with_config = + context_and_queries_extensions ++ + [ + :bonfire_boundaries, + :bonfire_federate_activitypub, + :bonfire_search, + :bonfire_mailer + ] -extensions_with_ui = extensions_with_config ++ [ - :bonfire_ui_common, - :bonfire_ui_me, - :bonfire_ui_social, - :bonfire_ui_valueflows, - :bonfire_ui_cooperation, - :bonfire_ui_breadpub, - :bonfire_ui_kanban, - :bonfire_breadpub, - :bonfire_recycleapp, - :bonfire_ui_reflow - ] +extensions_with_ui = + extensions_with_config ++ + [ + :bonfire_ui_common, + :bonfire_ui_me, + :bonfire_ui_social, + :bonfire_ui_valueflows, + :bonfire_ui_cooperation, + :bonfire_ui_breadpub, + :bonfire_ui_kanban, + :bonfire_breadpub, + :bonfire_recycleapp, + :bonfire_ui_reflow + ] config :bonfire, :verb_names, verbs config :bonfire, :context_modules_search_path, context_and_queries_extensions @@ -70,31 +90,74 @@ config :bonfire, :ui_modules_search_path, extensions_with_ui config :bonfire_data_access_control, search_path: [ # :bonfire_me, - :bonfire_boundaries, + :bonfire_boundaries + # :bonfire_social, # :bonfire, ] #### Alias modules for readability -alias Pointers.{Pointer, Table} -alias Bonfire.Data.AccessControl.{ - Acl, Circle, Encircle, Controlled, InstanceAdmin, Grant, Verb, -} -alias Bonfire.Data.ActivityPub.{Actor, Peer, Peered} -alias Bonfire.Boundaries.{Permitted, Stereotyped} -alias Bonfire.Data.Edges.{Edge,EdgeTotal} -alias Bonfire.Data.Identity.{ - Account, Accounted, AuthSecondFactor, Caretaker, CareClosure, Character, Credential, Email, ExtraInfo, Named, Self, Settings, User, -} -alias Bonfire.Data.Social.{ - Activity, APActivity, Article, Block, Bookmark, Boost, Created, Feed, FeedPublish, - Flag, Follow, Like, Mention, Message, Post, PostContent, Profile, Replied, Request, -} +alias Pointers.Pointer +alias Pointers.Table + +alias Bonfire.Data.AccessControl.Acl +alias Bonfire.Data.AccessControl.Circle +alias Bonfire.Data.AccessControl.Encircle +alias Bonfire.Data.AccessControl.Controlled +alias Bonfire.Data.AccessControl.InstanceAdmin +alias Bonfire.Data.AccessControl.Grant +alias Bonfire.Data.AccessControl.Verb + +alias Bonfire.Data.ActivityPub.Actor +alias Bonfire.Data.ActivityPub.Peer +alias Bonfire.Data.ActivityPub.Peered + +alias Bonfire.Boundaries.Permitted +alias Bonfire.Boundaries.Stereotyped + +alias Bonfire.Data.Edges.Edge +alias Bonfire.Data.Edges.EdgeTotal + +alias Bonfire.Data.Identity.Account +alias Bonfire.Data.Identity.Accounted +alias Bonfire.Data.Identity.AuthSecondFactor +alias Bonfire.Data.Identity.Caretaker +alias Bonfire.Data.Identity.CareClosure +alias Bonfire.Data.Identity.Character +alias Bonfire.Data.Identity.Credential +alias Bonfire.Data.Identity.Email +alias Bonfire.Data.Identity.ExtraInfo +alias Bonfire.Data.Identity.Named +alias Bonfire.Data.Identity.Self +alias Bonfire.Data.Identity.Settings +alias Bonfire.Data.Identity.User + +alias Bonfire.Data.Social.Activity +alias Bonfire.Data.Social.APActivity +alias Bonfire.Data.Social.Article +alias Bonfire.Data.Social.Block +alias Bonfire.Data.Social.Bookmark +alias Bonfire.Data.Social.Boost +alias Bonfire.Data.Social.Created +alias Bonfire.Data.Social.Feed +alias Bonfire.Data.Social.FeedPublish +alias Bonfire.Data.Social.Flag +alias Bonfire.Data.Social.Follow +alias Bonfire.Data.Social.Like +alias Bonfire.Data.Social.Mention +alias Bonfire.Data.Social.Message +alias Bonfire.Data.Social.Post +alias Bonfire.Data.Social.PostContent +alias Bonfire.Data.Social.Profile +alias Bonfire.Data.Social.Replied +alias Bonfire.Data.Social.Request + alias Bonfire.Classify.Category alias Bonfire.Geolocate.Geolocation alias Bonfire.Files alias Bonfire.Files.Media -alias Bonfire.{Tag, Tag.Tagged} +alias Bonfire.Tag +alias Bonfire.Tag.Tagged #### Flexto Stitching @@ -110,177 +173,258 @@ common_assocs = %{ ### Mixins # A summary of an object that can appear in a feed. - activity: quote(do: has_one(:activity, unquote(Activity), unquote(mixin))), + activity: quote(do: has_one(:activity, unquote(Activity), unquote(mixin))), # ActivityPub actor information - actor: quote(do: has_one(:actor, unquote(Actor), unquote(mixin))), + actor: quote(do: has_one(:actor, unquote(Actor), unquote(mixin))), # Indicates the entity responsible for an activity. Sort of like creator, but transferrable. Used # during deletion - when the caretaker is deleted, all their stuff will be too. - caretaker: quote(do: has_one(:caretaker, unquote(Caretaker), unquote(mixin))), + caretaker: quote(do: has_one(:caretaker, unquote(Caretaker), unquote(mixin))), # A Character has a unique username and some feeds. - character: quote(do: has_one(:character, unquote(Character), unquote(mixin))), + character: quote(do: has_one(:character, unquote(Character), unquote(mixin))), # Indicates the creator of an object - created: quote(do: has_one(:created, unquote(Created), unquote(mixin))), + created: quote(do: has_one(:created, unquote(Created), unquote(mixin))), # Used for non-textual interactions such as likes and follows to indicate the other object. - edge: quote(do: has_one(:edge, unquote(Edge), unquote(mixin))), + edge: quote(do: has_one(:edge, unquote(Edge), unquote(mixin))), # Adds a name that can appear in the user interface for an object. e.g. for an ACL. - named: quote(do: has_one(:named, unquote(Named), unquote(mixin))), + named: quote(do: has_one(:named, unquote(Named), unquote(mixin))), # Adds extra info that can appear in the user interface for an object. e.g. a summary or JSON-encoded data. - extra_info: quote(do: has_one(:extra_info, unquote(ExtraInfo), unquote(mixin))), + extra_info: quote(do: has_one(:extra_info, unquote(ExtraInfo), unquote(mixin))), # Information about the remote instance the object is from, if it is not local. - peered: quote(do: has_one(:peered, unquote(Peered), unquote(mixin))), + peered: quote(do: has_one(:peered, unquote(Peered), unquote(mixin))), # Information about the content of posts, e.g. a scrubbed html body post_content: quote(do: has_one(:post_content, unquote(PostContent), unquote(mixin))), # Information about a user or other object that they wish to make available - profile: quote(do: has_one(:profile, unquote(Profile), unquote(mixin))), + profile: quote(do: has_one(:profile, unquote(Profile), unquote(mixin))), # Threading information, for threaded discussions. - replied: quote(do: has_one(:replied, unquote(Replied), unquote(mixin))), + replied: quote(do: has_one(:replied, unquote(Replied), unquote(mixin))), # Information that allows the system to identify special system-managed ACLS. - stereotyped: quote(do: has_one(:stereotyped, unquote(Stereotyped), unquote(mixin))), - + stereotyped: quote(do: has_one(:stereotyped, unquote(Stereotyped), unquote(mixin))), ### Multimixins # Links to access control information for this object. - controlled: quote(do: has_many(:controlled, unquote(Controlled), unquote(mixin))), + 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))), + 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)), + 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))), + 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)), - + 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 # The objects which reply to this object. - direct_replies: quote(do: has_many(:direct_replies, unquote(Replied), foreign_key: :reply_to_id)), + direct_replies: + quote(do: has_many(:direct_replies, unquote(Replied), foreign_key: :reply_to_id)), # A recursive view of caretakers of caretakers of... used during deletion. - care_closure: quote(do: has_many(:care_closure, unquote(CareClosure), foreign_key: :branch_id)), + care_closure: quote(do: has_many(:care_closure, unquote(CareClosure), foreign_key: :branch_id)), # Retrieves activities where we are the object. e.g. if we are a # post or a user, this could turn up activities from likes or follows. - activities: quote(do: has_many(:activities, unquote(Activity), foreign_key: :object_id, references: :id)), + activities: + quote( + do: + has_many(:activities, unquote(Activity), + foreign_key: :object_id, + references: :id + ) + ), ### Stuff I'm not sure how to categorise yet # Used currently only for requesting to follow a user, but more general - request: quote(do: has_one(:request, unquote(Request), unquote(mixin))), + request: quote(do: has_one(:request, unquote(Request), unquote(mixin))) } # retrieves a list of quoted forms suitable for use with unquote_splicing common = fn names -> for name <- List.wrap(names) do with nil <- common_assocs[name], - do: raise(RuntimeError, message: "Expected a common association name, got #{inspect(name)}") + do: + raise(RuntimeError, + message: "Expected a common association name, got #{inspect(name)}" + ) end end -edge = common.([:controlled, :activities, :request, :created]) -edges = common.([:controlled, :activities, :request, :created, :caretaker, :activity, :feed_publishes]) +edge = common.([:controlled, :activities, :request, :created]) + +edges = + common.([ + :controlled, + :activities, + :request, + :created, + :caretaker, + :activity, + :feed_publishes + ]) # first up, pointers could have all the mixins we're using. TODO -pointer_mixins = common.([ - :activity, :actor, :caretaker, :character, :created, :edge, - :named, :extra_info, :peered, :post_content, :profile, :replied, :stereotyped -]) +pointer_mixins = + common.([ + :activity, + :actor, + :caretaker, + :character, + :created, + :edge, + :named, + :extra_info, + :peered, + :post_content, + :profile, + :replied, + :stereotyped + ]) + config :pointers, Pointer, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - field :dummy, :any, virtual: true - # pointables - has_one :circle, unquote(Circle), foreign_key: :id - many_to_many :encircle_subjects, Pointer, join_through: Encircle, join_keys: [circle_id: :id, subject_id: :id] - has_one :permitted, unquote(Permitted), foreign_key: :object_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 - has_one :category, unquote(Category), foreign_key: :id - has_one :geolocation, unquote(Geolocation), foreign_key: :id - # mixins - unquote_splicing(pointer_mixins) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media])) - # has_many - unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes])) + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + field(:dummy, :any, virtual: true) + # pointables + has_one(:circle, unquote(Circle), foreign_key: :id) - ## special things - # these should go away in future and they should be populated by a single query. - 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] + many_to_many(:encircle_subjects, Pointer, + join_through: Encircle, + join_keys: [circle_id: :id, subject_id: :id] + ) - end] + has_one(:permitted, unquote(Permitted), foreign_key: :object_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) + has_one(:category, unquote(Category), foreign_key: :id) + has_one(:geolocation, unquote(Geolocation), foreign_key: :id) + # mixins + unquote_splicing(pointer_mixins) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media])) + # has_many + unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes])) + + ## special things + # these should go away in future and they should be populated by a single query. + 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] + ) + end) config :pointers, Table, [] # now let's weave everything else together for convenience - # bonfire_data_access_control config :bonfire_data_access_control, Acl, - [code: quote do - field :grants_count, :integer, virtual: true - field :controlled_count, :integer, virtual: true - # mixins - unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) - # multimixins - # unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:grants_count, :integer, virtual: true) + field(:controlled_count, :integer, virtual: true) + # mixins + unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) + + # multimixins + # unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Circle, - [code: quote do - field :encircles_count, :integer, virtual: true - # mixins - unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) - # multimixins - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:encircles_count, :integer, virtual: true) + # mixins + unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) + + # multimixins + unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Controlled, [] config :bonfire_data_access_control, Encircle, - [code: quote do - has_one :peer, unquote(Peer), foreign_key: :id, references: :subject_id - end] + code: + (quote do + has_one(:peer, unquote(Peer), foreign_key: :id, references: :subject_id) + end) config :bonfire_data_access_control, Grant, - [code: quote do - # mixins - unquote_splicing(common.([:caretaker])) - # multimixins - # unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:caretaker]))) + + # multimixins + # unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Verb, [] config :bonfire_boundaries, Stereotyped, - [code: quote do - has_one(:named, unquote(Named), [foreign_key: :id, references: :stereotype_id]) - end] + code: + (quote do + has_one(:named, unquote(Named), + foreign_key: :id, + references: :stereotype_id + ) + end) # bonfire_data_activity_pub config :bonfire_data_activity_pub, Actor, - [code: quote do - # hacks - belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - # mixins - unquote_splicing(common.([:peered])) - # multimixins - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # hacks + belongs_to(:character, unquote(Character), + foreign_key: :id, + define_field: false + ) + + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + # mixins + unquote_splicing(common.([:peered])) + # multimixins + unquote_splicing(common.([:controlled])) + end) config :bonfire_data_activity_pub, Peer, [] config :bonfire_data_activity_pub, Peered, [] @@ -288,86 +432,153 @@ config :bonfire_data_activity_pub, Peered, [] # bonfire_data_identity config :bonfire_data_identity, Account, - [code: quote do - has_one :credential, unquote(Credential),foreign_key: :id - has_one :email, unquote(Email), foreign_key: :id - has_one :auth_second_factor, unquote(AuthSecondFactor), foreign_key: :id - has_one :settings, unquote(Settings), foreign_key: :id - many_to_many :users, unquote(User), - join_through: Accounted, - join_keys: [account_id: :id, id: :id] - many_to_many :shared_users, unquote(User), # optional - join_through: "bonfire_data_shared_user_accounts", - join_keys: [account_id: :id, shared_user_id: :id] - end] + code: + (quote do + has_one(:credential, unquote(Credential), foreign_key: :id) + has_one(:email, unquote(Email), foreign_key: :id) + has_one(:auth_second_factor, unquote(AuthSecondFactor), foreign_key: :id) + has_one(:settings, unquote(Settings), foreign_key: :id) + + many_to_many(:users, unquote(User), + join_through: Accounted, + join_keys: [account_id: :id, id: :id] + ) + + # optional + many_to_many(:shared_users, unquote(User), + join_through: "bonfire_data_shared_user_accounts", + join_keys: [account_id: :id, shared_user_id: :id] + ) + end) config :bonfire_data_identity, Accounted, - [code: quote do - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Caretaker, - [code: quote do - has_one :user, unquote(User), foreign_key: :id, references: :caretaker_id - # mixins - unquote_splicing(common.([:character, :profile])) - end] + code: + (quote do + has_one(:user, unquote(User), foreign_key: :id, references: :caretaker_id) + + # mixins + unquote_splicing(common.([:character, :profile])) + end) config :bonfire_data_identity, Character, - [code: quote do - @follow_ulid "70110WTHE1EADER1EADER1EADE" - # mixins - unquote_splicing(common.([:actor, :peered, :profile])) - has_one :user, unquote(User), unquote(mixin) - has_one :feed, unquote(Feed), unquote(mixin) - has_many :followers, unquote(Follow), foreign_key: :following_id, references: :id - has_many :followed, unquote(Follow), foreign_key: :follower_id, references: :id - has_one :follow_count, unquote(EdgeTotal), foreign_key: :id, references: :id, - where: [table_id: @follow_ulid] - end] + code: + (quote do + @follow_ulid "70110WTHE1EADER1EADER1EADE" + # mixins + unquote_splicing(common.([:actor, :peered, :profile])) + has_one(:user, unquote(User), unquote(mixin)) + has_one(:feed, unquote(Feed), unquote(mixin)) + + has_many(:followers, unquote(Follow), + foreign_key: :following_id, + references: :id + ) + + has_many(:followed, unquote(Follow), + foreign_key: :follower_id, + references: :id + ) + + has_one(:follow_count, unquote(EdgeTotal), + foreign_key: :id, + references: :id, + where: [table_id: @follow_ulid] + ) + end) config :bonfire_data_identity, Credential, - [code: quote do - belongs_to :account, unquote(Account), foreign_key: :id, define_field: false - end] + code: + (quote do + belongs_to(:account, unquote(Account), + foreign_key: :id, + define_field: false + ) + end) config :bonfire_data_identity, Email, - [must_confirm: true, - code: quote do - belongs_to :account, unquote(Account), foreign_key: :id, define_field: false - end] + must_confirm: true, + code: + (quote do + belongs_to(:account, unquote(Account), + foreign_key: :id, + define_field: false + ) + end) config :bonfire_data_identity, Self, [] config :bonfire_data_identity, User, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - # mixins - has_one :accounted, unquote(Accounted), foreign_key: :id - has_one :instance_admin, unquote(InstanceAdmin), foreign_key: :id, on_replace: :update - has_one :self, unquote(Self), foreign_key: :id - has_one :shared_user, unquote(Bonfire.Data.SharedUser), foreign_key: :id - has_one :settings, unquote(Settings), foreign_key: :id - unquote_splicing(common.([:actor, :character, :created, :peered, :profile])) - # multimixins - unquote_splicing(common.([:controlled])) - # manies - has_many :encircles, unquote(Encircle), foreign_key: :subject_id - has_many :creations, through: [:created, :pointer] # todo: stop through - has_many :posts, through: [:created, :post] # todo: stop through - has_many :followers, unquote(Edge), foreign_key: :object_id, references: :id, where: [table_id: @follow_ulid] - has_many :followed, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @follow_ulid] - has_many :user_activities, unquote(Activity), foreign_key: :subject_id, references: :id - has_many :boost_activities, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @boost_ulid] - has_many :like_activities, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @like_ulid] - many_to_many :caretaker_accounts, unquote(Account), - 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 # enable if using Geolocate extension - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + # mixins + has_one(:accounted, unquote(Accounted), foreign_key: :id) + + has_one(:instance_admin, unquote(InstanceAdmin), + foreign_key: :id, + on_replace: :update + ) + + has_one(:self, unquote(Self), foreign_key: :id) + has_one(:shared_user, unquote(Bonfire.Data.SharedUser), foreign_key: :id) + has_one(:settings, unquote(Settings), foreign_key: :id) + + unquote_splicing(common.([:actor, :character, :created, :peered, :profile])) + + # multimixins + unquote_splicing(common.([:controlled])) + # manies + has_many(:encircles, unquote(Encircle), foreign_key: :subject_id) + # todo: stop through + has_many(:creations, through: [:created, :pointer]) + # todo: stop through + has_many(:posts, through: [:created, :post]) + + has_many(:followers, unquote(Edge), + foreign_key: :object_id, + references: :id, + where: [table_id: @follow_ulid] + ) + + has_many(:followed, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @follow_ulid] + ) + + has_many(:user_activities, unquote(Activity), + foreign_key: :subject_id, + references: :id + ) + + has_many(:boost_activities, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @boost_ulid] + ) + + has_many(:like_activities, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @like_ulid] + ) + + many_to_many(:caretaker_accounts, unquote(Account), + 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 # enable if using Geolocate extension + end) config :bonfire_data_identity, Named, [] config :bonfire_data_identity, ExtraInfo, [] @@ -375,336 +586,525 @@ config :bonfire_data_identity, ExtraInfo, [] ### bonfire_data_social config :bonfire_data_social, Activity, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - has_many :feed_publishes, unquote(FeedPublish), unquote(mixin) - has_one :seen, unquote(Edge), foreign_key: :object_id, references: :id - # ugly workaround needed for certain queries (TODO: check if still needed) - has_one :activity, unquote(Activity), foreign_key: :id, references: :id - # 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] - has_many :controlled, unquote(Controlled), foreign_key: :id, references: :object_id - has_many :tagged, unquote(Tagged), foreign_key: :id, references: :object_id - many_to_many :tags, unquote(Pointer), - join_through: unquote(Tagged), - 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] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + has_many(:feed_publishes, unquote(FeedPublish), unquote(mixin)) + has_one(:seen, unquote(Edge), foreign_key: :object_id, references: :id) + + # ugly workaround needed for certain queries (TODO: check if still needed) + has_one(:activity, unquote(Activity), foreign_key: :id, references: :id) + # 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] + ) + + has_many(:controlled, unquote(Controlled), + foreign_key: :id, + references: :object_id + ) + + has_many(:tagged, unquote(Tagged), + foreign_key: :id, + references: :object_id + ) + + many_to_many(:tags, unquote(Pointer), + join_through: unquote(Tagged), + 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, - [code: quote do - unquote_splicing(common.([:activity, :caretaker, :controlled])) - end] + code: + (quote do + (unquote_splicing(common.([:activity, :caretaker, :controlled]))) + end) config :bonfire_data_edges, Edge, - [code: quote do - unquote_splicing(edge) - # TODO: requires composite foreign keys: - # has_one :activity, unquote(Activity), - # foreign_key: [:table_id, :object_id], references: [:table_id, :object_id] - end] + code: + (quote do + (unquote_splicing(edge)) + + # TODO: requires composite foreign keys: + # has_one :activity, unquote(Activity), + # foreign_key: [:table_id, :object_id], references: [:table_id, :object_id] + end) config :bonfire_data_social, Feed, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker])) - # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - # belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:activity, :caretaker]))) + + # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false + # belongs_to :user, unquote(User), foreign_key: :id, define_field: false + end) config :bonfire_data_social, FeedPublish, - [code: quote do - field :dummy, :any, virtual: true - has_one :activity, unquote(Activity), foreign_key: :object_id, references: :id - # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - # belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + field(:dummy, :any, virtual: true) + has_one(:activity, unquote(Activity), + foreign_key: :object_id, + references: :id + ) + + # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false + # belongs_to :user, unquote(User), foreign_key: :id, define_field: false + end) config :bonfire_data_social, Follow, - [code: quote do - unquote_splicing(edges) - end] - # 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}] + code: + (quote do + (unquote_splicing(edges)) + end) + +# 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}] config :bonfire_data_social, Block, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Boost, - [code: quote do - unquote_splicing(edges) - end] - # has_one: [activity: {Activity, foreign_key: :object_id, references: :boosted_id}] # requires an ON clause + code: + (quote do + (unquote_splicing(edges)) + end) + +# has_one: [activity: {Activity, foreign_key: :object_id, references: :boosted_id}] # requires an ON clause config :bonfire_data_social, Like, - [code: quote do - unquote_splicing(edges) - end] - # has_one: [activity: {Activity, foreign_key: :object_id, references: :liked_id}] # requires an ON clause + code: + (quote do + (unquote_splicing(edges)) + end) + +# has_one: [activity: {Activity, foreign_key: :object_id, references: :liked_id}] # requires an ON clause config :bonfire_data_social, Flag, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Request, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Bookmark, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Message, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - # mixins - unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied])) - # multimixins - 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] - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + # mixins + unquote_splicing( + common.([ + :activity, + :caretaker, + :created, + :peered, + :post_content, + :replied + ]) + ) + + # multimixins + 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] + ) + end) config :bonfire_data_social, Mention, [] config :bonfire_data_social, Post, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - # mixins - unquote_splicing(common.([:activities, :activity, :caretaker, :created, :peered, :post_content, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - # special - has_one :permitted, unquote(Permitted), foreign_key: :object_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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause - # 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 :like_count, unquote(EdgeTotal), - 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] - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + # mixins + unquote_splicing( + common.([ + :activities, + :activity, + :caretaker, + :created, + :peered, + :post_content, + :replied + ]) + ) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes])) + + # has + unquote_splicing(common.([:direct_replies])) + # special + has_one(:permitted, unquote(Permitted), foreign_key: :object_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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause + # 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(:like_count, unquote(EdgeTotal), + 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] + ) + end) config :bonfire_data_social, PostContent, - [code: quote do - # mixins - unquote_splicing(common.([:created])) - # multimixins - unquote_splicing(common.([:controlled])) - # virtuals for changesets - field :hashtags, {:array, :any}, virtual: true - field :mentions, {:array, :any}, virtual: true - field :urls, {:array, :any}, virtual: true - end] + code: + (quote do + # mixins + unquote_splicing(common.([:created])) + # multimixins + unquote_splicing(common.([:controlled])) + # virtuals for changesets + field(:hashtags, {:array, :any}, virtual: true) + field(:mentions, {:array, :any}, virtual: true) + field(:urls, {:array, :any}, virtual: true) + end) config :bonfire_data_social, Replied, - [code: quote do - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) + code: + (quote do + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) - @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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id - 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 - 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] + @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_one(:activity, unquote(Activity), + foreign_key: :object_id, + references: :id + ) + + # used in changesets + field(:replying_to, :map, virtual: true) + + 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 + ) + + 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) 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 - # mixins - shouldn't be here really - unquote_splicing(common.([:peered])) - has_one :post, unquote(Post), unquote(mixin) # huh? - end] + 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 + ) + + # mixins - shouldn't be here really + unquote_splicing(common.([:peered])) + # huh? + has_one(:post, unquote(Post), unquote(mixin)) + end) config :bonfire_data_social, Profile, - [code: quote do - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) + end) ######### other extensions config :bonfire_files, Media, - [code: quote do - field :url, :string, virtual: true - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:url, :string, virtual: true) + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) + end) config :bonfire_tag, Tagged, - [code: quote do - # mixins - unquote_splicing(common.([:activity])) - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:activity]))) + end) config :bonfire_classify, Category, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :created, :actor, :peered, :profile, :character])) # TODO :caretaker - # multimixins - unquote_splicing(common.([:controlled, :feed_publishes])) + code: + (quote do + # mixins + # TODO :caretaker + unquote_splicing(common.([:activity, :created, :actor, :peered, :profile, :character])) - has_one(:creator, through: [:created, :creator]) + # multimixins + unquote_splicing(common.([:controlled, :feed_publishes])) - # add references of tagged objects to any Category - many_to_many :tags, unquote(Pointer), - join_through: unquote(Tagged), - unique: true, - join_keys: [tag_id: :id, id: :id], - on_replace: :delete - end] + has_one(:creator, through: [:created, :creator]) + + # add references of tagged objects to any Category + many_to_many(:tags, unquote(Pointer), + join_through: unquote(Tagged), + unique: true, + join_keys: [tag_id: :id, id: :id], + 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] + 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, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + # TODO :caretaker + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.EconomicResource, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Knowledge.ResourceSpecification, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Process, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Knowledge.ProcessSpecification, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Planning.Intent, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Planning.Commitment, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Proposal, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows_observe, ValueFlows.Observe.Observation, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) diff --git a/flavours/classic/config/bonfire_fail.exs b/flavours/classic/config/bonfire_fail.exs index d9b3d2fd13..88ad8bff65 100755 --- a/flavours/classic/config/bonfire_fail.exs +++ b/flavours/classic/config/bonfire_fail.exs @@ -12,9 +12,11 @@ config :bonfire_fail, bad_header: {400, "Bad request: malformed header."}, no_access: {403, "This site is by invitation only."}, token_expired: {403, "This link or token has expired, please request a fresh one."}, - already_claimed: {403, "This link or token was already used, please request a fresh one if necessary."}, + already_claimed: + {403, "This link or token was already used, please request a fresh one if necessary."}, token_not_found: {403, "This token was not found, please request a fresh one."}, - user_disabled: {403, "This user account is disabled. Please contact the instance administrator."}, + user_disabled: + {403, "This user account is disabled. Please contact the instance administrator."}, email_not_confirmed: {403, "Please confirm your email address first."}, unknown_resource: {400, "Unknown resource."}, invalid_argument: {400, "Invalid arguments passed."}, diff --git a/flavours/classic/config/bonfire_gc.exs b/flavours/classic/config/bonfire_gc.exs index 340e2c846d..609cc3140d 100644 --- a/flavours/classic/config/bonfire_gc.exs +++ b/flavours/classic/config/bonfire_gc.exs @@ -21,5 +21,5 @@ config :bonfire_gc, Bonfire.Data.Identity.Caretaker, Bonfire.Data.Identity.Self, Bonfire.Data.Social.PostContent - ], + ] ] diff --git a/flavours/classic/config/bonfire_geolocate.exs b/flavours/classic/config/bonfire_geolocate.exs index 49c9723926..1d5142d211 100755 --- a/flavours/classic/config/bonfire_geolocate.exs +++ b/flavours/classic/config/bonfire_geolocate.exs @@ -3,5 +3,4 @@ import Config config :bonfire_geolocate, templates_path: "lib" -config :bonfire, :js_config, - mapbox_api_key: System.get_env("MAPBOX_API_KEY") +config :bonfire, :js_config, mapbox_api_key: System.get_env("MAPBOX_API_KEY") diff --git a/flavours/classic/config/bonfire_open_id.exs b/flavours/classic/config/bonfire_open_id.exs index c0873bf5a1..42cf871e60 100644 --- a/flavours/classic/config/bonfire_open_id.exs +++ b/flavours/classic/config/bonfire_open_id.exs @@ -11,17 +11,16 @@ config :boruta, Boruta.Oauth, ] # config :bonfire_open_id, :openid_connect_providers, - # bonfire_cafe: [ - # discovery_document_uri: "https://bonfire.cafe/.well-known/openid-configuration", - # client_id: "CLIENT_ID", - # client_secret: "CLIENT_SECRET", - # redirect_uri: "https://myinstance.net/", - # response_type: "code", - # scope: "identity data:public" - # ] +# bonfire_cafe: [ +# discovery_document_uri: "https://bonfire.cafe/.well-known/openid-configuration", +# client_id: "CLIENT_ID", +# client_secret: "CLIENT_SECRET", +# redirect_uri: "https://myinstance.net/", +# response_type: "code", +# scope: "identity data:public" +# ] - -if Mix.env()==:test do +if Mix.env() == :test do config :bonfire_open_id, :oauth_module, Boruta.OauthMock config :bonfire_open_id, :openid_module, Boruta.OpenidMock end diff --git a/flavours/classic/config/bonfire_ui.exs b/flavours/classic/config/bonfire_ui.exs index 9cc61327c9..e5a8a16a45 100755 --- a/flavours/classic/config/bonfire_ui.exs +++ b/flavours/classic/config/bonfire_ui.exs @@ -2,15 +2,15 @@ import Config # Please note that these are defaults meant to be overriden in Settings rather than edited here config :bonfire, :ui, - theme: [ - instance_name: "Bonfire", - instance_theme: "bonfire", - instance_icon: "/images/bonfire-icon.png", - instance_image: "/images/bonfires.png", - instance_description: "This is a bonfire demo instance for testing purposes", - instance_welcome: [ - title: "👋 Welcome", - description: " + theme: [ + instance_name: "Bonfire", + instance_theme: "bonfire", + instance_icon: "/images/bonfire-icon.png", + instance_image: "/images/bonfires.png", + instance_description: "This is a bonfire demo instance for testing purposes", + instance_welcome: [ + title: "👋 Welcome", + description: " Bonfire is a federated social networking toolkit for communities and individuals to design, operate and control their digital lives, by assembling their own social networks like lego blocks in order to cultivate safe and private spaces while being interconnected with the rest of the 'fediverse' and the internet at wide on their own terms. The bonfire ecosystem will include: 1. Bonfire apps/flavours: Open source federated networks that are ready to be installed and used for different purposes. Made up of a set of pre-configured extensions. @@ -19,122 +19,123 @@ The bonfire ecosystem will include: 4. Bonfire cloud services: Your public identity in the cloud can receive messages even when your device is offline. Syncs your Bonfire device with the fediverse, and deletes already-synced data from the cloud. Open source so others can host equivalent services. More details at https://bonfirenetworks.org", - links: [ - "About Bonfire": "https://bonfirenetworks.org/", - "Forum": "https://socialhub.activitypub.rocks/g/bonfire/activity/posts", - "Community Chat": "https://matrix.to/#/%23bonfire-networks:matrix.org", - "Contribute": "https://bonfirenetworks.org/contribute/" - ] + links: [ + "About Bonfire": "https://bonfirenetworks.org/", + Forum: "https://socialhub.activitypub.rocks/g/bonfire/activity/posts", + "Community Chat": "https://matrix.to/#/%23bonfire-networks:matrix.org", + Contribute: "https://bonfirenetworks.org/contribute/" ] - ], # end theme - # rich_text_editor_disabled: true, - rich_text_editor: Bonfire.Editor.Quill, - # rich_text_editor: Bonfire.Editor.Ck, - font_family: "Inter (Latin Languages)", # default - font_families: [ - "Inter (Latin Languages)", - "Inter (More Languages)", - "Noto Sans (Latin Languages)", - "Noto Sans (More Languages)", - "OpenDyslexic" - ], - theme: "bonfire", - themes: [ - "bonfire", - "light", - "dark", - "cupcake", - "bumblebee", - "emerald", - "corporate", - "synthwave", - "retro", - "cyberpunk", - "valentine", - "halloween", - "garden", - "forest", - "aqua", - "lofi", - "pastel", - "fantasy", - "wireframe", - "black", - "luxury", - "dracula", - "cmyk", - "autumn", - "business", - "acid", - "lemonade", - "night", - "coffee", - "winter" - ], + ] + ], - show_trending_tags: [ - disabled: false, - for_last_x_days: 30, - limit: 8, - ], - sidebar_components: [ - {Bonfire.UI.Social.SidebarNavigationLive, []}, - ], - smart_input: [ - post: true, - cw: true, - summary: true - ], - profile: [ - sections: [ - timeline: Bonfire.UI.Social.ProfileTimelineLive, - # private: Bonfire.UI.Social.MessageThreadsLive, - posts: Bonfire.UI.Social.ProfilePostsLive, - boosts: Bonfire.UI.Social.ProfileBoostsLive, - followers: Bonfire.UI.Social.ProfileFollowsLive, - followed: Bonfire.UI.Social.ProfileFollowsLive, - follow: Bonfire.UI.Me.RemoteInteractionFormLive, - ], - navigation: [ - timeline: "Timeline", - posts: "Posts", - boosts: "Boosts", - # private: "Messages", - ], - widgets: [ - ], - ], - category: [ - navigation: [ - timeline: "Published", - submitted: "Submitted" - ], - sections: [ - timeline: Bonfire.UI.Social.ProfileTimelineLive, - posts: Bonfire.UI.Social.ProfilePostsLive, - boosts: Bonfire.UI.Social.ProfileBoostsLive, - followers: Bonfire.UI.Social.ProfileFollowsLive, - follow: Bonfire.UI.Me.RemoteInteractionFormLive, - new: Bonfire.Classify.Web.NewCategoryLive, - settings: Bonfire.Classify.Web.SettingsLive - ], - ], - smart_input_activities: [ - post: "Compose a post", - category: "Create a topic", - # offer: "Publish an offer", - # need: "Publish a need", - # transfer_resource: "Transfer a resource", - # produce_resource: "Add a resource", - # intent: "Indicate an itent", - # economic_event: "Record an economic event", - # process: "Define a process" - ], - smart_input_components: [ - post: Bonfire.UI.Social.WritePostContentLive, - message: Bonfire.UI.Social.WritePostContentLive, - category: Bonfire.Classify.Web.NewCategoryLive, - ], + # end theme + # rich_text_editor_disabled: true, + rich_text_editor: Bonfire.Editor.Quill, + # rich_text_editor: Bonfire.Editor.Ck, + # default + font_family: "Inter (Latin Languages)", + font_families: [ + "Inter (Latin Languages)", + "Inter (More Languages)", + "Noto Sans (Latin Languages)", + "Noto Sans (More Languages)", + "OpenDyslexic" + ], + theme: "bonfire", + themes: [ + "bonfire", + "light", + "dark", + "cupcake", + "bumblebee", + "emerald", + "corporate", + "synthwave", + "retro", + "cyberpunk", + "valentine", + "halloween", + "garden", + "forest", + "aqua", + "lofi", + "pastel", + "fantasy", + "wireframe", + "black", + "luxury", + "dracula", + "cmyk", + "autumn", + "business", + "acid", + "lemonade", + "night", + "coffee", + "winter" + ], + show_trending_tags: [ + disabled: false, + for_last_x_days: 30, + limit: 8 + ], + sidebar_components: [ + {Bonfire.UI.Social.SidebarNavigationLive, []} + ], + smart_input: [ + post: true, + cw: true, + summary: true + ], + profile: [ + sections: [ + timeline: Bonfire.UI.Social.ProfileTimelineLive, + # private: Bonfire.UI.Social.MessageThreadsLive, + posts: Bonfire.UI.Social.ProfilePostsLive, + boosts: Bonfire.UI.Social.ProfileBoostsLive, + followers: Bonfire.UI.Social.ProfileFollowsLive, + followed: Bonfire.UI.Social.ProfileFollowsLive, + follow: Bonfire.UI.Me.RemoteInteractionFormLive + ], + navigation: [ + timeline: "Timeline", + posts: "Posts", + boosts: "Boosts" + # private: "Messages", + ], + widgets: [] + ], + category: [ + navigation: [ + timeline: "Published", + submitted: "Submitted" + ], + sections: [ + timeline: Bonfire.UI.Social.ProfileTimelineLive, + posts: Bonfire.UI.Social.ProfilePostsLive, + boosts: Bonfire.UI.Social.ProfileBoostsLive, + followers: Bonfire.UI.Social.ProfileFollowsLive, + follow: Bonfire.UI.Me.RemoteInteractionFormLive, + new: Bonfire.Classify.Web.NewCategoryLive, + settings: Bonfire.Classify.Web.SettingsLive + ] + ], + smart_input_activities: [ + post: "Compose a post", + category: "Create a topic" + # offer: "Publish an offer", + # need: "Publish a need", + # transfer_resource: "Transfer a resource", + # produce_resource: "Add a resource", + # intent: "Indicate an itent", + # economic_event: "Record an economic event", + # process: "Define a process" + ], + smart_input_components: [ + post: Bonfire.UI.Social.WritePostContentLive, + message: Bonfire.UI.Social.WritePostContentLive, + category: Bonfire.Classify.Web.NewCategoryLive + ], invites_component: Bonfire.Invite.Links.Web.InvitesLive # config :surface_boxicon, diff --git a/flavours/classic/config/config.exs b/flavours/classic/config/config.exs index a08817d48e..260d76568c 100755 --- a/flavours/classic/config/config.exs +++ b/flavours/classic/config/config.exs @@ -2,7 +2,7 @@ import Config default_flavour = "classic" flavour = System.get_env("FLAVOUR", default_flavour) -flavour_path = System.get_env("FLAVOUR_PATH", "flavours/"<>flavour) +flavour_path = System.get_env("FLAVOUR_PATH", "flavours/" <> flavour) #### Basic configuration @@ -26,9 +26,12 @@ config :bonfire, org_schema: Bonfire.Data.Identity.User, home_page: Bonfire.Web.HomeLive, user_home_page: Bonfire.UI.Social.FeedsLive, - default_pagination_limit: 15, # limit for prod - thread_default_pagination_limit: 500, # very high limit for prod - thread_default_max_depth: 3, # how many nested replies to show + # limit for prod + default_pagination_limit: 15, + # very high limit for prod + thread_default_pagination_limit: 500, + # how many nested replies to show + thread_default_max_depth: 3, localisation_path: "priv/localisation", ap_base_path: System.get_env("AP_BASE_PATH", "/pub"), signing_salt: "this-will-be-overriden-by-a-secure-string-in-runtime.exs", @@ -37,10 +40,15 @@ config :bonfire, config :bonfire, Bonfire.Web.Endpoint, url: [host: "localhost"], http: [ - port: String.to_integer(System.get_env("SERVER_PORT", "4000")), # this gets overriden in runtime.exs + # this gets overriden in runtime.exs + port: String.to_integer(System.get_env("SERVER_PORT", "4000")), transport_options: [socket_opts: [:inet6]] ], - render_errors: [view: Bonfire.UI.Common.ErrorView, accepts: ~w(html json), layout: false], + render_errors: [ + view: Bonfire.UI.Common.ErrorView, + accepts: ~w(html json), + layout: false + ], pubsub_server: Bonfire.PubSub config :phoenix, :json_library, Jason @@ -48,11 +56,17 @@ config :phoenix_gon, :json_library, Jason config :ecto_sparkles, :otp_app, :bonfire config :bonfire, :ecto_repos, [Bonfire.Common.Repo] + config :bonfire, Bonfire.Common.Repo, - types: Bonfire.Geolocate.PostgresTypes # point to the appropriate definition to support any Postgres extensions used by your Bonfire flavour or extensions - # priv: flavour_path <> "/repo", + # point to the appropriate definition to support any Postgres extensions used by your Bonfire flavour or extensions + types: Bonfire.Geolocate.PostgresTypes + +# priv: flavour_path <> "/repo", config :ecto_sparkles, :otp_app, :bonfire -config :ecto_shorts, repo: Bonfire.Common.Repo, error_module: EctoShorts.Actions.Error + +config :ecto_shorts, + repo: Bonfire.Common.Repo, + error_module: EctoShorts.Actions.Error # ecto query filtering # config :query_elf, :id_types, [:id, :binary_id, Pointers.ULID] @@ -63,8 +77,7 @@ config :logger, :console, config :elixir, :dbg_callback, {Untangle, :custom_dbg, []} -config :surface, :compiler, - warn_on_undefined_props: false +config :surface, :compiler, warn_on_undefined_props: false config :bonfire, Oban, repo: Bonfire.Common.Repo, @@ -85,13 +98,12 @@ config :mime, :types, %{ config :sentry, dsn: "this-will-be-overriden-by-a-secure-string-in-runtime.exs", - environment_name: Mix.env, + environment_name: Mix.env(), # enable_source_code_context: true, root_source_code_path: File.cwd!(), included_environments: [:prod, :dev], tags: %{app_version: Mix.Project.config()[:version]} - # include config for all used Bonfire extensions for config <- "bonfire_*.exs" |> Path.expand(__DIR__) |> Path.wildcard() do # IO.inspect(include_config: config) @@ -100,6 +112,5 @@ end import_config "activity_pub.exs" - # finally, append/override config based on env, which will override any config set above (including from imported files) import_config "#{config_env()}.exs" diff --git a/flavours/classic/config/dev.exs b/flavours/classic/config/dev.exs index 4227d714eb..24808ff992 100755 --- a/flavours/classic/config/dev.exs +++ b/flavours/classic/config/dev.exs @@ -4,8 +4,10 @@ import Config changelog_issues_closed_after = "2022-08-30" config :bonfire, - experimental_features_enabled: true, # Note: you can run `Bonfire.Common.Config.put(:experimental_features_enabled, true)` to enable these in prod too - default_pagination_limit: 10 # low limit so it is easier to test + # Note: you can run `Bonfire.Common.Config.put(:experimental_features_enabled, true)` to enable these in prod too + experimental_features_enabled: true, + # low limit so it is easier to test + default_pagination_limit: 10 # config :pseudo_gettext, :locale, "en-pseudo_text" # uncomment to use https://en.wikipedia.org/wiki/Pseudolocalization and check that the app is properly localisable @@ -20,15 +22,22 @@ path_dep_dirs = |> Enum.map(&(Keyword.fetch!(elem(&1, 1), :path) <> "/lib")) config :phoenix_live_reload, - dirs: path_dep_dirs ++ ["lib/"] # watch the app's lib/ dir + the dep/lib/ dir of every locally-cloned dep + # watch the app's lib/ dir + the dep/lib/ dir of every locally-cloned dep + dirs: path_dep_dirs ++ ["lib/"] -path_dep_patterns = path_dep_dirs |> Enum.map(&(String.slice(&1, 2..1000) <>".*ex")) # to include cloned code in patterns -path_dep_patterns = path_dep_patterns ++ path_dep_dirs |> Enum.map(&(String.slice(&1, 2..1000) <>".*sface")) # Surface views +# to include cloned code in patterns +path_dep_patterns = Enum.map(path_dep_dirs, &(String.slice(&1, 2..1000) <> ".*ex")) + +# Surface views +path_dep_patterns = + (path_dep_patterns ++ path_dep_dirs) + |> Enum.map(&(String.slice(&1, 2..1000) <> ".*sface")) # Watch static and templates for browser reloading. config :bonfire, Bonfire.Web.Endpoint, server: true, - debug_errors: true, # In the development environment, Phoenix will debug errors by default, showing us a very informative debugging page. If we want to see what the application would serve in production, set to false + # In the development environment, Phoenix will debug errors by default, showing us a very informative debugging page. If we want to see what the application would serve in production, set to false + debug_errors: true, check_origin: false, code_reloader: true, watchers: [ @@ -50,49 +59,51 @@ config :bonfire, Bonfire.Web.Endpoint, ] ], live_reload: [ - patterns: [ - # ~r"^priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", - # ~r"^priv/gettext/.*(po)$", - # ~r"^web/(live|views)/.*ex$", - # ~r"^lib/.*_live\.ex$", - # ~r".*leex$", - ~r"lib/.*(ex|sface)$", - ~r"priv/catalogue/.*(ex)$", - ] ++ path_dep_patterns - ] + patterns: + [ + # ~r"^priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", + # ~r"^priv/gettext/.*(po)$", + # ~r"^web/(live|views)/.*ex$", + # ~r"^lib/.*_live\.ex$", + # ~r".*leex$", + # defp elixirc_paths(:dev), do: ["lib"] ++ catalogues() -# defp elixirc_paths(:dev), do: ["lib"] ++ catalogues() + ~r"lib/.*(ex|sface)$", + ~r"priv/catalogue/.*(ex)$" + ] ++ path_dep_patterns + ] config :logger, :console, level: :debug, truncate: :infinity, - format: "[$level] $message\n" # Do not include metadata or timestamps + # Do not include metadata or timestamps + format: "[$level] $message\n" config :phoenix, :stacktrace_depth, 30 config :phoenix, :plug_init_mode, :runtime -config :surface, :compiler, - warn_on_undefined_props: true +config :surface, :compiler, warn_on_undefined_props: true config :exsync, src_monitor: true, extra_extensions: [".leex", ".js", ".css", ".sface"] config :versioce, :changelog, - datagrabber: Versioce.Changelog.DataGrabber.Git, # Or your own datagrabber module - formatter: Versioce.Changelog.Formatter.Keepachangelog # Or your own formatter module + # Or your own datagrabber module + datagrabber: Versioce.Changelog.DataGrabber.Git, + # Or your own formatter module + formatter: Versioce.Changelog.Formatter.Keepachangelog config :versioce, :changelog, closed_after: changelog_issues_closed_after, changelog_file: "docs/CHANGELOG-autogenerated.md", datagrabber: Bonfire.Common.Changelog.Github.DataGrabber, - anchors: - %{ - added: ["Feature"], - changed: ["Improvement", "UI/UX", "Refactor"], - deprecated: ["[DEP]"], - removed: ["[REM]"], - fixed: ["Bug"], - security: ["Security", "Safety"] - } + anchors: %{ + added: ["Feature"], + changed: ["Improvement", "UI/UX", "Refactor"], + deprecated: ["[DEP]"], + removed: ["[REM]"], + fixed: ["Bug"], + security: ["Security", "Safety"] + } diff --git a/flavours/classic/config/prod.exs b/flavours/classic/config/prod.exs index 8a3cad9d37..dea572d579 100755 --- a/flavours/classic/config/prod.exs +++ b/flavours/classic/config/prod.exs @@ -1,13 +1,11 @@ import Config - # We include the path to a cache manifest # containing the digested version of static files. This # manifest is generated by the `mix phx.digest` task, # which you should run after static files are built and # before starting your production server. -config :bonfire, Bonfire.Web.Endpoint, - cache_static_manifest: "priv/static/cache_manifest.json" +config :bonfire, Bonfire.Web.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json" config :logger, backends: [:console, Sentry.LoggerBackend] @@ -18,4 +16,5 @@ config :logger, level: :info config :bonfire, Bonfire.Web.Endpoint, server: true config :bonfire, Bonfire.Common.Repo, - priv: "priv/repo" # in releases migrations are not in a flavour-specific directory + # in releases migrations are not in a flavour-specific directory + priv: "priv/repo" diff --git a/flavours/classic/config/runtime.exs b/flavours/classic/config/runtime.exs index 5bc9ec0a96..bb7dfff413 100755 --- a/flavours/classic/config/runtime.exs +++ b/flavours/classic/config/runtime.exs @@ -12,17 +12,17 @@ public_port = String.to_integer(System.get_env("PUBLIC_PORT", "4000")) Bonfire.Common.Config.LoadExtensionsConfig.load_configs() ## -System.get_env("DATABASE_URL") || System.get_env("POSTGRES_PASSWORD") || System.get_env("CI") || - raise """ - Environment variables for database are missing. - For example: DATABASE_URL=ecto://USER:PASS@HOST/DATABASE - You can also set POSTGRES_PASSWORD (required), - and POSTGRES_USER (default: postgres) and POSTGRES_HOST (default: localhost) - """ +System.get_env("DATABASE_URL") || System.get_env("POSTGRES_PASSWORD") || + System.get_env("CI") || + raise """ + Environment variables for database are missing. + For example: DATABASE_URL=ecto://USER:PASS@HOST/DATABASE + You can also set POSTGRES_PASSWORD (required), + and POSTGRES_USER (default: postgres) and POSTGRES_HOST (default: localhost) + """ if System.get_env("DATABASE_URL") do - config :bonfire, Bonfire.Common.Repo, - url: System.get_env("DATABASE_URL") + config :bonfire, Bonfire.Common.Repo, url: System.get_env("DATABASE_URL") else config :bonfire, Bonfire.Common.Repo, # ssl: true, @@ -38,12 +38,14 @@ secret_key_base = You can generate one by calling: mix phx.gen.secret """ -signing_salt = System.get_env("SIGNING_SALT") || System.get_env("CI") || +signing_salt = + System.get_env("SIGNING_SALT") || System.get_env("CI") || raise """ environment variable SIGNING_SALT is missing. """ -encryption_salt = System.get_env("ENCRYPTION_SALT") || System.get_env("CI") || +encryption_salt = + System.get_env("ENCRYPTION_SALT") || System.get_env("CI") || raise """ environment variable ENCRYPTION_SALT is missing. """ @@ -58,7 +60,10 @@ config :bonfire, signing_salt: signing_salt, root_path: File.cwd!() -start_server? = if config_env() == :test, do: System.get_env("START_SERVER", "true"), else: System.get_env("START_SERVER", "true") +start_server? = + if config_env() == :test, + do: System.get_env("START_SERVER", "true"), + else: System.get_env("START_SERVER", "true") config :bonfire, Bonfire.Web.Endpoint, server: String.to_existing_atom(start_server?), @@ -73,9 +78,7 @@ config :bonfire, Bonfire.Web.Endpoint, live_view: [signing_salt: signing_salt] if System.get_env("SENTRY_DSN") do - IO.puts( - "Note: errors will be reported to Sentry." - ) + IO.puts("Note: errors will be reported to Sentry.") config :sentry, dsn: System.get_env("SENTRY_DSN") @@ -87,22 +90,20 @@ end # start prod-only config if config_env() == :prod do - config :bonfire, Bonfire.Common.Repo, # ssl: true, database: System.get_env("POSTGRES_DB", "bonfire"), pool_size: String.to_integer(System.get_env("POOL_SIZE", "10")), - log: String.to_atom(System.get_env("DB_QUERIES_LOG_LEVEL", "false")) # Note: keep this disabled if using ecto_dev_logger or EctoSparkles.Log instead # - -end # prod only config + # Note: keep this disabled if using ecto_dev_logger or EctoSparkles.Log instead # + log: String.to_atom(System.get_env("DB_QUERIES_LOG_LEVEL", "false")) +end +# prod only config # start prod and dev only config if config_env() != :test do - config :bonfire, Bonfire.Common.Repo, slow_query_ms: String.to_integer(System.get_env("SLOW_QUERY_MS", "100")) - end ## bonfire_livebook @@ -110,6 +111,4 @@ if Code.ensure_loaded?(Livebook) do Livebook.config_runtime() end -IO.puts( - "Welcome to Bonfire!" -) +IO.puts("Welcome to Bonfire!") diff --git a/flavours/classic/config/test.exs b/flavours/classic/config/test.exs index 7cc0631391..cf0a70f505 100755 --- a/flavours/classic/config/test.exs +++ b/flavours/classic/config/test.exs @@ -5,8 +5,10 @@ import Config import_config "activity_pub_test.exs" config :bonfire, - default_pagination_limit: 10, # should match limit hardcoded in tests - thread_default_pagination_limit: 10, # should match limit hardcoded in tests + # should match limit hardcoded in tests + default_pagination_limit: 10, + # should match limit hardcoded in tests + thread_default_pagination_limit: 10, skip_all_boundary_checks: false config :bonfire, Bonfire.Mailer, adapter: Bamboo.TestAdapter @@ -40,8 +42,7 @@ config :bonfire, Bonfire.Common.Repo, timeout: 10_000, connect_timeout: 10_000 -config :bonfire, Bonfire.Web.Endpoint, - http: [port: 4001] +config :bonfire, Bonfire.Web.Endpoint, http: [port: 4001] config :bonfire, Oban, crontab: false, @@ -54,6 +55,7 @@ config :mix_test_interactive, clear: true config :paginator, ecto_repos: [Bonfire.Common.Repo] + config :paginator, Paginator.Repo, pool: Ecto.Adapters.SQL.Sandbox, username: System.get_env("POSTGRES_USER", "postgres"), @@ -65,15 +67,17 @@ config :exsync, src_monitor: false, extra_extensions: [".leex", ".js", ".css", ".sface"] - # for headless browser testing: config :bonfire, sql_sandbox: true + config :wallaby, otp_app: :bonfire, # base_url: Bonfire.Web.Endpoint.url(), max_wait_time: 6_000, screenshot_on_failure: true, chromedriver: [ - path: "assets/node_modules/chromedriver/bin/chromedriver", # point to your chromedriver path - headless: true # change to false if you want to see the browser in action + # point to your chromedriver path + path: "assets/node_modules/chromedriver/bin/chromedriver", + # change to false if you want to see the browser in action + headless: true ] diff --git a/flavours/classic/repo/migrations/20200523081010_citext.exs b/flavours/classic/repo/migrations/20200523081010_citext.exs index bad3ec5df0..8de33932f7 100644 --- a/flavours/classic/repo/migrations/20200523081010_citext.exs +++ b/flavours/classic/repo/migrations/20200523081010_citext.exs @@ -2,11 +2,10 @@ defmodule Bonfire.Repo.Migrations.HelloWorld do use Ecto.Migration def up do - execute "CREATE EXTENSION IF NOT EXISTS \"citext\"" + execute("CREATE EXTENSION IF NOT EXISTS \"citext\"") end def down do - execute "DROP EXTENSION IF EXISTS \"citext\"" + execute("DROP EXTENSION IF EXISTS \"citext\"") end - end diff --git a/flavours/classic/repo/migrations/20200523081012_init_pointers.exs b/flavours/classic/repo/migrations/20200523081012_init_pointers.exs index 7fa1ef977d..4d75827e8e 100755 --- a/flavours/classic/repo/migrations/20200523081012_init_pointers.exs +++ b/flavours/classic/repo/migrations/20200523081012_init_pointers.exs @@ -6,9 +6,9 @@ defmodule Bonfire.Repo.Migrations.InitPointers do init_pointers_ulid_extra() init_pointers() end + def down do init_pointers_ulid_extra() init_pointers() end - end diff --git a/flavours/classic/repo/migrations/20200523081014_init_edges.exs b/flavours/classic/repo/migrations/20200523081014_init_edges.exs index 523e0e8258..6a9051db55 100644 --- a/flavours/classic/repo/migrations/20200523081014_init_edges.exs +++ b/flavours/classic/repo/migrations/20200523081014_init_edges.exs @@ -2,7 +2,6 @@ defmodule Bonfire.Repo.Migrations.InitEdges do use Ecto.Migration alias Bonfire.Data.Edges.Migration - def up do Migration.up() end @@ -10,5 +9,4 @@ defmodule Bonfire.Repo.Migrations.InitEdges do def down do Migration.down() end - end diff --git a/flavours/classic/repo/migrations/20200818094943_import_ap.exs b/flavours/classic/repo/migrations/20200818094943_import_ap.exs index 38cea36742..bfdc4815e6 100755 --- a/flavours/classic/repo/migrations/20200818094943_import_ap.exs +++ b/flavours/classic/repo/migrations/20200818094943_import_ap.exs @@ -6,5 +6,4 @@ defmodule Bonfire.Federate.ActivityPub.Repo.Migrations.ImportMe do def up, do: migrate_activity_pub def down, do: migrate_activity_pub - end diff --git a/flavours/classic/repo/migrations/20200820094941_import_boundaries.exs b/flavours/classic/repo/migrations/20200820094941_import_boundaries.exs index 21ef29e5c9..51908b3a52 100755 --- a/flavours/classic/repo/migrations/20200820094941_import_boundaries.exs +++ b/flavours/classic/repo/migrations/20200820094941_import_boundaries.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.ImportBoundaries do def up, do: migrate_boundaries() def down, do: migrate_boundaries() - end diff --git a/flavours/classic/repo/migrations/20200828094944_import_me.exs b/flavours/classic/repo/migrations/20200828094944_import_me.exs index 5b9e9a8c3f..97ac819380 100755 --- a/flavours/classic/repo/migrations/20200828094944_import_me.exs +++ b/flavours/classic/repo/migrations/20200828094944_import_me.exs @@ -9,5 +9,4 @@ defmodule Bonfire.Repo.Migrations.ImportMe do end def down, do: migrate_me() - end diff --git a/flavours/classic/repo/migrations/20200828094945_import_social.exs b/flavours/classic/repo/migrations/20200828094945_import_social.exs index 3f8c6db408..2ee83ee871 100755 --- a/flavours/classic/repo/migrations/20200828094945_import_social.exs +++ b/flavours/classic/repo/migrations/20200828094945_import_social.exs @@ -5,10 +5,8 @@ defmodule Bonfire.Social.Repo.Migrations.ImportSocial do import Pointers.Migration def up do - migrate_social() - end - def down, do: migrate_social() + def down, do: migrate_social() end diff --git a/flavours/classic/repo/migrations/20200829004946_boundaries_fixtures.exs b/flavours/classic/repo/migrations/20200829004946_boundaries_fixtures.exs index 87fd61baf6..7a8eb123c7 100755 --- a/flavours/classic/repo/migrations/20200829004946_boundaries_fixtures.exs +++ b/flavours/classic/repo/migrations/20200829004946_boundaries_fixtures.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.BoundariesFixtures do def up, do: Bonfire.Boundaries.Fixtures.insert() def down, do: nil - end diff --git a/flavours/classic/repo/migrations/20201205094943_import_quantify.exs b/flavours/classic/repo/migrations/20201205094943_import_quantify.exs index 5c0bce0506..4a60dd1763 100644 --- a/flavours/classic/repo/migrations/20201205094943_import_quantify.exs +++ b/flavours/classic/repo/migrations/20201205094943_import_quantify.exs @@ -2,12 +2,12 @@ defmodule Bonfire.Repo.Migrations.ImportQuantify do use Ecto.Migration def up do - Bonfire.Quantify.Migrations.change - Bonfire.Quantify.Migrations.change_measure + Bonfire.Quantify.Migrations.change() + Bonfire.Quantify.Migrations.change_measure() end def down do - Bonfire.Quantify.Migrations.change - Bonfire.Quantify.Migrations.change_measure + Bonfire.Quantify.Migrations.change() + Bonfire.Quantify.Migrations.change_measure() end end diff --git a/flavours/classic/repo/migrations/20201208094940_import_geolocation.exs b/flavours/classic/repo/migrations/20201208094940_import_geolocation.exs index 479d9e680c..42178a098b 100644 --- a/flavours/classic/repo/migrations/20201208094940_import_geolocation.exs +++ b/flavours/classic/repo/migrations/20201208094940_import_geolocation.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportGeolocation do use Ecto.Migration def up do - Bonfire.Geolocate.Migrations.change + Bonfire.Geolocate.Migrations.change() end def down do - Bonfire.Geolocate.Migrations.change + Bonfire.Geolocate.Migrations.change() end end diff --git a/flavours/classic/repo/migrations/20210102094944_import_shared_user.exs b/flavours/classic/repo/migrations/20210102094944_import_shared_user.exs index 09845637a3..e55a68d7fa 100644 --- a/flavours/classic/repo/migrations/20210102094944_import_shared_user.exs +++ b/flavours/classic/repo/migrations/20210102094944_import_shared_user.exs @@ -6,5 +6,4 @@ defmodule Bonfire.Repo.Migrations.ImportSharedUser do def up, do: migrate_shared_user() def down, do: migrate_shared_user() - end diff --git a/flavours/classic/repo/migrations/20210402105128_ap_test_table.exs b/flavours/classic/repo/migrations/20210402105128_ap_test_table.exs index 929b6324f6..ecc4b56355 100755 --- a/flavours/classic/repo/migrations/20210402105128_ap_test_table.exs +++ b/flavours/classic/repo/migrations/20210402105128_ap_test_table.exs @@ -4,12 +4,12 @@ defmodule ActivityPub.Repo.Migrations.APTestTable do def change do # This table only exists for test purposes create table("local_actor", primary_key: false) do - add :id, :uuid, primary_key: true - add :username, :citext - add :data, :map - add :local, :boolean - add :keys, :text - add :followers, {:array, :string} + add(:id, :uuid, primary_key: true) + add(:username, :citext) + add(:data, :map) + add(:local, :boolean) + add(:keys, :text) + add(:followers, {:array, :string}) end end end diff --git a/flavours/classic/repo/migrations/20210410094945_profile_images.exs b/flavours/classic/repo/migrations/20210410094945_profile_images.exs index c0a07043eb..8294d2b957 100755 --- a/flavours/classic/repo/migrations/20210410094945_profile_images.exs +++ b/flavours/classic/repo/migrations/20210410094945_profile_images.exs @@ -4,15 +4,19 @@ defmodule Bonfire.Social.Repo.Migrations.ProfileImages do import Pointers.Migration def up do + drop_if_exists( + constraint("bonfire_data_social_profile", "bonfire_data_social_profile_icon_id_fkey") + ) - drop_if_exists constraint "bonfire_data_social_profile", "bonfire_data_social_profile_icon_id_fkey" - drop_if_exists constraint "bonfire_data_social_profile", "bonfire_data_social_profile_image_id_fkey" + drop_if_exists( + constraint("bonfire_data_social_profile", "bonfire_data_social_profile_image_id_fkey") + ) alter table("bonfire_data_social_profile") do - Ecto.Migration.add_if_not_exists :icon_id, strong_pointer(Bonfire.Files.Media) - Ecto.Migration.add_if_not_exists :image_id, strong_pointer(Bonfire.Files.Media) + Ecto.Migration.add_if_not_exists(:icon_id, strong_pointer(Bonfire.Files.Media)) + Ecto.Migration.add_if_not_exists(:image_id, strong_pointer(Bonfire.Files.Media)) end end - def down, do: nil + def down, do: nil end diff --git a/flavours/classic/repo/migrations/20210412094946_fp.exs b/flavours/classic/repo/migrations/20210412094946_fp.exs index 4e13f8b533..1966abd46a 100755 --- a/flavours/classic/repo/migrations/20210412094946_fp.exs +++ b/flavours/classic/repo/migrations/20210412094946_fp.exs @@ -1,7 +1,6 @@ defmodule Bonfire.Repo.Migrations.FP do use Ecto.Migration - def up do execute("create or replace function column_exists(ptable text, pcolumn text, pschema text default 'public') @@ -18,7 +17,8 @@ defmodule Bonfire.Repo.Migrations.FP do ); $body$;") - execute("CREATE OR REPLACE FUNCTION rename_column_if_exists(ptable TEXT, pcolumn TEXT, new_name TEXT) + execute( + "CREATE OR REPLACE FUNCTION rename_column_if_exists(ptable TEXT, pcolumn TEXT, new_name TEXT) RETURNS VOID AS $BODY$ BEGIN -- Rename the column if it exists. @@ -27,14 +27,15 @@ defmodule Bonfire.Repo.Migrations.FP do ptable, pcolumn, new_name); END IF; END$BODY$ - LANGUAGE plpgsql VOLATILE;") + LANGUAGE plpgsql VOLATILE;" + ) flush() - execute("SELECT rename_column_if_exists('bonfire_data_social_feed_publish', 'object_id', 'activity_id') ") - + execute( + "SELECT rename_column_if_exists('bonfire_data_social_feed_publish', 'object_id', 'activity_id') " + ) end def down, do: nil - end diff --git a/flavours/classic/repo/migrations/20210618094945_peered_uri.exs b/flavours/classic/repo/migrations/20210618094945_peered_uri.exs index ce0bb3c412..1aff450e95 100755 --- a/flavours/classic/repo/migrations/20210618094945_peered_uri.exs +++ b/flavours/classic/repo/migrations/20210618094945_peered_uri.exs @@ -5,9 +5,9 @@ defmodule Bonfire.Social.Repo.Migrations.PeeredURI do def up do alter table("bonfire_data_activity_pub_peered") do - Ecto.Migration.add_if_not_exists :canonical_uri, :text, null: true + Ecto.Migration.add_if_not_exists(:canonical_uri, :text, null: true) end end - def down, do: nil + def down, do: nil end diff --git a/flavours/classic/repo/migrations/20210925094942_import_classify.exs b/flavours/classic/repo/migrations/20210925094942_import_classify.exs index 2f83f7b214..d8c04f13ec 100644 --- a/flavours/classic/repo/migrations/20210925094942_import_classify.exs +++ b/flavours/classic/repo/migrations/20210925094942_import_classify.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportClassify do use Ecto.Migration def up do - Bonfire.Classify.Migrations.up + Bonfire.Classify.Migrations.up() end def down do - Bonfire.Classify.Migrations.down + Bonfire.Classify.Migrations.down() end end diff --git a/flavours/classic/repo/migrations/20220208094942_import_invite_link.exs b/flavours/classic/repo/migrations/20220208094942_import_invite_link.exs index aead406a7e..4fa8d4f44c 100644 --- a/flavours/classic/repo/migrations/20220208094942_import_invite_link.exs +++ b/flavours/classic/repo/migrations/20220208094942_import_invite_link.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportInviteLink do use Ecto.Migration def up do - Bonfire.Invites.Link.Migration.up + Bonfire.Invites.Link.Migration.up() end def down do - Bonfire.Invites.Link.Migration.down + Bonfire.Invites.Link.Migration.down() end end diff --git a/flavours/classic/repo/migrations/20220304081300_care_closure.exs b/flavours/classic/repo/migrations/20220304081300_care_closure.exs index 30a0dbc621..2e41085d5c 100644 --- a/flavours/classic/repo/migrations/20220304081300_care_closure.exs +++ b/flavours/classic/repo/migrations/20220304081300_care_closure.exs @@ -4,5 +4,4 @@ defmodule Bonfire.Data.Identity.Repo.Migrations.CareClosure do alias Bonfire.Data.Identity.CareClosure.Migration def change, do: Migration.migrate_care_closure_view() - end diff --git a/flavours/classic/repo/migrations/20220428094200_add_files_mixin.exs b/flavours/classic/repo/migrations/20220428094200_add_files_mixin.exs index 0fd23546a9..ae2f93b48f 100644 --- a/flavours/classic/repo/migrations/20220428094200_add_files_mixin.exs +++ b/flavours/classic/repo/migrations/20220428094200_add_files_mixin.exs @@ -5,9 +5,10 @@ defmodule Bonfire.Repo.Migrations.AddFilesMixin do 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 + # cleanup old stuff + alter table("bonfire_files_media") do + remove_if_exists(:created_at, :utc_datetime_usec) + remove_if_exists(:updated_at, :utc_datetime_usec) end Bonfire.Files.Migrations.migrate_files() diff --git a/flavours/classic/repo/migrations/20220802004946_boundaries_fixtures_up.exs b/flavours/classic/repo/migrations/20220802004946_boundaries_fixtures_up.exs index 43389fb8bd..d17ec2e328 100644 --- a/flavours/classic/repo/migrations/20220802004946_boundaries_fixtures_up.exs +++ b/flavours/classic/repo/migrations/20220802004946_boundaries_fixtures_up.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.BoundariesFixturesUp do def up, do: Bonfire.Boundaries.Fixtures.insert() def down, do: nil - end diff --git a/flavours/classic/repo/seeds.exs b/flavours/classic/repo/seeds.exs index 67d18df649..f42870c1e7 100755 --- a/flavours/classic/repo/seeds.exs +++ b/flavours/classic/repo/seeds.exs @@ -8,11 +8,13 @@ System.put_env("SEARCH_INDEXING_DISABLED", "true") # if the user has configured an admin user for the seeds, insert it. case {System.get_env("ADMIN_USER", "root"), System.get_env("ADMIN_PASSWORD", "")} do - {u,p} when p != "" -> + {u, p} when p != "" -> fake_account!(%{credential: %{password: p}}) |> fake_user!(%{character: %{username: u}, profile: %{name: u}}) |> Bonfire.Me.Users.make_admin() - _ -> nil + + _ -> + nil end # create some users @@ -20,7 +22,7 @@ users = for _ <- 1..3, do: fake_user!() random_user = fn -> Faker.Util.pick(users) end # start fake threads -#for _ <- 1..3 do +# for _ <- 1..3 do # user = random_user.() # thread = fake_thread!(user) # comment = fake_comment!(user, thread) @@ -28,15 +30,14 @@ random_user = fn -> Faker.Util.pick(users) end # reply = fake_comment!(random_user.(), thread, %{in_reply_to_id: comment.id}) # subreply = fake_comment!(random_user.(), thread, %{in_reply_to_id: reply.id}) # subreply2 = fake_comment!(random_user.(), thread, %{in_reply_to_id: subreply.id}) -#end +# end # ## more fake threads -#for _ <- 1..2 do +# for _ <- 1..2 do # user = random_user.() # thread = fake_thread!(user) # comment = fake_comment!(user, thread) -#end - +# end # define some tags/categories if(Bonfire.Common.Extend.extension_enabled?(Bonfire.Classify.Simulate)) do @@ -82,18 +83,22 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do # some proposed intents action_id = ValueFlows.Simulate.action_id() - intent = ValueFlows.Simulate.fake_intent!(user, %{resource_conforms_to: res_spec, action_id: action_id}) + + intent = + ValueFlows.Simulate.fake_intent!(user, %{ + resource_conforms_to: res_spec, + action_id: action_id + }) + proposal = ValueFlows.Simulate.fake_proposal!(user) ValueFlows.Simulate.fake_proposed_to!(random_user.(), proposal) ValueFlows.Simulate.fake_proposed_intent!(proposal, intent) # define some geolocations if(Bonfire.Common.Extend.extension_enabled?(Bonfire.Geolocate.Simulate)) do - places = for _ <- 1..2, do: Bonfire.Geolocate.Simulate.fake_geolocation!(random_user.()) random_place = fn -> Faker.Util.pick(places) end - for _ <- 1..2 do # define some intents with geolocation _intent = @@ -103,7 +108,8 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do ) # define some proposals with geolocation - _proposal = ValueFlows.Simulate.fake_proposal!(user, %{eligible_location: random_place.()}) + _proposal = + ValueFlows.Simulate.fake_proposal!(user, %{eligible_location: random_place.()}) # both with geo intent = @@ -118,8 +124,13 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do # some economic events user = random_user.() - resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(user, %{current_location: random_place.()}) - to_resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{current_location: random_place.()}) + resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(user, %{current_location: random_place.()}) + + to_resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{ + current_location: random_place.() + }) ValueFlows.Simulate.fake_economic_event!( user, @@ -155,7 +166,9 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do unit = Faker.Util.pick([unit1, unit2]) resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(user, %{}, unit) - to_resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{}, unit) + + to_resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{}, unit) ValueFlows.Simulate.fake_economic_event!( user, diff --git a/flavours/cooperation/config/activity_pub.exs b/flavours/cooperation/config/activity_pub.exs index db8451ad7e..d24d4ca12f 100644 --- a/flavours/cooperation/config/activity_pub.exs +++ b/flavours/cooperation/config/activity_pub.exs @@ -37,7 +37,7 @@ config :activity_pub, ActivityPubWeb.Endpoint, render_errors: [view: ActivityPubWeb.ErrorView, accepts: ~w(json), layout: false] config :activity_pub, :json_contexts, %{ - "Hashtag"=> "as:Hashtag", - "ValueFlows" => "https://w3id.org/valueflows#", - "om2" => "http://www.ontology-of-units-of-measure.org/resource/om-2/" - } + "Hashtag" => "as:Hashtag", + "ValueFlows" => "https://w3id.org/valueflows#", + "om2" => "http://www.ontology-of-units-of-measure.org/resource/om-2/" +} diff --git a/flavours/cooperation/config/activity_pub_test.exs b/flavours/cooperation/config/activity_pub_test.exs index 323eacd6fd..ac343b578e 100644 --- a/flavours/cooperation/config/activity_pub_test.exs +++ b/flavours/cooperation/config/activity_pub_test.exs @@ -12,9 +12,8 @@ config :activity_pub, Oban, repo: Bonfire.Common.Repo, queues: false -config :activity_pub, :instance, - federating: false - # rewrite_policy: [ActivityPub.MRF.SimplePolicy] +config :activity_pub, :instance, federating: false +# rewrite_policy: [ActivityPub.MRF.SimplePolicy] config :tesla, adapter: Tesla.Mock diff --git a/flavours/cooperation/config/bonfire_common.exs b/flavours/cooperation/config/bonfire_common.exs index 1ef9919410..b87cb17a92 100644 --- a/flavours/cooperation/config/bonfire_common.exs +++ b/flavours/cooperation/config/bonfire_common.exs @@ -8,7 +8,8 @@ config :bonfire_common, # internationalisation config :bonfire_common, Bonfire.Common.Localise.Cldr, default_locale: default_locale, - locales: ["fr", "en", "es"], # locales that will be made available on top of those for which gettext localisation files are available + # locales that will be made available on top of those for which gettext localisation files are available + locales: ["fr", "en", "es"], providers: [Cldr.Language], gettext: Bonfire.Common.Localise.Gettext, data_dir: "./priv/cldr", diff --git a/flavours/cooperation/config/bonfire_data.exs b/flavours/cooperation/config/bonfire_data.exs index 964bb8121d..d84fb8b6ca 100644 --- a/flavours/cooperation/config/bonfire_data.exs +++ b/flavours/cooperation/config/bonfire_data.exs @@ -2,65 +2,85 @@ import Config #### Base configuration -verbs = ["Boost", "Create", "Delete", "Edit", "Flag", "Follow", "Like", "Mention", - "Message", "Read", "Reply", "Request", "See", "Tag"] +verbs = [ + "Boost", + "Create", + "Delete", + "Edit", + "Flag", + "Follow", + "Like", + "Mention", + "Message", + "Read", + "Reply", + "Request", + "See", + "Tag" +] # 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 +config :bonfire_data_identity, Bonfire.Data.Identity.Credential, hasher_module: hasher #### Sentinel Data Services # Search these apps/extensions for Pointable ecto schema definitions to index pointable_schema_extensions = [ - :bonfire, - :bonfire_data_access_control, - :bonfire_data_activity_pub, - :bonfire_data_identity, - :bonfire_data_social, - :bonfire_data_edges, - :bonfire_tag, - :bonfire_classify, - :bonfire_data_shared_users, - :bonfire_files, - :bonfire_quantify, - :bonfire_geolocate, - :bonfire_valueflows, - :bonfire_valueflows_observe, - ] + :bonfire, + :bonfire_data_access_control, + :bonfire_data_activity_pub, + :bonfire_data_identity, + :bonfire_data_social, + :bonfire_data_edges, + :bonfire_tag, + :bonfire_classify, + :bonfire_data_shared_users, + :bonfire_files, + :bonfire_quantify, + :bonfire_geolocate, + :bonfire_valueflows, + :bonfire_valueflows_observe +] + 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, - ] +context_and_queries_extensions = + pointable_schema_extensions ++ + [ + :bonfire_common, + :bonfire_me, + :bonfire_social + ] -extensions_with_config = context_and_queries_extensions ++ [ - :bonfire_boundaries, - :bonfire_federate_activitypub, - :bonfire_search, - :bonfire_mailer, - :bonfire_geolocate - ] +extensions_with_config = + context_and_queries_extensions ++ + [ + :bonfire_boundaries, + :bonfire_federate_activitypub, + :bonfire_search, + :bonfire_mailer, + :bonfire_geolocate + ] -extensions_with_ui = extensions_with_config ++ [ - :bonfire_ui_common, - :bonfire_ui_me, - :bonfire_ui_social, - :bonfire_ui_valueflows, - :bonfire_ui_coordination, - :bonfire_ui_breadpub, - :bonfire_ui_kanban, - :bonfire_breadpub, - :bonfire_upcycle, - :bonfire_recyclapp, - :bonfire_ui_reflow - ] +extensions_with_ui = + extensions_with_config ++ + [ + :bonfire_ui_common, + :bonfire_ui_me, + :bonfire_ui_social, + :bonfire_ui_valueflows, + :bonfire_ui_coordination, + :bonfire_ui_breadpub, + :bonfire_ui_kanban, + :bonfire_breadpub, + :bonfire_upcycle, + :bonfire_recyclapp, + :bonfire_ui_reflow + ] config :bonfire, :verb_names, verbs config :bonfire, :context_modules_search_path, context_and_queries_extensions @@ -72,31 +92,74 @@ config :bonfire, :ui_modules_search_path, extensions_with_ui config :bonfire_data_access_control, search_path: [ # :bonfire_me, - :bonfire_boundaries, + :bonfire_boundaries + # :bonfire_social, # :bonfire, ] #### Alias modules for readability -alias Pointers.{Pointer, Table} -alias Bonfire.Data.AccessControl.{ - Acl, Circle, Encircle, Controlled, InstanceAdmin, Grant, Verb, -} -alias Bonfire.Data.ActivityPub.{Actor, Peer, Peered} -alias Bonfire.Boundaries.{Permitted, Stereotyped} -alias Bonfire.Data.Edges.{Edge,EdgeTotal} -alias Bonfire.Data.Identity.{ - Account, Accounted, AuthSecondFactor, Caretaker, CareClosure, Character, Credential, Email, ExtraInfo, Named, Self, Settings, User, -} -alias Bonfire.Data.Social.{ - Activity, APActivity, Article, Block, Bookmark, Boost, Created, Feed, FeedPublish, - Flag, Follow, Like, Mention, Message, Post, PostContent, Profile, Replied, Request, -} +alias Pointers.Pointer +alias Pointers.Table + +alias Bonfire.Data.AccessControl.Acl +alias Bonfire.Data.AccessControl.Circle +alias Bonfire.Data.AccessControl.Encircle +alias Bonfire.Data.AccessControl.Controlled +alias Bonfire.Data.AccessControl.InstanceAdmin +alias Bonfire.Data.AccessControl.Grant +alias Bonfire.Data.AccessControl.Verb + +alias Bonfire.Data.ActivityPub.Actor +alias Bonfire.Data.ActivityPub.Peer +alias Bonfire.Data.ActivityPub.Peered + +alias Bonfire.Boundaries.Permitted +alias Bonfire.Boundaries.Stereotyped + +alias Bonfire.Data.Edges.Edge +alias Bonfire.Data.Edges.EdgeTotal + +alias Bonfire.Data.Identity.Account +alias Bonfire.Data.Identity.Accounted +alias Bonfire.Data.Identity.AuthSecondFactor +alias Bonfire.Data.Identity.Caretaker +alias Bonfire.Data.Identity.CareClosure +alias Bonfire.Data.Identity.Character +alias Bonfire.Data.Identity.Credential +alias Bonfire.Data.Identity.Email +alias Bonfire.Data.Identity.ExtraInfo +alias Bonfire.Data.Identity.Named +alias Bonfire.Data.Identity.Self +alias Bonfire.Data.Identity.Settings +alias Bonfire.Data.Identity.User + +alias Bonfire.Data.Social.Activity +alias Bonfire.Data.Social.APActivity +alias Bonfire.Data.Social.Article +alias Bonfire.Data.Social.Block +alias Bonfire.Data.Social.Bookmark +alias Bonfire.Data.Social.Boost +alias Bonfire.Data.Social.Created +alias Bonfire.Data.Social.Feed +alias Bonfire.Data.Social.FeedPublish +alias Bonfire.Data.Social.Flag +alias Bonfire.Data.Social.Follow +alias Bonfire.Data.Social.Like +alias Bonfire.Data.Social.Mention +alias Bonfire.Data.Social.Message +alias Bonfire.Data.Social.Post +alias Bonfire.Data.Social.PostContent +alias Bonfire.Data.Social.Profile +alias Bonfire.Data.Social.Replied +alias Bonfire.Data.Social.Request + alias Bonfire.Classify.Category alias Bonfire.Geolocate.Geolocation alias Bonfire.Files alias Bonfire.Files.Media -alias Bonfire.{Tag, Tag.Tagged} +alias Bonfire.Tag +alias Bonfire.Tag.Tagged #### Flexto Stitching @@ -112,177 +175,234 @@ common_assocs = %{ ### Mixins # A summary of an object that can appear in a feed. - activity: quote(do: has_one(:activity, unquote(Activity), unquote(mixin))), + activity: quote(do: has_one(:activity, unquote(Activity), unquote(mixin))), # ActivityPub actor information - actor: quote(do: has_one(:actor, unquote(Actor), unquote(mixin))), + actor: quote(do: has_one(:actor, unquote(Actor), unquote(mixin))), # Indicates the entity responsible for an activity. Sort of like creator, but transferrable. Used # during deletion - when the caretaker is deleted, all their stuff will be too. - caretaker: quote(do: has_one(:caretaker, unquote(Caretaker), unquote(mixin))), + caretaker: quote(do: has_one(:caretaker, unquote(Caretaker), unquote(mixin))), # A Character has a unique username and some feeds. - character: quote(do: has_one(:character, unquote(Character), unquote(mixin))), + character: quote(do: has_one(:character, unquote(Character), unquote(mixin))), # Indicates the creator of an object - created: quote(do: has_one(:created, unquote(Created), unquote(mixin))), + created: quote(do: has_one(:created, unquote(Created), unquote(mixin))), # Used for non-textual interactions such as likes and follows to indicate the other object. - edge: quote(do: has_one(:edge, unquote(Edge), unquote(mixin))), + edge: quote(do: has_one(:edge, unquote(Edge), unquote(mixin))), # Adds a name that can appear in the user interface for an object. e.g. for an ACL. - named: quote(do: has_one(:named, unquote(Named), unquote(mixin))), + named: quote(do: has_one(:named, unquote(Named), unquote(mixin))), # Adds extra info that can appear in the user interface for an object. e.g. a summary or JSON-encoded data. - extra_info: quote(do: has_one(:extra_info, unquote(ExtraInfo), unquote(mixin))), + extra_info: quote(do: has_one(:extra_info, unquote(ExtraInfo), unquote(mixin))), # Information about the remote instance the object is from, if it is not local. - peered: quote(do: has_one(:peered, unquote(Peered), unquote(mixin))), + peered: quote(do: has_one(:peered, unquote(Peered), unquote(mixin))), # Information about the content of posts, e.g. a scrubbed html body post_content: quote(do: has_one(:post_content, unquote(PostContent), unquote(mixin))), # Information about a user or other object that they wish to make available - profile: quote(do: has_one(:profile, unquote(Profile), unquote(mixin))), + profile: quote(do: has_one(:profile, unquote(Profile), unquote(mixin))), # Threading information, for threaded discussions. - replied: quote(do: has_one(:replied, unquote(Replied), unquote(mixin))), + replied: quote(do: has_one(:replied, unquote(Replied), unquote(mixin))), # Information that allows the system to identify special system-managed ACLS. - stereotyped: quote(do: has_one(:stereotyped, unquote(Stereotyped), unquote(mixin))), - + stereotyped: quote(do: has_one(:stereotyped, unquote(Stereotyped), unquote(mixin))), ### Multimixins # Links to access control information for this object. - controlled: quote(do: has_many(:controlled, unquote(Controlled), unquote(mixin))), + 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))), + 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)), + 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))), + 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)), - + 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 # The objects which reply to this object. - direct_replies: quote(do: has_many(:direct_replies, unquote(Replied), foreign_key: :reply_to_id)), + direct_replies: + quote(do: has_many(:direct_replies, unquote(Replied), foreign_key: :reply_to_id)), # A recursive view of caretakers of caretakers of... used during deletion. - care_closure: quote(do: has_many(:care_closure, unquote(CareClosure), foreign_key: :branch_id)), + care_closure: quote(do: has_many(:care_closure, unquote(CareClosure), foreign_key: :branch_id)), # Retrieves activities where we are the object. e.g. if we are a # post or a user, this could turn up activities from likes or follows. - activities: quote(do: has_many(:activities, unquote(Activity), foreign_key: :object_id, references: :id)), + activities: + quote(do: has_many(:activities, unquote(Activity), foreign_key: :object_id, references: :id)), ### Stuff I'm not sure how to categorise yet # Used currently only for requesting to follow a user, but more general - request: quote(do: has_one(:request, unquote(Request), unquote(mixin))), + request: quote(do: has_one(:request, unquote(Request), unquote(mixin))) } # retrieves a list of quoted forms suitable for use with unquote_splicing common = fn names -> for name <- List.wrap(names) do with nil <- common_assocs[name], - do: raise(RuntimeError, message: "Expected a common association name, got #{inspect(name)}") + do: + raise(RuntimeError, message: "Expected a common association name, got #{inspect(name)}") end end -edge = common.([:controlled, :activities, :request, :created]) -edges = common.([:controlled, :activities, :request, :created, :caretaker, :activity, :feed_publishes]) +edge = common.([:controlled, :activities, :request, :created]) + +edges = + common.([:controlled, :activities, :request, :created, :caretaker, :activity, :feed_publishes]) # first up, pointers could have all the mixins we're using. TODO -pointer_mixins = common.([ - :activity, :actor, :caretaker, :character, :created, :edge, - :named, :extra_info, :peered, :post_content, :profile, :replied, :stereotyped -]) +pointer_mixins = + common.([ + :activity, + :actor, + :caretaker, + :character, + :created, + :edge, + :named, + :extra_info, + :peered, + :post_content, + :profile, + :replied, + :stereotyped + ]) + config :pointers, Pointer, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - field :dummy, :any, virtual: true - # pointables - has_one :circle, unquote(Circle), foreign_key: :id - many_to_many :encircle_subjects, Pointer, join_through: Encircle, join_keys: [circle_id: :id, subject_id: :id] - has_one :permitted, unquote(Permitted), foreign_key: :object_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 - has_one :category, unquote(Category), foreign_key: :id - has_one :geolocation, unquote(Geolocation), foreign_key: :id - # mixins - unquote_splicing(pointer_mixins) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media])) - # has_many - unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes])) + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + field(:dummy, :any, virtual: true) + # pointables + has_one(:circle, unquote(Circle), foreign_key: :id) - ## special things - # these should go away in future and they should be populated by a single query. - 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] + many_to_many(:encircle_subjects, Pointer, + join_through: Encircle, + join_keys: [circle_id: :id, subject_id: :id] + ) - end] + has_one(:permitted, unquote(Permitted), foreign_key: :object_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) + has_one(:category, unquote(Category), foreign_key: :id) + has_one(:geolocation, unquote(Geolocation), foreign_key: :id) + # mixins + unquote_splicing(pointer_mixins) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media])) + # has_many + unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes])) + + ## special things + # these should go away in future and they should be populated by a single query. + 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] + ) + end) config :pointers, Table, [] # now let's weave everything else together for convenience - # bonfire_data_access_control config :bonfire_data_access_control, Acl, - [code: quote do - field :grants_count, :integer, virtual: true - field :controlled_count, :integer, virtual: true - # mixins - unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) - # multimixins - # unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:grants_count, :integer, virtual: true) + field(:controlled_count, :integer, virtual: true) + # mixins + unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) + + # multimixins + # unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Circle, - [code: quote do - field :encircles_count, :integer, virtual: true - # mixins - unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) - # multimixins - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:encircles_count, :integer, virtual: true) + # mixins + unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) + # multimixins + unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Controlled, [] config :bonfire_data_access_control, Encircle, - [code: quote do - has_one :peer, unquote(Peer), foreign_key: :id, references: :subject_id - end] + code: + (quote do + has_one(:peer, unquote(Peer), foreign_key: :id, references: :subject_id) + end) config :bonfire_data_access_control, Grant, - [code: quote do - # mixins - unquote_splicing(common.([:caretaker])) - # multimixins - # unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:caretaker]))) + + # multimixins + # unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Verb, [] config :bonfire_boundaries, Stereotyped, - [code: quote do - has_one(:named, unquote(Named), [foreign_key: :id, references: :stereotype_id]) - end] + code: + (quote do + has_one(:named, unquote(Named), foreign_key: :id, references: :stereotype_id) + end) # bonfire_data_activity_pub config :bonfire_data_activity_pub, Actor, - [code: quote do - # hacks - belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - # mixins - unquote_splicing(common.([:peered])) - # multimixins - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # hacks + belongs_to(:character, unquote(Character), foreign_key: :id, define_field: false) + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + # mixins + unquote_splicing(common.([:peered])) + # multimixins + unquote_splicing(common.([:controlled])) + end) config :bonfire_data_activity_pub, Peer, [] config :bonfire_data_activity_pub, Peered, [] @@ -290,86 +410,128 @@ config :bonfire_data_activity_pub, Peered, [] # bonfire_data_identity config :bonfire_data_identity, Account, - [code: quote do - has_one :credential, unquote(Credential),foreign_key: :id - has_one :email, unquote(Email), foreign_key: :id - has_one :auth_second_factor, unquote(AuthSecondFactor), foreign_key: :id - has_one :settings, unquote(Settings), foreign_key: :id - many_to_many :users, unquote(User), - join_through: Accounted, - join_keys: [account_id: :id, id: :id] - many_to_many :shared_users, unquote(User), # optional - join_through: "bonfire_data_shared_user_accounts", - join_keys: [account_id: :id, shared_user_id: :id] - end] + code: + (quote do + has_one(:credential, unquote(Credential), foreign_key: :id) + has_one(:email, unquote(Email), foreign_key: :id) + has_one(:auth_second_factor, unquote(AuthSecondFactor), foreign_key: :id) + has_one(:settings, unquote(Settings), foreign_key: :id) + + many_to_many(:users, unquote(User), + join_through: Accounted, + join_keys: [account_id: :id, id: :id] + ) + + # optional + many_to_many(:shared_users, unquote(User), + join_through: "bonfire_data_shared_user_accounts", + join_keys: [account_id: :id, shared_user_id: :id] + ) + end) config :bonfire_data_identity, Accounted, - [code: quote do - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Caretaker, - [code: quote do - has_one :user, unquote(User), foreign_key: :id, references: :caretaker_id - # mixins - unquote_splicing(common.([:character, :profile])) - end] + code: + (quote do + has_one(:user, unquote(User), foreign_key: :id, references: :caretaker_id) + # mixins + unquote_splicing(common.([:character, :profile])) + end) config :bonfire_data_identity, Character, - [code: quote do - @follow_ulid "70110WTHE1EADER1EADER1EADE" - # mixins - unquote_splicing(common.([:actor, :peered, :profile])) - has_one :user, unquote(User), unquote(mixin) - has_one :feed, unquote(Feed), unquote(mixin) - has_many :followers, unquote(Follow), foreign_key: :following_id, references: :id - has_many :followed, unquote(Follow), foreign_key: :follower_id, references: :id - has_one :follow_count, unquote(EdgeTotal), foreign_key: :id, references: :id, - where: [table_id: @follow_ulid] - end] + code: + (quote do + @follow_ulid "70110WTHE1EADER1EADER1EADE" + # mixins + unquote_splicing(common.([:actor, :peered, :profile])) + has_one(:user, unquote(User), unquote(mixin)) + has_one(:feed, unquote(Feed), unquote(mixin)) + has_many(:followers, unquote(Follow), foreign_key: :following_id, references: :id) + has_many(:followed, unquote(Follow), foreign_key: :follower_id, references: :id) + + has_one(:follow_count, unquote(EdgeTotal), + foreign_key: :id, + references: :id, + where: [table_id: @follow_ulid] + ) + end) config :bonfire_data_identity, Credential, - [code: quote do - belongs_to :account, unquote(Account), foreign_key: :id, define_field: false - end] + code: + (quote do + belongs_to(:account, unquote(Account), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Email, - [must_confirm: true, - code: quote do - belongs_to :account, unquote(Account), foreign_key: :id, define_field: false - end] + must_confirm: true, + code: + (quote do + belongs_to(:account, unquote(Account), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Self, [] config :bonfire_data_identity, User, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - # mixins - has_one :accounted, unquote(Accounted), foreign_key: :id - has_one :instance_admin, unquote(InstanceAdmin), foreign_key: :id, on_replace: :update - has_one :self, unquote(Self), foreign_key: :id - has_one :shared_user, unquote(Bonfire.Data.SharedUser), foreign_key: :id - has_one :settings, unquote(Settings), foreign_key: :id - unquote_splicing(common.([:actor, :character, :created, :peered, :profile])) - # multimixins - unquote_splicing(common.([:controlled])) - # manies - has_many :encircles, unquote(Encircle), foreign_key: :subject_id - has_many :creations, through: [:created, :pointer] # todo: stop through - has_many :posts, through: [:created, :post] # todo: stop through - has_many :followers, unquote(Edge), foreign_key: :object_id, references: :id, where: [table_id: @follow_ulid] - has_many :followed, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @follow_ulid] - has_many :user_activities, unquote(Activity), foreign_key: :subject_id, references: :id - has_many :boost_activities, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @boost_ulid] - has_many :like_activities, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @like_ulid] - many_to_many :caretaker_accounts, unquote(Account), - 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 # enable if using Geolocate extension - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + # mixins + has_one(:accounted, unquote(Accounted), foreign_key: :id) + has_one(:instance_admin, unquote(InstanceAdmin), foreign_key: :id, on_replace: :update) + has_one(:self, unquote(Self), foreign_key: :id) + has_one(:shared_user, unquote(Bonfire.Data.SharedUser), foreign_key: :id) + has_one(:settings, unquote(Settings), foreign_key: :id) + unquote_splicing(common.([:actor, :character, :created, :peered, :profile])) + # multimixins + unquote_splicing(common.([:controlled])) + # manies + has_many(:encircles, unquote(Encircle), foreign_key: :subject_id) + # todo: stop through + has_many(:creations, through: [:created, :pointer]) + # todo: stop through + has_many(:posts, through: [:created, :post]) + + has_many(:followers, unquote(Edge), + foreign_key: :object_id, + references: :id, + where: [table_id: @follow_ulid] + ) + + has_many(:followed, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @follow_ulid] + ) + + has_many(:user_activities, unquote(Activity), foreign_key: :subject_id, references: :id) + + has_many(:boost_activities, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @boost_ulid] + ) + + has_many(:like_activities, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @like_ulid] + ) + + many_to_many(:caretaker_accounts, unquote(Account), + 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 # enable if using Geolocate extension + end) config :bonfire_data_identity, Named, [] config :bonfire_data_identity, ExtraInfo, [] @@ -377,336 +539,448 @@ config :bonfire_data_identity, ExtraInfo, [] ### bonfire_data_social config :bonfire_data_social, Activity, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - has_many :feed_publishes, unquote(FeedPublish), unquote(mixin) - has_one :seen, unquote(Edge), foreign_key: :object_id, references: :id - # ugly workaround needed for certain queries (TODO: check if still needed) - has_one :activity, unquote(Activity), foreign_key: :id, references: :id - # 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] - has_many :controlled, unquote(Controlled), foreign_key: :id, references: :object_id - has_many :tagged, unquote(Tagged), foreign_key: :id, references: :object_id - many_to_many :tags, unquote(Pointer), - join_through: unquote(Tagged), - 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] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + has_many(:feed_publishes, unquote(FeedPublish), unquote(mixin)) + has_one(:seen, unquote(Edge), foreign_key: :object_id, references: :id) + # ugly workaround needed for certain queries (TODO: check if still needed) + has_one(:activity, unquote(Activity), foreign_key: :id, references: :id) + # 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] + ) + + has_many(:controlled, unquote(Controlled), foreign_key: :id, references: :object_id) + has_many(:tagged, unquote(Tagged), foreign_key: :id, references: :object_id) + + many_to_many(:tags, unquote(Pointer), + join_through: unquote(Tagged), + 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, - [code: quote do - unquote_splicing(common.([:activity, :caretaker, :controlled])) - end] + code: + (quote do + (unquote_splicing(common.([:activity, :caretaker, :controlled]))) + end) config :bonfire_data_edges, Edge, - [code: quote do - unquote_splicing(edge) - # TODO: requires composite foreign keys: - # has_one :activity, unquote(Activity), - # foreign_key: [:table_id, :object_id], references: [:table_id, :object_id] - end] + code: + (quote do + (unquote_splicing(edge)) + + # TODO: requires composite foreign keys: + # has_one :activity, unquote(Activity), + # foreign_key: [:table_id, :object_id], references: [:table_id, :object_id] + end) config :bonfire_data_social, Feed, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker])) - # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - # belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:activity, :caretaker]))) + + # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false + # belongs_to :user, unquote(User), foreign_key: :id, define_field: false + end) config :bonfire_data_social, FeedPublish, - [code: quote do - field :dummy, :any, virtual: true - has_one :activity, unquote(Activity), foreign_key: :object_id, references: :id - # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - # belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + field(:dummy, :any, virtual: true) + has_one(:activity, unquote(Activity), foreign_key: :object_id, references: :id) + # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false + # belongs_to :user, unquote(User), foreign_key: :id, define_field: false + end) config :bonfire_data_social, Follow, - [code: quote do - unquote_splicing(edges) - end] - # 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}] + code: + (quote do + (unquote_splicing(edges)) + end) + +# 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}] config :bonfire_data_social, Block, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Boost, - [code: quote do - unquote_splicing(edges) - end] - # has_one: [activity: {Activity, foreign_key: :object_id, references: :boosted_id}] # requires an ON clause + code: + (quote do + (unquote_splicing(edges)) + end) + +# has_one: [activity: {Activity, foreign_key: :object_id, references: :boosted_id}] # requires an ON clause config :bonfire_data_social, Like, - [code: quote do - unquote_splicing(edges) - end] - # has_one: [activity: {Activity, foreign_key: :object_id, references: :liked_id}] # requires an ON clause + code: + (quote do + (unquote_splicing(edges)) + end) + +# has_one: [activity: {Activity, foreign_key: :object_id, references: :liked_id}] # requires an ON clause config :bonfire_data_social, Flag, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Request, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Bookmark, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Message, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - # mixins - unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied])) - # multimixins - 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] - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + # mixins + unquote_splicing( + common.([:activity, :caretaker, :created, :peered, :post_content, :replied]) + ) + + # multimixins + 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] + ) + end) config :bonfire_data_social, Mention, [] config :bonfire_data_social, Post, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - # mixins - unquote_splicing(common.([:activities, :activity, :caretaker, :created, :peered, :post_content, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - # special - has_one :permitted, unquote(Permitted), foreign_key: :object_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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause - # 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 :like_count, unquote(EdgeTotal), - 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] - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + # mixins + unquote_splicing( + common.([:activities, :activity, :caretaker, :created, :peered, :post_content, :replied]) + ) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + # special + has_one(:permitted, unquote(Permitted), foreign_key: :object_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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause + # 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(:like_count, unquote(EdgeTotal), + 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] + ) + end) config :bonfire_data_social, PostContent, - [code: quote do - # mixins - unquote_splicing(common.([:created])) - # multimixins - unquote_splicing(common.([:controlled])) - # virtuals for changesets - field :hashtags, {:array, :any}, virtual: true - field :mentions, {:array, :any}, virtual: true - field :urls, {:array, :any}, virtual: true - end] + code: + (quote do + # mixins + unquote_splicing(common.([:created])) + # multimixins + unquote_splicing(common.([:controlled])) + # virtuals for changesets + field(:hashtags, {:array, :any}, virtual: true) + field(:mentions, {:array, :any}, virtual: true) + field(:urls, {:array, :any}, virtual: true) + end) config :bonfire_data_social, Replied, - [code: quote do - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) + code: + (quote do + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) - @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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id - 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 - 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] + @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_one(:activity, unquote(Activity), foreign_key: :object_id, references: :id) + # used in changesets + field(:replying_to, :map, virtual: true) + 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 + ) + + 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) 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 - # mixins - shouldn't be here really - unquote_splicing(common.([:peered])) - has_one :post, unquote(Post), unquote(mixin) # huh? - end] + 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 + ) + + # mixins - shouldn't be here really + unquote_splicing(common.([:peered])) + # huh? + has_one(:post, unquote(Post), unquote(mixin)) + end) config :bonfire_data_social, Profile, - [code: quote do - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) + end) ######### other extensions config :bonfire_files, Media, - [code: quote do - field :url, :string, virtual: true - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:url, :string, virtual: true) + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) + end) config :bonfire_tag, Tagged, - [code: quote do - # mixins - unquote_splicing(common.([:activity])) - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:activity]))) + end) config :bonfire_classify, Category, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :created, :actor, :peered, :profile, :character])) # TODO :caretaker - # multimixins - unquote_splicing(common.([:controlled, :feed_publishes])) + code: + (quote do + # mixins + # TODO :caretaker + unquote_splicing(common.([:activity, :created, :actor, :peered, :profile, :character])) + # multimixins + unquote_splicing(common.([:controlled, :feed_publishes])) - has_one(:creator, through: [:created, :creator]) + has_one(:creator, through: [:created, :creator]) - # add references of tagged objects to any Category - many_to_many :tags, unquote(Pointer), - join_through: unquote(Tagged), - unique: true, - join_keys: [tag_id: :id, id: :id], - on_replace: :delete - end] + # add references of tagged objects to any Category + many_to_many(:tags, unquote(Pointer), + join_through: unquote(Tagged), + unique: true, + join_keys: [tag_id: :id, id: :id], + 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] + 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, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + # TODO :caretaker + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.EconomicResource, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Knowledge.ResourceSpecification, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Process, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Knowledge.ProcessSpecification, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Planning.Intent, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Planning.Commitment, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Proposal, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows_observe, ValueFlows.Observe.Observation, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) diff --git a/flavours/cooperation/config/bonfire_fail.exs b/flavours/cooperation/config/bonfire_fail.exs index b4a66cb338..7a712ed231 100644 --- a/flavours/cooperation/config/bonfire_fail.exs +++ b/flavours/cooperation/config/bonfire_fail.exs @@ -11,9 +11,11 @@ config :bonfire_fail, bad_header: {400, "Bad request: malformed header."}, no_access: {403, "This site is by invitation only."}, token_expired: {403, "This link or token has expired, please request a fresh one."}, - already_claimed: {403, "This link or token was already used, please request a fresh one if necessary."}, + already_claimed: + {403, "This link or token was already used, please request a fresh one if necessary."}, token_not_found: {403, "This token was not found, please request a fresh one."}, - user_disabled: {403, "This user account is disabled. Please contact the instance administrator."}, + user_disabled: + {403, "This user account is disabled. Please contact the instance administrator."}, email_not_confirmed: {403, "Please confirm your email address first."}, unknown_resource: {400, "Unknown resource."}, invalid_argument: {400, "Invalid arguments passed."}, diff --git a/flavours/cooperation/config/bonfire_federate_activitypub.exs b/flavours/cooperation/config/bonfire_federate_activitypub.exs index 28e917ce5f..fc758f2aaa 100644 --- a/flavours/cooperation/config/bonfire_federate_activitypub.exs +++ b/flavours/cooperation/config/bonfire_federate_activitypub.exs @@ -13,12 +13,13 @@ config :bonfire, :bonfire_classify, :bonfire_geolocate, :bonfire_quantify - ], - log_federation: true, # enable/disable logging of federation logic + ], + # enable/disable logging of federation logic + log_federation: true, federation_fallback_module: Bonfire.Social.APActivities config :bonfire, actor_AP_types: actor_types # config :bonfire, Bonfire.Instance, - # hostname: hostname, - # description: desc +# hostname: hostname, +# description: desc diff --git a/flavours/cooperation/config/bonfire_files.exs b/flavours/cooperation/config/bonfire_files.exs index 7d59d69d8e..004256aaeb 100644 --- a/flavours/cooperation/config/bonfire_files.exs +++ b/flavours/cooperation/config/bonfire_files.exs @@ -4,48 +4,53 @@ import Config # see https://hexdocs.pm/waffle/Waffle.html#module-setup-a-storage-provider config :waffle, storage: Waffle.Storage.Local, - asset_host: "/" # or {:system, "ASSET_HOST"} + # or {:system, "ASSET_HOST"} + 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", -] +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_files, image_media_types: image_media_types config :bonfire_files, all_allowed_media_types: all_allowed_media_types config :bonfire_files, Bonfire.Files.IconUploader, allowed_media_types: image_media_types config :bonfire_files, Bonfire.Files.ImageUploader, allowed_media_types: image_media_types -config :bonfire_files, Bonfire.Files.DocumentUploader, allowed_media_types: all_allowed_media_types + +config :bonfire_files, Bonfire.Files.DocumentUploader, + allowed_media_types: all_allowed_media_types diff --git a/flavours/cooperation/config/bonfire_geolocate.exs b/flavours/cooperation/config/bonfire_geolocate.exs index 49c9723926..1d5142d211 100644 --- a/flavours/cooperation/config/bonfire_geolocate.exs +++ b/flavours/cooperation/config/bonfire_geolocate.exs @@ -3,5 +3,4 @@ import Config config :bonfire_geolocate, templates_path: "lib" -config :bonfire, :js_config, - mapbox_api_key: System.get_env("MAPBOX_API_KEY") +config :bonfire, :js_config, mapbox_api_key: System.get_env("MAPBOX_API_KEY") diff --git a/flavours/cooperation/config/bonfire_quantify.exs b/flavours/cooperation/config/bonfire_quantify.exs index 6cfe4174f1..521c304be9 100644 --- a/flavours/cooperation/config/bonfire_quantify.exs +++ b/flavours/cooperation/config/bonfire_quantify.exs @@ -3,4 +3,5 @@ import Config config :bonfire_quantify, templates_path: "lib" -config :bonfire_quantify, Bonfire.Quantify.Units, valid_contexts: [Bonfire.Quantify.Units, Bonfire.Data.Identity.User] +config :bonfire_quantify, Bonfire.Quantify.Units, + valid_contexts: [Bonfire.Quantify.Units, Bonfire.Data.Identity.User] diff --git a/flavours/cooperation/config/bonfire_search.exs b/flavours/cooperation/config/bonfire_search.exs index a5c6025899..7de227c923 100644 --- a/flavours/cooperation/config/bonfire_search.exs +++ b/flavours/cooperation/config/bonfire_search.exs @@ -3,8 +3,10 @@ import Config config :bonfire_search, disable_indexing: System.get_env("SEARCH_INDEXING_DISABLED", "false"), adapter: Bonfire.Search.Meili, - instance: System.get_env("SEARCH_MEILI_INSTANCE", "http://search:7700"), # protocol, hostname and port - api_key: System.get_env("MEILI_MASTER_KEY", "make-sure-to-change-me") # secret key + # protocol, hostname and port + instance: System.get_env("SEARCH_MEILI_INSTANCE", "http://search:7700"), + # secret key + api_key: System.get_env("MEILI_MASTER_KEY", "make-sure-to-change-me") # for use by API client config :tesla, adapter: Tesla.Adapter.Hackney diff --git a/flavours/cooperation/config/bonfire_ui.exs b/flavours/cooperation/config/bonfire_ui.exs index 992f1d7a30..7442e106df 100644 --- a/flavours/cooperation/config/bonfire_ui.exs +++ b/flavours/cooperation/config/bonfire_ui.exs @@ -1,113 +1,117 @@ import Config - config :bonfire, :ui, - theme: [ - instance_name: "Bonfire", - instance_icon: "/images/bonfire-icon.png", - instance_image: "/images/bonfires.png", - instance_description: "This is a bonfire demo instance for testing purposes", - instance_welcome: [ - title: "👋 Welcome", - description: "Bonfire is a federated social networking toolkit to customise and host your own online space and control your experience at the most granular level. + theme: [ + instance_name: "Bonfire", + instance_icon: "/images/bonfire-icon.png", + instance_image: "/images/bonfires.png", + instance_description: "This is a bonfire demo instance for testing purposes", + instance_welcome: [ + title: "👋 Welcome", + description: + "Bonfire is a federated social networking toolkit to customise and host your own online space and control your experience at the most granular level. More details at https://bonfirenetworks.org", - links: [ - "About Bonfire": "https://bonfirenetworks.org/", - "About ValueFlows": "https://valueflo.ws/", - "Forum": "https://socialhub.activitypub.rocks/g/bonfire/activity/posts", - "Community Chat": "https://matrix.to/#/%23bonfire-networks:matrix.org", - "Contribute": "https://bonfirenetworks.org/contribute/" - ] - ]], - app_menu_extension_paths: %{ # TODO: make dynamic based on active extensions - "Social" => Bonfire.UI.Social.FeedsLive, - "Breadpub" => Bonfire.Breadpub.Web.HomeLive, - "Kanban" => Bonfire.UI.Kanban.HomeLive, - # "Coordination" => Bonfire.UI.Coordination.ProcessesLive - }, - sidebar_components: [ # TODO: make dynamic based on active extensions - {Bonfire.UI.Social.SidebarNavigationLive, []}, - # {Bonfire.UI.Coordination.SidebarNavigationLive, []}, - #{Bonfire.Breadpub.SidebarNavigationLive, []}, - # {Bonfire.UI.ValueFlows.ProcessesListLive, [title: "Processes", process_url: "/process/"]}, - # {Bonfire.UI.ValueFlows.ProcessesListLive, [title: "Lists", process_url: "/breadpub/list/"]} - ], - rich_text_editor: Bonfire.Editor.Quill, - smart_input: [ - post: true, - cw: true, - summary: true - ], - profile: [ - sections: [ # TODO: make dynamic based on active extensions - timeline: Bonfire.UI.Social.ProfileTimelineLive, - # private: Bonfire.UI.Social.MessageThreadsLive, - posts: Bonfire.UI.Social.ProfilePostsLive, - boosts: Bonfire.UI.Social.ProfileBoostsLive, - followers: Bonfire.UI.Social.ProfileFollowsLive, - followed: Bonfire.UI.Social.ProfileFollowsLive, - # inventory: Bonfire.UI.Reflow.ProfileInventoryLive, - ], - navigation: [ - timeline: "timeline", - # inventory: "inventory", - posts: "posts", - boosts: "boosts", - # private: "private", - ], - widgets: [ - ], - ], - smart_input_activities: [ - post: "Compose a post", - task: "Add a task", - offer: "Publish an offer", - need: "Publish a need", - # transfer_resource: "Transfer a resource", - # produce_resource: "Add a resource", - # intent: "Indicate an itent", - economic_event: "Record an economic event", - process: "Define a process" - ], - smart_input_components: [ - post: Bonfire.UI.Social.WritePostContentLive, - message: Bonfire.UI.Social.WritePostContentLive, - category: Bonfire.Classify.Web.NewCategoryLive, - economic_event: Bonfire.UI.ValueFlows.SelectEconomicEventLive, - process: Bonfire.UI.ValueFlows.CreateProcessSmartInputLive, - offer: Bonfire.UI.ValueFlows.CreateIntentLive, - need: Bonfire.UI.ValueFlows.CreateIntentLive, - task: Bonfire.UI.Coordination.CreateTaskLive, - ], - resource: [ - navigation: [ - timeline: "timeline", - material_passport: "material passport", - ], - widgets: [ - # Bonfire.UI.Social.SubscribeWidgetLive, - Bonfire.UI.ValueFlows.LocationWidgetLive, - Bonfire.UI.Social.HashtagsWidgetLive, - ], - ] - # process: [ - # navigation: [ - # events: "Economic events", - # intents: "Intents", - # # material_passport: "material passport", - # ], - # sections: [ - # events: Bonfire.UI.ValueFlows.EconomicEventsLive, - # intents: Bonfire.UI.ValueFlows.IntentsLive, - # ], - # widgets: [ - # # Bonfire.UI.Social.SubscribeWidgetLive, - # # Bonfire.UI.ValueFlows.LocationWidgetLive, - # # Bonfire.UI.Social.HashtagsWidgetLive, - # ], - # ] + links: [ + "About Bonfire": "https://bonfirenetworks.org/", + "About ValueFlows": "https://valueflo.ws/", + Forum: "https://socialhub.activitypub.rocks/g/bonfire/activity/posts", + "Community Chat": "https://matrix.to/#/%23bonfire-networks:matrix.org", + Contribute: "https://bonfirenetworks.org/contribute/" + ] + ] + ], + # TODO: make dynamic based on active extensions + app_menu_extension_paths: %{ + "Social" => Bonfire.UI.Social.FeedsLive, + "Breadpub" => Bonfire.Breadpub.Web.HomeLive, + "Kanban" => Bonfire.UI.Kanban.HomeLive + # "Coordination" => Bonfire.UI.Coordination.ProcessesLive + }, + # TODO: make dynamic based on active extensions + sidebar_components: [ + {Bonfire.UI.Social.SidebarNavigationLive, []} + # {Bonfire.UI.Coordination.SidebarNavigationLive, []}, + # {Bonfire.Breadpub.SidebarNavigationLive, []}, + # {Bonfire.UI.ValueFlows.ProcessesListLive, [title: "Processes", process_url: "/process/"]}, + # {Bonfire.UI.ValueFlows.ProcessesListLive, [title: "Lists", process_url: "/breadpub/list/"]} + ], + rich_text_editor: Bonfire.Editor.Quill, + smart_input: [ + post: true, + cw: true, + summary: true + ], + profile: [ + # TODO: make dynamic based on active extensions + sections: [ + timeline: Bonfire.UI.Social.ProfileTimelineLive, + # private: Bonfire.UI.Social.MessageThreadsLive, + posts: Bonfire.UI.Social.ProfilePostsLive, + boosts: Bonfire.UI.Social.ProfileBoostsLive, + followers: Bonfire.UI.Social.ProfileFollowsLive, + followed: Bonfire.UI.Social.ProfileFollowsLive + # inventory: Bonfire.UI.Reflow.ProfileInventoryLive, + ], + navigation: [ + timeline: "timeline", + # inventory: "inventory", + posts: "posts", + boosts: "boosts" + # private: "private", + ], + widgets: [] + ], + smart_input_activities: [ + post: "Compose a post", + task: "Add a task", + offer: "Publish an offer", + need: "Publish a need", + # transfer_resource: "Transfer a resource", + # produce_resource: "Add a resource", + # intent: "Indicate an itent", + economic_event: "Record an economic event", + process: "Define a process" + ], + smart_input_components: [ + post: Bonfire.UI.Social.WritePostContentLive, + message: Bonfire.UI.Social.WritePostContentLive, + category: Bonfire.Classify.Web.NewCategoryLive, + economic_event: Bonfire.UI.ValueFlows.SelectEconomicEventLive, + process: Bonfire.UI.ValueFlows.CreateProcessSmartInputLive, + offer: Bonfire.UI.ValueFlows.CreateIntentLive, + need: Bonfire.UI.ValueFlows.CreateIntentLive, + task: Bonfire.UI.Coordination.CreateTaskLive + ], + resource: [ + navigation: [ + timeline: "timeline", + material_passport: "material passport" + ], + widgets: [ + # Bonfire.UI.Social.SubscribeWidgetLive, + Bonfire.UI.ValueFlows.LocationWidgetLive, + Bonfire.UI.Social.HashtagsWidgetLive + ] + ] + +# process: [ +# navigation: [ +# events: "Economic events", +# intents: "Intents", +# # material_passport: "material passport", +# ], +# sections: [ +# events: Bonfire.UI.ValueFlows.EconomicEventsLive, +# intents: Bonfire.UI.ValueFlows.IntentsLive, +# ], +# widgets: [ +# # Bonfire.UI.Social.SubscribeWidgetLive, +# # Bonfire.UI.ValueFlows.LocationWidgetLive, +# # Bonfire.UI.Social.HashtagsWidgetLive, +# ], +# ] config :surface_catalogue, - title: "Bonfire UI", - subtitle: "Surface Components Documentation & Examples" + title: "Bonfire UI", + subtitle: "Surface Components Documentation & Examples" diff --git a/flavours/cooperation/config/config.exs b/flavours/cooperation/config/config.exs index 19706a68e3..aba2e1b2dc 100644 --- a/flavours/cooperation/config/config.exs +++ b/flavours/cooperation/config/config.exs @@ -2,7 +2,7 @@ import Config default_flavour = "classic" flavour = System.get_env("FLAVOUR", default_flavour) -flavour_path = System.get_env("FLAVOUR_PATH", "flavours/"<>flavour) +flavour_path = System.get_env("FLAVOUR_PATH", "flavours/" <> flavour) #### Basic configuration @@ -33,7 +33,8 @@ config :bonfire, config :bonfire, Bonfire.Web.Endpoint, url: [host: "localhost"], http: [ - port: String.to_integer(System.get_env("SERVER_PORT", "4000")), # this gets overriden in runtime.exs + # this gets overriden in runtime.exs + port: String.to_integer(System.get_env("SERVER_PORT", "4000")), transport_options: [socket_opts: [:inet6]] ], render_errors: [view: Bonfire.UI.Common.ErrorView, accepts: ~w(html json), layout: false], @@ -44,6 +45,7 @@ config :phoenix_gon, :json_library, Jason config :ecto_sparkles, :otp_app, :bonfire config :bonfire, :ecto_repos, [Bonfire.Common.Repo] + config :bonfire, Bonfire.Common.Repo, types: Bonfire.Geolocate.PostgresTypes, priv: flavour_path <> "/repo" @@ -74,10 +76,9 @@ config :mime, :types, %{ config :sentry, dsn: "this-will-be-overriden-by-a-secure-string-in-runtime.exs", - environment_name: Mix.env, + environment_name: Mix.env(), included_environments: [:prod] - # include config for all used Bonfire extensions for config <- "bonfire_*.exs" |> Path.expand(__DIR__) |> Path.wildcard() do # IO.inspect(include_config: config) @@ -86,6 +87,5 @@ end import_config "activity_pub.exs" - # finally, append/override config based on env, which will override any config set above (including from imported files) import_config "#{config_env()}.exs" diff --git a/flavours/cooperation/config/dev.exs b/flavours/cooperation/config/dev.exs index 480826d532..9a4239276a 100644 --- a/flavours/cooperation/config/dev.exs +++ b/flavours/cooperation/config/dev.exs @@ -1,21 +1,27 @@ import Config config :bonfire, Bonfire.Common.Repo, - experimental_features_enabled: true, # Note: you can run `Bonfire.Common.Config.put(:experimental_features_enabled, true)` to enable these in prod too + # Note: you can run `Bonfire.Common.Config.put(:experimental_features_enabled, true)` to enable these in prod too + experimental_features_enabled: true, database: System.get_env("POSTGRES_DB", "bonfire_dev"), # show_sensitive_data_on_connection_error: true, pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"), - log: false # EctoSparkles does the logging instead + # EctoSparkles does the logging instead + log: false path_dep_dirs = Mess.deps([path: "deps.path"], []) |> Enum.map(&(Keyword.fetch!(elem(&1, 1), :path) <> "/lib")) config :phoenix_live_reload, - dirs: path_dep_dirs ++ ["lib/"] # watch the app's lib/ dir + the dep/lib/ dir of every locally-cloned dep + # watch the app's lib/ dir + the dep/lib/ dir of every locally-cloned dep + dirs: path_dep_dirs ++ ["lib/"] -path_dep_patterns = path_dep_dirs |> Enum.map(&(String.slice(&1, 2..1000) <>".*ex")) # to include cloned code in patterns -path_dep_patterns = path_dep_patterns ++ path_dep_dirs |> Enum.map(&(String.slice(&1, 2..1000) <>".*sface")) # Surface views +# to include cloned code in patterns +path_dep_patterns = Enum.map(path_dep_dirs, &(String.slice(&1, 2..1000) <> ".*ex")) +# Surface views +path_dep_patterns = + (path_dep_patterns ++ path_dep_dirs) |> Enum.map(&(String.slice(&1, 2..1000) <> ".*sface")) # Watch static and templates for browser reloading. config :bonfire, Bonfire.Web.Endpoint, @@ -38,24 +44,26 @@ config :bonfire, Bonfire.Web.Endpoint, ] ], live_reload: [ - patterns: [ - # ~r"^priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", - # ~r"^priv/gettext/.*(po)$", - # ~r"^web/(live|views)/.*ex$", - # ~r"^lib/.*_live\.ex$", - # ~r".*leex$", - ~r"lib/.*ex$", - ~r".*sface$", - ~r"priv/catalogue/.*(ex)$", - ] ++ path_dep_patterns - ] + patterns: + [ + # ~r"^priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", + # ~r"^priv/gettext/.*(po)$", + # ~r"^web/(live|views)/.*ex$", + # ~r"^lib/.*_live\.ex$", + # ~r".*leex$", + # defp elixirc_paths(:dev), do: ["lib"] ++ catalogues() -# defp elixirc_paths(:dev), do: ["lib"] ++ catalogues() + ~r"lib/.*ex$", + ~r".*sface$", + ~r"priv/catalogue/.*(ex)$" + ] ++ path_dep_patterns + ] config :logger, :console, level: :debug, # truncate: :infinity, - format: "[$level] $message\n" # Do not include metadata or timestamps + # Do not include metadata or timestamps + format: "[$level] $message\n" config :phoenix, :stacktrace_depth, 30 diff --git a/flavours/cooperation/config/prod.exs b/flavours/cooperation/config/prod.exs index 8a3cad9d37..dea572d579 100644 --- a/flavours/cooperation/config/prod.exs +++ b/flavours/cooperation/config/prod.exs @@ -1,13 +1,11 @@ import Config - # We include the path to a cache manifest # containing the digested version of static files. This # manifest is generated by the `mix phx.digest` task, # which you should run after static files are built and # before starting your production server. -config :bonfire, Bonfire.Web.Endpoint, - cache_static_manifest: "priv/static/cache_manifest.json" +config :bonfire, Bonfire.Web.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json" config :logger, backends: [:console, Sentry.LoggerBackend] @@ -18,4 +16,5 @@ config :logger, level: :info config :bonfire, Bonfire.Web.Endpoint, server: true config :bonfire, Bonfire.Common.Repo, - priv: "priv/repo" # in releases migrations are not in a flavour-specific directory + # in releases migrations are not in a flavour-specific directory + priv: "priv/repo" diff --git a/flavours/cooperation/config/runtime.exs b/flavours/cooperation/config/runtime.exs index 55b59a10ec..7aa902e020 100644 --- a/flavours/cooperation/config/runtime.exs +++ b/flavours/cooperation/config/runtime.exs @@ -13,16 +13,15 @@ Bonfire.Common.Config.LoadExtensionsConfig.load_configs() ## System.get_env("DATABASE_URL") || System.get_env("POSTGRES_PASSWORD") || System.get_env("CI") || - raise """ - Environment variables for database are missing. - For example: DATABASE_URL=ecto://USER:PASS@HOST/DATABASE - You can also set POSTGRES_PASSWORD (required), - and POSTGRES_USER (default: postgres) and POSTGRES_HOST (default: localhost) - """ + raise """ + Environment variables for database are missing. + For example: DATABASE_URL=ecto://USER:PASS@HOST/DATABASE + You can also set POSTGRES_PASSWORD (required), + and POSTGRES_USER (default: postgres) and POSTGRES_HOST (default: localhost) + """ if System.get_env("DATABASE_URL") do - config :bonfire, Bonfire.Common.Repo, - url: System.get_env("DATABASE_URL") + config :bonfire, Bonfire.Common.Repo, url: System.get_env("DATABASE_URL") else config :bonfire, Bonfire.Common.Repo, # ssl: true, @@ -38,12 +37,14 @@ secret_key_base = You can generate one by calling: mix phx.gen.secret """ -signing_salt = System.get_env("SIGNING_SALT") || System.get_env("CI") || +signing_salt = + System.get_env("SIGNING_SALT") || System.get_env("CI") || raise """ environment variable SIGNING_SALT is missing. """ -encryption_salt = System.get_env("ENCRYPTION_SALT") || System.get_env("CI") || +encryption_salt = + System.get_env("ENCRYPTION_SALT") || System.get_env("CI") || raise """ environment variable ENCRYPTION_SALT is missing. """ @@ -57,7 +58,10 @@ config :bonfire, encryption_salt: encryption_salt, signing_salt: signing_salt -start_server? = if config_env() == :test, do: System.get_env("START_SERVER", "true"), else: System.get_env("START_SERVER", "true") +start_server? = + if config_env() == :test, + do: System.get_env("START_SERVER", "true"), + else: System.get_env("START_SERVER", "true") config :bonfire, Bonfire.Web.Endpoint, server: String.to_existing_atom(start_server?), @@ -72,9 +76,7 @@ config :bonfire, Bonfire.Web.Endpoint, live_view: [signing_salt: signing_salt] if System.get_env("SENTRY_DSN") do - IO.puts( - "Note: errors will be reported to Sentry." - ) + IO.puts("Note: errors will be reported to Sentry.") config :sentry, dsn: System.get_env("SENTRY_DSN") @@ -86,22 +88,20 @@ end # start prod-only config if config_env() == :prod do - config :bonfire, Bonfire.Common.Repo, # ssl: true, database: System.get_env("POSTGRES_DB", "bonfire"), pool_size: String.to_integer(System.get_env("POOL_SIZE", "10")), - log: String.to_atom(System.get_env("DB_QUERIES_LOG_LEVEL", "false")) # Note: keep this disabled if using ecto_dev_logger or EctoSparkles.Log instead # - -end # prod only config + # Note: keep this disabled if using ecto_dev_logger or EctoSparkles.Log instead # + log: String.to_atom(System.get_env("DB_QUERIES_LOG_LEVEL", "false")) +end +# prod only config # start prod and dev only config if config_env() != :test do - config :bonfire, Bonfire.Common.Repo, slow_query_ms: String.to_integer(System.get_env("SLOW_QUERY_MS", "100")) - end ## bonfire_livebook diff --git a/flavours/cooperation/config/test.exs b/flavours/cooperation/config/test.exs index ce3bd86a78..b43b2980b5 100644 --- a/flavours/cooperation/config/test.exs +++ b/flavours/cooperation/config/test.exs @@ -15,7 +15,6 @@ config :bonfire_search, config :logger, level: :info # config :logger, level: :notice - # Configure your database db = "bonfire_test#{System.get_env("MIX_TEST_PARTITION")}" # @@ -46,6 +45,7 @@ config :mix_test_interactive, clear: true config :paginator, ecto_repos: [Bonfire.Common.Repo] + config :paginator, Paginator.Repo, pool: Ecto.Adapters.SQL.Sandbox, username: System.get_env("POSTGRES_USER", "postgres"), diff --git a/flavours/cooperation/repo/migrations/20200523081010_citext.exs b/flavours/cooperation/repo/migrations/20200523081010_citext.exs index bad3ec5df0..8de33932f7 100644 --- a/flavours/cooperation/repo/migrations/20200523081010_citext.exs +++ b/flavours/cooperation/repo/migrations/20200523081010_citext.exs @@ -2,11 +2,10 @@ defmodule Bonfire.Repo.Migrations.HelloWorld do use Ecto.Migration def up do - execute "CREATE EXTENSION IF NOT EXISTS \"citext\"" + execute("CREATE EXTENSION IF NOT EXISTS \"citext\"") end def down do - execute "DROP EXTENSION IF EXISTS \"citext\"" + execute("DROP EXTENSION IF EXISTS \"citext\"") end - end diff --git a/flavours/cooperation/repo/migrations/20200523081012_init_pointers.exs b/flavours/cooperation/repo/migrations/20200523081012_init_pointers.exs index 7fa1ef977d..4d75827e8e 100644 --- a/flavours/cooperation/repo/migrations/20200523081012_init_pointers.exs +++ b/flavours/cooperation/repo/migrations/20200523081012_init_pointers.exs @@ -6,9 +6,9 @@ defmodule Bonfire.Repo.Migrations.InitPointers do init_pointers_ulid_extra() init_pointers() end + def down do init_pointers_ulid_extra() init_pointers() end - end diff --git a/flavours/cooperation/repo/migrations/20200523081014_init_edges.exs b/flavours/cooperation/repo/migrations/20200523081014_init_edges.exs index 523e0e8258..6a9051db55 100644 --- a/flavours/cooperation/repo/migrations/20200523081014_init_edges.exs +++ b/flavours/cooperation/repo/migrations/20200523081014_init_edges.exs @@ -2,7 +2,6 @@ defmodule Bonfire.Repo.Migrations.InitEdges do use Ecto.Migration alias Bonfire.Data.Edges.Migration - def up do Migration.up() end @@ -10,5 +9,4 @@ defmodule Bonfire.Repo.Migrations.InitEdges do def down do Migration.down() end - end diff --git a/flavours/cooperation/repo/migrations/20200818094943_import_ap.exs b/flavours/cooperation/repo/migrations/20200818094943_import_ap.exs index 38cea36742..bfdc4815e6 100644 --- a/flavours/cooperation/repo/migrations/20200818094943_import_ap.exs +++ b/flavours/cooperation/repo/migrations/20200818094943_import_ap.exs @@ -6,5 +6,4 @@ defmodule Bonfire.Federate.ActivityPub.Repo.Migrations.ImportMe do def up, do: migrate_activity_pub def down, do: migrate_activity_pub - end diff --git a/flavours/cooperation/repo/migrations/20200820094941_import_boundaries.exs b/flavours/cooperation/repo/migrations/20200820094941_import_boundaries.exs index bc21caeec0..f46503012a 100644 --- a/flavours/cooperation/repo/migrations/20200820094941_import_boundaries.exs +++ b/flavours/cooperation/repo/migrations/20200820094941_import_boundaries.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.ImportBoundaries do def up, do: migrate_boundaries def down, do: migrate_boundaries - end diff --git a/flavours/cooperation/repo/migrations/20200828094944_import_me.exs b/flavours/cooperation/repo/migrations/20200828094944_import_me.exs index 5b9e9a8c3f..97ac819380 100644 --- a/flavours/cooperation/repo/migrations/20200828094944_import_me.exs +++ b/flavours/cooperation/repo/migrations/20200828094944_import_me.exs @@ -9,5 +9,4 @@ defmodule Bonfire.Repo.Migrations.ImportMe do end def down, do: migrate_me() - end diff --git a/flavours/cooperation/repo/migrations/20200828094945_import_social.exs b/flavours/cooperation/repo/migrations/20200828094945_import_social.exs index 3f8c6db408..2ee83ee871 100644 --- a/flavours/cooperation/repo/migrations/20200828094945_import_social.exs +++ b/flavours/cooperation/repo/migrations/20200828094945_import_social.exs @@ -5,10 +5,8 @@ defmodule Bonfire.Social.Repo.Migrations.ImportSocial do import Pointers.Migration def up do - migrate_social() - end - def down, do: migrate_social() + def down, do: migrate_social() end diff --git a/flavours/cooperation/repo/migrations/20200829004946_boundaries_fixtures.exs b/flavours/cooperation/repo/migrations/20200829004946_boundaries_fixtures.exs index 87fd61baf6..7a8eb123c7 100644 --- a/flavours/cooperation/repo/migrations/20200829004946_boundaries_fixtures.exs +++ b/flavours/cooperation/repo/migrations/20200829004946_boundaries_fixtures.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.BoundariesFixtures do def up, do: Bonfire.Boundaries.Fixtures.insert() def down, do: nil - end diff --git a/flavours/cooperation/repo/migrations/20201205094943_import_quantify.exs b/flavours/cooperation/repo/migrations/20201205094943_import_quantify.exs index 5c0bce0506..4a60dd1763 100644 --- a/flavours/cooperation/repo/migrations/20201205094943_import_quantify.exs +++ b/flavours/cooperation/repo/migrations/20201205094943_import_quantify.exs @@ -2,12 +2,12 @@ defmodule Bonfire.Repo.Migrations.ImportQuantify do use Ecto.Migration def up do - Bonfire.Quantify.Migrations.change - Bonfire.Quantify.Migrations.change_measure + Bonfire.Quantify.Migrations.change() + Bonfire.Quantify.Migrations.change_measure() end def down do - Bonfire.Quantify.Migrations.change - Bonfire.Quantify.Migrations.change_measure + Bonfire.Quantify.Migrations.change() + Bonfire.Quantify.Migrations.change_measure() end end diff --git a/flavours/cooperation/repo/migrations/20201208094940_import_geolocation.exs b/flavours/cooperation/repo/migrations/20201208094940_import_geolocation.exs index 479d9e680c..42178a098b 100644 --- a/flavours/cooperation/repo/migrations/20201208094940_import_geolocation.exs +++ b/flavours/cooperation/repo/migrations/20201208094940_import_geolocation.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportGeolocation do use Ecto.Migration def up do - Bonfire.Geolocate.Migrations.change + Bonfire.Geolocate.Migrations.change() end def down do - Bonfire.Geolocate.Migrations.change + Bonfire.Geolocate.Migrations.change() end end diff --git a/flavours/cooperation/repo/migrations/20201212094942_import_valueflows.exs b/flavours/cooperation/repo/migrations/20201212094942_import_valueflows.exs index 87b60d305d..17868173f8 100644 --- a/flavours/cooperation/repo/migrations/20201212094942_import_valueflows.exs +++ b/flavours/cooperation/repo/migrations/20201212094942_import_valueflows.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportValueFlows do use Ecto.Migration def up do - ValueFlows.AllMigrations.up + ValueFlows.AllMigrations.up() end def down do - ValueFlows.AllMigrations.down + ValueFlows.AllMigrations.down() end end diff --git a/flavours/cooperation/repo/migrations/20210102094944_import_shared_user.exs b/flavours/cooperation/repo/migrations/20210102094944_import_shared_user.exs index 09845637a3..e55a68d7fa 100644 --- a/flavours/cooperation/repo/migrations/20210102094944_import_shared_user.exs +++ b/flavours/cooperation/repo/migrations/20210102094944_import_shared_user.exs @@ -6,5 +6,4 @@ defmodule Bonfire.Repo.Migrations.ImportSharedUser do def up, do: migrate_shared_user() def down, do: migrate_shared_user() - end diff --git a/flavours/cooperation/repo/migrations/20210113094942_import_valueflows_observe.exs b/flavours/cooperation/repo/migrations/20210113094942_import_valueflows_observe.exs index f71a9dc765..4f67bd579a 100644 --- a/flavours/cooperation/repo/migrations/20210113094942_import_valueflows_observe.exs +++ b/flavours/cooperation/repo/migrations/20210113094942_import_valueflows_observe.exs @@ -4,10 +4,10 @@ defmodule Bonfire.Repo.Migrations.ImportValueFlowsObserve do alias ValueFlows.Observe.Migrations def up do - Migrations.up + Migrations.up() end def down do - Migrations.down + Migrations.down() end end diff --git a/flavours/cooperation/repo/migrations/20210402105128_ap_test_table.exs b/flavours/cooperation/repo/migrations/20210402105128_ap_test_table.exs index 929b6324f6..ecc4b56355 100644 --- a/flavours/cooperation/repo/migrations/20210402105128_ap_test_table.exs +++ b/flavours/cooperation/repo/migrations/20210402105128_ap_test_table.exs @@ -4,12 +4,12 @@ defmodule ActivityPub.Repo.Migrations.APTestTable do def change do # This table only exists for test purposes create table("local_actor", primary_key: false) do - add :id, :uuid, primary_key: true - add :username, :citext - add :data, :map - add :local, :boolean - add :keys, :text - add :followers, {:array, :string} + add(:id, :uuid, primary_key: true) + add(:username, :citext) + add(:data, :map) + add(:local, :boolean) + add(:keys, :text) + add(:followers, {:array, :string}) end end end diff --git a/flavours/cooperation/repo/migrations/20210407094946_message.exs b/flavours/cooperation/repo/migrations/20210407094946_message.exs index 9cb0cc34b9..9a23628612 100644 --- a/flavours/cooperation/repo/migrations/20210407094946_message.exs +++ b/flavours/cooperation/repo/migrations/20210407094946_message.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Repo.Migrations.Message do def up, do: migrate_message() def down, do: migrate_message() - end diff --git a/flavours/cooperation/repo/migrations/20210410094945_profile_images.exs b/flavours/cooperation/repo/migrations/20210410094945_profile_images.exs index c0a07043eb..8294d2b957 100644 --- a/flavours/cooperation/repo/migrations/20210410094945_profile_images.exs +++ b/flavours/cooperation/repo/migrations/20210410094945_profile_images.exs @@ -4,15 +4,19 @@ defmodule Bonfire.Social.Repo.Migrations.ProfileImages do import Pointers.Migration def up do + drop_if_exists( + constraint("bonfire_data_social_profile", "bonfire_data_social_profile_icon_id_fkey") + ) - drop_if_exists constraint "bonfire_data_social_profile", "bonfire_data_social_profile_icon_id_fkey" - drop_if_exists constraint "bonfire_data_social_profile", "bonfire_data_social_profile_image_id_fkey" + drop_if_exists( + constraint("bonfire_data_social_profile", "bonfire_data_social_profile_image_id_fkey") + ) alter table("bonfire_data_social_profile") do - Ecto.Migration.add_if_not_exists :icon_id, strong_pointer(Bonfire.Files.Media) - Ecto.Migration.add_if_not_exists :image_id, strong_pointer(Bonfire.Files.Media) + Ecto.Migration.add_if_not_exists(:icon_id, strong_pointer(Bonfire.Files.Media)) + Ecto.Migration.add_if_not_exists(:image_id, strong_pointer(Bonfire.Files.Media)) end end - def down, do: nil + def down, do: nil end diff --git a/flavours/cooperation/repo/migrations/20210412094946_fp.exs b/flavours/cooperation/repo/migrations/20210412094946_fp.exs index 4e13f8b533..1966abd46a 100644 --- a/flavours/cooperation/repo/migrations/20210412094946_fp.exs +++ b/flavours/cooperation/repo/migrations/20210412094946_fp.exs @@ -1,7 +1,6 @@ defmodule Bonfire.Repo.Migrations.FP do use Ecto.Migration - def up do execute("create or replace function column_exists(ptable text, pcolumn text, pschema text default 'public') @@ -18,7 +17,8 @@ defmodule Bonfire.Repo.Migrations.FP do ); $body$;") - execute("CREATE OR REPLACE FUNCTION rename_column_if_exists(ptable TEXT, pcolumn TEXT, new_name TEXT) + execute( + "CREATE OR REPLACE FUNCTION rename_column_if_exists(ptable TEXT, pcolumn TEXT, new_name TEXT) RETURNS VOID AS $BODY$ BEGIN -- Rename the column if it exists. @@ -27,14 +27,15 @@ defmodule Bonfire.Repo.Migrations.FP do ptable, pcolumn, new_name); END IF; END$BODY$ - LANGUAGE plpgsql VOLATILE;") + LANGUAGE plpgsql VOLATILE;" + ) flush() - execute("SELECT rename_column_if_exists('bonfire_data_social_feed_publish', 'object_id', 'activity_id') ") - + execute( + "SELECT rename_column_if_exists('bonfire_data_social_feed_publish', 'object_id', 'activity_id') " + ) end def down, do: nil - end diff --git a/flavours/cooperation/repo/migrations/20210618094945_peered_uri.exs b/flavours/cooperation/repo/migrations/20210618094945_peered_uri.exs index ce0bb3c412..1aff450e95 100644 --- a/flavours/cooperation/repo/migrations/20210618094945_peered_uri.exs +++ b/flavours/cooperation/repo/migrations/20210618094945_peered_uri.exs @@ -5,9 +5,9 @@ defmodule Bonfire.Social.Repo.Migrations.PeeredURI do def up do alter table("bonfire_data_activity_pub_peered") do - Ecto.Migration.add_if_not_exists :canonical_uri, :text, null: true + Ecto.Migration.add_if_not_exists(:canonical_uri, :text, null: true) end end - def down, do: nil + def down, do: nil end diff --git a/flavours/cooperation/repo/migrations/20210925094942_import_classify.exs b/flavours/cooperation/repo/migrations/20210925094942_import_classify.exs index 2f83f7b214..d8c04f13ec 100644 --- a/flavours/cooperation/repo/migrations/20210925094942_import_classify.exs +++ b/flavours/cooperation/repo/migrations/20210925094942_import_classify.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportClassify do use Ecto.Migration def up do - Bonfire.Classify.Migrations.up + Bonfire.Classify.Migrations.up() end def down do - Bonfire.Classify.Migrations.down + Bonfire.Classify.Migrations.down() end end diff --git a/flavours/cooperation/repo/migrations/20211001094942_import_assort_ranked.exs b/flavours/cooperation/repo/migrations/20211001094942_import_assort_ranked.exs index daf2c99385..93aaa5b18e 100644 --- a/flavours/cooperation/repo/migrations/20211001094942_import_assort_ranked.exs +++ b/flavours/cooperation/repo/migrations/20211001094942_import_assort_ranked.exs @@ -2,7 +2,6 @@ defmodule Bonfire.Repo.Migrations.ImportRanked do use Ecto.Migration require Bonfire.Data.Assort.Ranked.Migration - def up, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked - def down, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked - + def up, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked() + def down, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked() end diff --git a/flavours/cooperation/repo/migrations/20211112094942_import_commitment_satisfaction.exs b/flavours/cooperation/repo/migrations/20211112094942_import_commitment_satisfaction.exs index 8e08f938ed..fc46a93de8 100644 --- a/flavours/cooperation/repo/migrations/20211112094942_import_commitment_satisfaction.exs +++ b/flavours/cooperation/repo/migrations/20211112094942_import_commitment_satisfaction.exs @@ -3,7 +3,7 @@ defmodule Bonfire.Repo.Migrations.ImportCommitmentSatisfaction do def up do ValueFlows.Planning.Commitment.Migrations.up() - ValueFlows.Planning.Satisfaction.Migrations.up() + ValueFlows.Planning.Satisfaction.Migrations.up() end def down do diff --git a/flavours/cooperation/repo/migrations/20220208094942_import_invite_link.exs b/flavours/cooperation/repo/migrations/20220208094942_import_invite_link.exs index aead406a7e..4fa8d4f44c 100644 --- a/flavours/cooperation/repo/migrations/20220208094942_import_invite_link.exs +++ b/flavours/cooperation/repo/migrations/20220208094942_import_invite_link.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportInviteLink do use Ecto.Migration def up do - Bonfire.Invites.Link.Migration.up + Bonfire.Invites.Link.Migration.up() end def down do - Bonfire.Invites.Link.Migration.down + Bonfire.Invites.Link.Migration.down() end end diff --git a/flavours/cooperation/repo/migrations/20220304081300_care_closure.exs b/flavours/cooperation/repo/migrations/20220304081300_care_closure.exs index 30a0dbc621..2e41085d5c 100644 --- a/flavours/cooperation/repo/migrations/20220304081300_care_closure.exs +++ b/flavours/cooperation/repo/migrations/20220304081300_care_closure.exs @@ -4,5 +4,4 @@ defmodule Bonfire.Data.Identity.Repo.Migrations.CareClosure do alias Bonfire.Data.Identity.CareClosure.Migration def change, do: Migration.migrate_care_closure_view() - end diff --git a/flavours/cooperation/repo/migrations/20220408094940_settings.exs b/flavours/cooperation/repo/migrations/20220408094940_settings.exs index c7a22dcd23..57f6ac5987 100644 --- a/flavours/cooperation/repo/migrations/20220408094940_settings.exs +++ b/flavours/cooperation/repo/migrations/20220408094940_settings.exs @@ -2,7 +2,7 @@ defmodule Bonfire.Repo.Migrations.ImportSettings do use Ecto.Migration require Bonfire.Data.Identity.Settings.Migration - def up do + def up do Bonfire.Data.Identity.Settings.Migration.migrate_settings(:up) end diff --git a/flavours/cooperation/repo/migrations/20220428094200_add_files_mixin.exs b/flavours/cooperation/repo/migrations/20220428094200_add_files_mixin.exs index 0fd23546a9..ae2f93b48f 100644 --- a/flavours/cooperation/repo/migrations/20220428094200_add_files_mixin.exs +++ b/flavours/cooperation/repo/migrations/20220428094200_add_files_mixin.exs @@ -5,9 +5,10 @@ defmodule Bonfire.Repo.Migrations.AddFilesMixin do 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 + # cleanup old stuff + alter table("bonfire_files_media") do + remove_if_exists(:created_at, :utc_datetime_usec) + remove_if_exists(:updated_at, :utc_datetime_usec) end Bonfire.Files.Migrations.migrate_files() diff --git a/flavours/cooperation/repo/migrations/20220701004946_boundaries_fixtures_up.exs b/flavours/cooperation/repo/migrations/20220701004946_boundaries_fixtures_up.exs index 459abf2c09..ef5eb88114 100644 --- a/flavours/cooperation/repo/migrations/20220701004946_boundaries_fixtures_up.exs +++ b/flavours/cooperation/repo/migrations/20220701004946_boundaries_fixtures_up.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.BoundariesUpFixtures do def up, do: Bonfire.Boundaries.Fixtures.insert() def down, do: nil - end diff --git a/flavours/cooperation/repo/seeds.exs b/flavours/cooperation/repo/seeds.exs index 930c8c6bff..7504f8e90b 100644 --- a/flavours/cooperation/repo/seeds.exs +++ b/flavours/cooperation/repo/seeds.exs @@ -3,28 +3,30 @@ import Bonfire.Me.Fake System.put_env("INVITE_ONLY", "false") System.put_env("SEARCH_INDEXING_DISABLED", "true") -%{ - preferred_username: System.get_env("SEEDS_USER", "root"), - name: System.get_env("SEEDS_USER", "Seed User") -} -|> fake_user!(%{confirm_email: true}) +fake_user!( + %{ + preferred_username: System.get_env("SEEDS_USER", "root"), + name: System.get_env("SEEDS_USER", "Seed User") + }, + %{confirm_email: true} +) # create some users users = for _ <- 1..2, do: fake_user!() random_user = fn -> Faker.Util.pick(users) end # start some communities -#communities = for _ <- 1..2, do: fake_community!(random_user.()) -#subcommunities = for _ <- 1..2, do: fake_community!(random_user.(), Faker.Util.pick(communities)) -#maybe_random_community = fn -> maybe_one_of(communities ++ subcommunities) end +# communities = for _ <- 1..2, do: fake_community!(random_user.()) +# subcommunities = for _ <- 1..2, do: fake_community!(random_user.(), Faker.Util.pick(communities)) +# maybe_random_community = fn -> maybe_one_of(communities ++ subcommunities) end # create fake collections -#collections = for _ <- 1..4, do: fake_collection!(random_user.(), maybe_random_community.()) -#subcollections = for _ <- 1..2, do: fake_collection!(random_user.(), Faker.Util.pick(collections)) -#maybe_random_collection = fn -> maybe_one_of(collections ++ subcollections) end +# collections = for _ <- 1..4, do: fake_collection!(random_user.(), maybe_random_community.()) +# subcollections = for _ <- 1..2, do: fake_collection!(random_user.(), Faker.Util.pick(collections)) +# maybe_random_collection = fn -> maybe_one_of(collections ++ subcollections) end # start fake threads -#for _ <- 1..3 do +# for _ <- 1..3 do # user = random_user.() # thread = fake_thread!(user, maybe_random_community.()) # comment = fake_comment!(user, thread) @@ -32,18 +34,18 @@ random_user = fn -> Faker.Util.pick(users) end # reply = fake_comment!(random_user.(), thread, %{in_reply_to_id: comment.id}) # subreply = fake_comment!(random_user.(), thread, %{in_reply_to_id: reply.id}) # subreply2 = fake_comment!(random_user.(), thread, %{in_reply_to_id: subreply.id}) -#end +# end # ## more fake threads -#for _ <- 1..2 do +# for _ <- 1..2 do # user = random_user.() # thread = fake_thread!(user, maybe_random_collection.()) # comment = fake_comment!(user, thread) -#end +# end # post some links/resources -#for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_community.()) -#for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_collection.()) +# for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_community.()) +# for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_collection.()) # define some tags/categories if(Bonfire.Common.Extend.extension_enabled?(Bonfire.Classify.Simulate)) do @@ -89,18 +91,22 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do # some proposed intents action_id = ValueFlows.Simulate.action_id() - intent = ValueFlows.Simulate.fake_intent!(user, %{resource_conforms_to: res_spec, action_id: action_id}) + + intent = + ValueFlows.Simulate.fake_intent!(user, %{ + resource_conforms_to: res_spec, + action_id: action_id + }) + proposal = ValueFlows.Simulate.fake_proposal!(user) ValueFlows.Simulate.fake_proposed_to!(random_user.(), proposal) ValueFlows.Simulate.fake_proposed_intent!(proposal, intent) # define some geolocations if(Bonfire.Common.Extend.extension_enabled?(Bonfire.Geolocate.Simulate)) do - places = for _ <- 1..2, do: Bonfire.Geolocate.Simulate.fake_geolocation!(random_user.()) random_place = fn -> Faker.Util.pick(places) end - for _ <- 1..2 do # define some intents with geolocation _intent = @@ -110,7 +116,8 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do ) # define some proposals with geolocation - _proposal = ValueFlows.Simulate.fake_proposal!(user, %{eligible_location: random_place.()}) + _proposal = + ValueFlows.Simulate.fake_proposal!(user, %{eligible_location: random_place.()}) # both with geo intent = @@ -125,8 +132,13 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do # some economic events user = random_user.() - resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(user, %{current_location: random_place.()}) - to_resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{current_location: random_place.()}) + resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(user, %{current_location: random_place.()}) + + to_resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{ + current_location: random_place.() + }) ValueFlows.Simulate.fake_economic_event!( user, @@ -162,7 +174,9 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do unit = Faker.Util.pick([unit1, unit2]) resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(user, %{}, unit) - to_resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{}, unit) + + to_resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{}, unit) ValueFlows.Simulate.fake_economic_event!( user, diff --git a/flavours/cooperation/repo/seeds/20210122131234_observe_classifications.exs b/flavours/cooperation/repo/seeds/20210122131234_observe_classifications.exs index 098393c298..05581b6cc5 100644 --- a/flavours/cooperation/repo/seeds/20210122131234_observe_classifications.exs +++ b/flavours/cooperation/repo/seeds/20210122131234_observe_classifications.exs @@ -1,7 +1,7 @@ defmodule Bonfire.Repo.Seeds.ObserveClassifications do use Bonfire.Seeder - envs [:dev, :prod, :test] + envs([:dev, :prod, :test]) def up(repo), do: ValueFlows.Observe.Seeds.up(repo) end diff --git a/flavours/haha/config/activity_pub_test.exs b/flavours/haha/config/activity_pub_test.exs index 323eacd6fd..ac343b578e 100644 --- a/flavours/haha/config/activity_pub_test.exs +++ b/flavours/haha/config/activity_pub_test.exs @@ -12,9 +12,8 @@ config :activity_pub, Oban, repo: Bonfire.Common.Repo, queues: false -config :activity_pub, :instance, - federating: false - # rewrite_policy: [ActivityPub.MRF.SimplePolicy] +config :activity_pub, :instance, federating: false +# rewrite_policy: [ActivityPub.MRF.SimplePolicy] config :tesla, adapter: Tesla.Mock diff --git a/flavours/haha/config/bonfire_common.exs b/flavours/haha/config/bonfire_common.exs index fa0fe71e6d..9dd428f9de 100644 --- a/flavours/haha/config/bonfire_common.exs +++ b/flavours/haha/config/bonfire_common.exs @@ -8,7 +8,8 @@ config :bonfire_common, # internationalisation config :bonfire_common, Bonfire.Common.Localise.Cldr, default_locale: default_locale, - locales: ["fr", "en", "es"], # locales that will be made available on top of those for which gettext localisation files are available + # locales that will be made available on top of those for which gettext localisation files are available + locales: ["fr", "en", "es"], providers: [Cldr.Language], gettext: Bonfire.Common.Localise.Gettext, data_dir: "./priv/cldr", diff --git a/flavours/haha/config/bonfire_data.exs b/flavours/haha/config/bonfire_data.exs index 59bee4046e..c6acb06c1a 100644 --- a/flavours/haha/config/bonfire_data.exs +++ b/flavours/haha/config/bonfire_data.exs @@ -2,50 +2,68 @@ import Config #### Base configuration -verbs = ["Boost", "Create", "Delete", "Edit", "Flag", "Follow", "Like", "Mention", - "Message", "Read", "Reply", "Request", "See", "Tag"] +verbs = [ + "Boost", + "Create", + "Delete", + "Edit", + "Flag", + "Follow", + "Like", + "Mention", + "Message", + "Read", + "Reply", + "Request", + "See", + "Tag" +] # 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 +config :bonfire_data_identity, Bonfire.Data.Identity.Credential, hasher_module: hasher #### Sentinel Data Services # Search these apps/extensions for Pointable ecto schema definitions to index pointable_schema_extensions = [ - :bonfire, - :bonfire_data_access_control, - :bonfire_data_activity_pub, - :bonfire_data_identity, - :bonfire_data_social, - :bonfire_data_edges, - :bonfire_tag, - :bonfire_classify, - :bonfire_data_shared_users, - :bonfire_files, - :bonfire_quantify, - :bonfire_geolocate, - :bonfire_valueflows, - :bonfire_valueflows_observe, - ] + :bonfire, + :bonfire_data_access_control, + :bonfire_data_activity_pub, + :bonfire_data_identity, + :bonfire_data_social, + :bonfire_data_edges, + :bonfire_tag, + :bonfire_classify, + :bonfire_data_shared_users, + :bonfire_files, + :bonfire_quantify, + :bonfire_geolocate, + :bonfire_valueflows, + :bonfire_valueflows_observe +] + 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, - ] +context_and_queries_extensions = + pointable_schema_extensions ++ + [ + :bonfire_common, + :bonfire_me, + :bonfire_social + ] -extensions_with_config = context_and_queries_extensions ++ [ - :bonfire_boundaries, - :bonfire_federate_activitypub, - :bonfire_search, - :bonfire_mailer - ] +extensions_with_config = + context_and_queries_extensions ++ + [ + :bonfire_boundaries, + :bonfire_federate_activitypub, + :bonfire_search, + :bonfire_mailer + ] config :bonfire, :verb_names, verbs config :bonfire, :context_modules_search_path, context_and_queries_extensions @@ -56,31 +74,72 @@ config :bonfire, :config_modules_search_path, extensions_with_config config :bonfire_data_access_control, search_path: [ # :bonfire_me, - :bonfire_boundaries, + :bonfire_boundaries + # :bonfire_social, # :bonfire, ] #### Alias modules for readability -alias Pointers.{Pointer, Table} -alias Bonfire.Data.AccessControl.{ - Acl, Circle, Encircle, Controlled, InstanceAdmin, Grant, Verb, -} -alias Bonfire.Data.ActivityPub.{Actor, Peer, Peered} -alias Bonfire.Boundaries.{Permitted, Stereotyped} -alias Bonfire.Data.Edges.{Edge,EdgeTotal} -alias Bonfire.Data.Identity.{ - Account, Accounted, Caretaker, CareClosure, Character, Credential, Email, Named, Self, Settings, User, -} -alias Bonfire.Data.Social.{ - Activity, APActivity, Article, Block, Bookmark, Boost, Created, Feed, FeedPublish, - Flag, Follow, Like, Mention, Message, Post, PostContent, Profile, Replied, Request, -} +alias Pointers.Pointer +alias Pointers.Table + +alias Bonfire.Data.AccessControl.Acl +alias Bonfire.Data.AccessControl.Circle +alias Bonfire.Data.AccessControl.Encircle +alias Bonfire.Data.AccessControl.Controlled +alias Bonfire.Data.AccessControl.InstanceAdmin +alias Bonfire.Data.AccessControl.Grant +alias Bonfire.Data.AccessControl.Verb + +alias Bonfire.Data.ActivityPub.Actor +alias Bonfire.Data.ActivityPub.Peer +alias Bonfire.Data.ActivityPub.Peered + +alias Bonfire.Boundaries.Permitted +alias Bonfire.Boundaries.Stereotyped + +alias Bonfire.Data.Edges.Edge +alias Bonfire.Data.Edges.EdgeTotal + +alias Bonfire.Data.Identity.Account +alias Bonfire.Data.Identity.Accounted +alias Bonfire.Data.Identity.Caretaker +alias Bonfire.Data.Identity.CareClosure +alias Bonfire.Data.Identity.Character +alias Bonfire.Data.Identity.Credential +alias Bonfire.Data.Identity.Email +alias Bonfire.Data.Identity.Named +alias Bonfire.Data.Identity.Self +alias Bonfire.Data.Identity.Settings +alias Bonfire.Data.Identity.User + +alias Bonfire.Data.Social.Activity +alias Bonfire.Data.Social.APActivity +alias Bonfire.Data.Social.Article +alias Bonfire.Data.Social.Block +alias Bonfire.Data.Social.Bookmark +alias Bonfire.Data.Social.Boost +alias Bonfire.Data.Social.Created +alias Bonfire.Data.Social.Feed +alias Bonfire.Data.Social.FeedPublish +alias Bonfire.Data.Social.Flag +alias Bonfire.Data.Social.Follow +alias Bonfire.Data.Social.Like +alias Bonfire.Data.Social.Mention +alias Bonfire.Data.Social.Message +alias Bonfire.Data.Social.Post +alias Bonfire.Data.Social.PostContent +alias Bonfire.Data.Social.Profile +alias Bonfire.Data.Social.Replied +alias Bonfire.Data.Social.Request + alias Bonfire.Classify.Category alias Bonfire.Geolocate.Geolocation alias Bonfire.Files alias Bonfire.Files.Media -alias Bonfire.{Tag, Tag.Tagged} +alias Bonfire.Tag +alias Bonfire.Tag.Tagged #### Flexto Stitching @@ -96,172 +155,223 @@ common_assocs = %{ ### Mixins # A summary of an object that can appear in a feed. - activity: quote(do: has_one(:activity, unquote(Activity), unquote(mixin))), + activity: quote(do: has_one(:activity, unquote(Activity), unquote(mixin))), # ActivityPub actor information - actor: quote(do: has_one(:actor, unquote(Actor), unquote(mixin))), + actor: quote(do: has_one(:actor, unquote(Actor), unquote(mixin))), # Indicates the entity responsible for an activity. Sort of like creator, but transferrable. Used # during deletion - when the caretaker is deleted, all their stuff will be too. - caretaker: quote(do: has_one(:caretaker, unquote(Caretaker), unquote(mixin))), + caretaker: quote(do: has_one(:caretaker, unquote(Caretaker), unquote(mixin))), # A Character has a unique username and some feeds. - character: quote(do: has_one(:character, unquote(Character), unquote(mixin))), + character: quote(do: has_one(:character, unquote(Character), unquote(mixin))), # Indicates the creator of an object - created: quote(do: has_one(:created, unquote(Created), unquote(mixin))), + created: quote(do: has_one(:created, unquote(Created), unquote(mixin))), # Used for non-textual interactions such as likes and follows to indicate the other object. - edge: quote(do: has_one(:edge, unquote(Edge), unquote(mixin))), + edge: quote(do: has_one(:edge, unquote(Edge), unquote(mixin))), # Adds a name that can appear in the user interface for an object. e.g. for an ACL. - named: quote(do: has_one(:named, unquote(Named), unquote(mixin))), + named: quote(do: has_one(:named, unquote(Named), unquote(mixin))), # Information about the remote instance the object is from, if it is not local. - peered: quote(do: has_one(:peered, unquote(Peered), unquote(mixin))), + peered: quote(do: has_one(:peered, unquote(Peered), unquote(mixin))), # Information about the content of posts, e.g. a scrubbed html body post_content: quote(do: has_one(:post_content, unquote(PostContent), unquote(mixin))), # Information about a user or other object that they wish to make available - profile: quote(do: has_one(:profile, unquote(Profile), unquote(mixin))), + profile: quote(do: has_one(:profile, unquote(Profile), unquote(mixin))), # Threading information, for threaded discussions. - replied: quote(do: has_one(:replied, unquote(Replied), unquote(mixin))), + replied: quote(do: has_one(:replied, unquote(Replied), unquote(mixin))), # Information that allows the system to identify special system-managed ACLS. - stereotyped: quote(do: has_one(:stereotyped, unquote(Stereotyped), unquote(mixin))), - + stereotyped: quote(do: has_one(:stereotyped, unquote(Stereotyped), unquote(mixin))), ### Multimixins # Links to access control information for this object. - controlled: quote(do: has_many(:controlled, unquote(Controlled), unquote(mixin))), + 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))), + 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)), + 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))), + 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)), - + 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 # The objects which reply to this object. - direct_replies: quote(do: has_many(:direct_replies, unquote(Replied), foreign_key: :reply_to_id)), + direct_replies: + quote(do: has_many(:direct_replies, unquote(Replied), foreign_key: :reply_to_id)), # A recursive view of caretakers of caretakers of... used during deletion. - care_closure: quote(do: has_many(:care_closure, unquote(CareClosure), foreign_key: :branch_id)), + care_closure: quote(do: has_many(:care_closure, unquote(CareClosure), foreign_key: :branch_id)), # Retrieves activities where we are the object. e.g. if we are a # post or a user, this could turn up activities from likes or follows. - activities: quote(do: has_many(:activities, unquote(Activity), foreign_key: :object_id, references: :id)), + activities: + quote(do: has_many(:activities, unquote(Activity), foreign_key: :object_id, references: :id)), ### Stuff I'm not sure how to categorise yet # Used currently only for requesting to follow a user, but more general - request: quote(do: has_one(:request, unquote(Request), unquote(mixin))), + request: quote(do: has_one(:request, unquote(Request), unquote(mixin))) } # retrieves a list of quoted forms suitable for use with unquote_splicing common = fn names -> for name <- List.wrap(names) do with nil <- common_assocs[name], - do: raise(RuntimeError, message: "Expected a common association name, got #{inspect(name)}") + do: + raise(RuntimeError, message: "Expected a common association name, got #{inspect(name)}") end end -edge = common.([:controlled, :activities, :request, :created]) -edges = common.([:controlled, :activities, :request, :created, :caretaker, :activity, :feed_publishes]) +edge = common.([:controlled, :activities, :request, :created]) + +edges = + common.([:controlled, :activities, :request, :created, :caretaker, :activity, :feed_publishes]) # first up, pointers could have all the mixins we're using. TODO -pointer_mixins = common.([ - :activity, :actor, :caretaker, :character, :created, :edge, - :named, :peered, :post_content, :profile, :replied, :stereotyped -]) +pointer_mixins = + common.([ + :activity, + :actor, + :caretaker, + :character, + :created, + :edge, + :named, + :peered, + :post_content, + :profile, + :replied, + :stereotyped + ]) + config :pointers, Pointer, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - field :dummy, :any, virtual: true - # pointables - has_one :circle, unquote(Circle), foreign_key: :id - has_one :permitted, unquote(Permitted), foreign_key: :object_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 - has_one :category, unquote(Category), foreign_key: :id - has_one :geolocation, unquote(Geolocation), foreign_key: :id - # mixins - unquote_splicing(pointer_mixins) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media])) - # has_many - unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes])) + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + field(:dummy, :any, virtual: true) + # pointables + has_one(:circle, unquote(Circle), foreign_key: :id) + has_one(:permitted, unquote(Permitted), foreign_key: :object_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) + has_one(:category, unquote(Category), foreign_key: :id) + has_one(:geolocation, unquote(Geolocation), foreign_key: :id) + # mixins + unquote_splicing(pointer_mixins) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media])) + # has_many + unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes])) - ## special things - # these should go away in future and they should be populated by a single query. - 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] + ## special things + # these should go away in future and they should be populated by a single query. + has_one(:like_count, unquote(EdgeTotal), + foreign_key: :id, + references: :id, + where: [table_id: @like_ulid] + ) - end] + 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] + ) + end) config :pointers, Table, [] # now let's weave everything else together for convenience - # bonfire_data_access_control config :bonfire_data_access_control, Acl, - [code: quote do - # mixins - unquote_splicing(common.([:caretaker, :named, :stereotyped])) - # multimixins - # unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:caretaker, :named, :stereotyped]))) + + # multimixins + # unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Circle, - [code: quote do - # mixins - unquote_splicing(common.([:caretaker, :named, :stereotyped])) - # multimixins - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:caretaker, :named, :stereotyped])) + # multimixins + unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Controlled, [] config :bonfire_data_access_control, Encircle, - [code: quote do - has_one :peer, unquote(Peer), foreign_key: :id, references: :subject_id - end] + code: + (quote do + has_one(:peer, unquote(Peer), foreign_key: :id, references: :subject_id) + end) config :bonfire_data_access_control, Grant, - [code: quote do - # mixins - unquote_splicing(common.([:caretaker])) - # multimixins - # unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:caretaker]))) + + # multimixins + # unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Verb, [] config :bonfire_boundaries, Stereotyped, - [code: quote do - # mixins - unquote_splicing(common.([:named])) - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:named]))) + end) # bonfire_data_activity_pub config :bonfire_data_activity_pub, Actor, - [code: quote do - # hacks - belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - # mixins - unquote_splicing(common.([:peered])) - # multimixins - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # hacks + belongs_to(:character, unquote(Character), foreign_key: :id, define_field: false) + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + # mixins + unquote_splicing(common.([:peered])) + # multimixins + unquote_splicing(common.([:controlled])) + end) config :bonfire_data_activity_pub, Peer, [] config :bonfire_data_activity_pub, Peered, [] @@ -269,411 +379,564 @@ config :bonfire_data_activity_pub, Peered, [] # bonfire_data_identity config :bonfire_data_identity, Account, - [code: quote do - has_one :credential, unquote(Credential),foreign_key: :id - has_one :email, unquote(Email), foreign_key: :id - has_one :settings, unquote(Settings), foreign_key: :id - many_to_many :users, unquote(User), - join_through: Accounted, - join_keys: [account_id: :id, id: :id] - many_to_many :shared_users, unquote(User), # optional - join_through: "bonfire_data_shared_user_accounts", - join_keys: [account_id: :id, shared_user_id: :id] - end] + code: + (quote do + has_one(:credential, unquote(Credential), foreign_key: :id) + has_one(:email, unquote(Email), foreign_key: :id) + has_one(:settings, unquote(Settings), foreign_key: :id) + + many_to_many(:users, unquote(User), + join_through: Accounted, + join_keys: [account_id: :id, id: :id] + ) + + # optional + many_to_many(:shared_users, unquote(User), + join_through: "bonfire_data_shared_user_accounts", + join_keys: [account_id: :id, shared_user_id: :id] + ) + end) config :bonfire_data_identity, Accounted, - [code: quote do - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Caretaker, - [code: quote do - has_one :user, unquote(User), foreign_key: :id, references: :caretaker_id - # mixins - unquote_splicing(common.([:character, :profile])) - end] + code: + (quote do + has_one(:user, unquote(User), foreign_key: :id, references: :caretaker_id) + # mixins + unquote_splicing(common.([:character, :profile])) + end) config :bonfire_data_identity, Character, - [code: quote do - @follow_ulid "70110WTHE1EADER1EADER1EADE" - # mixins - unquote_splicing(common.([:actor, :peered, :profile])) - has_one :user, unquote(User), unquote(mixin) - has_one :feed, unquote(Feed), unquote(mixin) - has_many :followers, unquote(Follow), foreign_key: :following_id, references: :id - has_many :followed, unquote(Follow), foreign_key: :follower_id, references: :id - has_one :follow_count, unquote(EdgeTotal), foreign_key: :id, references: :id, - where: [table_id: @follow_ulid] - end] + code: + (quote do + @follow_ulid "70110WTHE1EADER1EADER1EADE" + # mixins + unquote_splicing(common.([:actor, :peered, :profile])) + has_one(:user, unquote(User), unquote(mixin)) + has_one(:feed, unquote(Feed), unquote(mixin)) + has_many(:followers, unquote(Follow), foreign_key: :following_id, references: :id) + has_many(:followed, unquote(Follow), foreign_key: :follower_id, references: :id) + + has_one(:follow_count, unquote(EdgeTotal), + foreign_key: :id, + references: :id, + where: [table_id: @follow_ulid] + ) + end) config :bonfire_data_identity, Credential, - [code: quote do - belongs_to :account, unquote(Account), foreign_key: :id, define_field: false - end] + code: + (quote do + belongs_to(:account, unquote(Account), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Email, - [must_confirm: true, - code: quote do - belongs_to :account, unquote(Account), foreign_key: :id, define_field: false - end] + must_confirm: true, + code: + (quote do + belongs_to(:account, unquote(Account), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Self, [] config :bonfire_data_identity, User, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - # mixins - has_one :accounted, unquote(Accounted), foreign_key: :id - has_one :instance_admin, unquote(InstanceAdmin), foreign_key: :id, on_replace: :update - has_one :self, unquote(Self), foreign_key: :id - has_one :shared_user, unquote(Bonfire.Data.SharedUser), foreign_key: :id - has_one :settings, unquote(Settings), foreign_key: :id - unquote_splicing(common.([:actor, :character, :created, :peered, :profile])) - # multimixins - unquote_splicing(common.([:controlled])) - # manies - has_many :encircles, unquote(Encircle), foreign_key: :subject_id - has_many :creations, through: [:created, :pointer] # todo: stop through - has_many :posts, through: [:created, :post] # todo: stop through - has_many :followers, unquote(Edge), foreign_key: :object_id, references: :id, where: [table_id: @follow_ulid] - has_many :followed, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @follow_ulid] - has_many :user_activities, unquote(Activity), foreign_key: :subject_id, references: :id - has_many :boost_activities, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @boost_ulid] - has_many :like_activities, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @like_ulid] - many_to_many :caretaker_accounts, unquote(Account), - 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 # enable if using Geolocate extension - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + # mixins + has_one(:accounted, unquote(Accounted), foreign_key: :id) + has_one(:instance_admin, unquote(InstanceAdmin), foreign_key: :id, on_replace: :update) + has_one(:self, unquote(Self), foreign_key: :id) + has_one(:shared_user, unquote(Bonfire.Data.SharedUser), foreign_key: :id) + has_one(:settings, unquote(Settings), foreign_key: :id) + unquote_splicing(common.([:actor, :character, :created, :peered, :profile])) + # multimixins + unquote_splicing(common.([:controlled])) + # manies + has_many(:encircles, unquote(Encircle), foreign_key: :subject_id) + # todo: stop through + has_many(:creations, through: [:created, :pointer]) + # todo: stop through + has_many(:posts, through: [:created, :post]) + + has_many(:followers, unquote(Edge), + foreign_key: :object_id, + references: :id, + where: [table_id: @follow_ulid] + ) + + has_many(:followed, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @follow_ulid] + ) + + has_many(:user_activities, unquote(Activity), foreign_key: :subject_id, references: :id) + + has_many(:boost_activities, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @boost_ulid] + ) + + has_many(:like_activities, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @like_ulid] + ) + + many_to_many(:caretaker_accounts, unquote(Account), + 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 # enable if using Geolocate extension + end) ### bonfire_data_social config :bonfire_data_social, Activity, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - has_many :feed_publishes, unquote(FeedPublish), unquote(mixin) - has_one :seen, unquote(Edge), foreign_key: :id, references: :id - # ugly workaround needed for certain queries (TODO: check if still needed) - has_one :activity, unquote(Activity), foreign_key: :id, references: :id - # 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] - has_many :controlled, unquote(Controlled), foreign_key: :id, references: :object_id - has_many :tagged, unquote(Tagged), foreign_key: :id, references: :object_id - many_to_many :tags, unquote(Pointer), - join_through: unquote(Tagged), - 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] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + has_many(:feed_publishes, unquote(FeedPublish), unquote(mixin)) + has_one(:seen, unquote(Edge), foreign_key: :id, references: :id) + # ugly workaround needed for certain queries (TODO: check if still needed) + has_one(:activity, unquote(Activity), foreign_key: :id, references: :id) + # 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] + ) + + has_many(:controlled, unquote(Controlled), foreign_key: :id, references: :object_id) + has_many(:tagged, unquote(Tagged), foreign_key: :id, references: :object_id) + + many_to_many(:tags, unquote(Pointer), + join_through: unquote(Tagged), + 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, - [code: quote do - unquote_splicing(common.([:activity, :caretaker])) - end] + code: + (quote do + (unquote_splicing(common.([:activity, :caretaker]))) + end) config :bonfire_data_edges, Edge, - [code: quote do - unquote_splicing(edge) - # TODO: requires composite foreign keys: - # has_one :activity, unquote(Activity), - # foreign_key: [:table_id, :object_id], references: [:table_id, :object_id] - end] + code: + (quote do + (unquote_splicing(edge)) + + # TODO: requires composite foreign keys: + # has_one :activity, unquote(Activity), + # foreign_key: [:table_id, :object_id], references: [:table_id, :object_id] + end) config :bonfire_data_social, Feed, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker])) - # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - # belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:activity, :caretaker]))) + + # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false + # belongs_to :user, unquote(User), foreign_key: :id, define_field: false + end) config :bonfire_data_social, FeedPublish, - [code: quote do - field :dummy, :any, virtual: true - has_one :activity, unquote(Activity), foreign_key: :object_id, references: :id - # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - # belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + field(:dummy, :any, virtual: true) + has_one(:activity, unquote(Activity), foreign_key: :object_id, references: :id) + # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false + # belongs_to :user, unquote(User), foreign_key: :id, define_field: false + end) config :bonfire_data_social, Follow, - [code: quote do - unquote_splicing(edges) - end] - # 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}] + code: + (quote do + (unquote_splicing(edges)) + end) + +# 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}] config :bonfire_data_social, Block, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Boost, - [code: quote do - unquote_splicing(edges) - end] - # has_one: [activity: {Activity, foreign_key: :object_id, references: :boosted_id}] # requires an ON clause + code: + (quote do + (unquote_splicing(edges)) + end) + +# has_one: [activity: {Activity, foreign_key: :object_id, references: :boosted_id}] # requires an ON clause config :bonfire_data_social, Like, - [code: quote do - unquote_splicing(edges) - end] - # has_one: [activity: {Activity, foreign_key: :object_id, references: :liked_id}] # requires an ON clause + code: + (quote do + (unquote_splicing(edges)) + end) + +# has_one: [activity: {Activity, foreign_key: :object_id, references: :liked_id}] # requires an ON clause config :bonfire_data_social, Flag, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Request, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Bookmark, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Message, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - # mixins - unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied])) - # multimixins - 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] - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + # mixins + unquote_splicing( + common.([:activity, :caretaker, :created, :peered, :post_content, :replied]) + ) + + # multimixins + 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] + ) + end) config :bonfire_data_social, Mention, [] config :bonfire_data_social, Named, [] config :bonfire_data_social, Post, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - # mixins - unquote_splicing(common.([:activities, :activity, :caretaker, :created, :peered, :post_content, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - # special - has_one :permitted, unquote(Permitted), foreign_key: :object_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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause - # 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 :like_count, unquote(EdgeTotal), - 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] - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + # mixins + unquote_splicing( + common.([:activities, :activity, :caretaker, :created, :peered, :post_content, :replied]) + ) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + # special + has_one(:permitted, unquote(Permitted), foreign_key: :object_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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause + # 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(:like_count, unquote(EdgeTotal), + 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] + ) + end) config :bonfire_data_social, PostContent, - [code: quote do - # mixins - unquote_splicing(common.([:created])) - # multimixins - unquote_splicing(common.([:controlled])) - # virtuals for changesets - field :hashtags, {:array, :any}, virtual: true - field :mentions, {:array, :any}, virtual: true - end] + code: + (quote do + # mixins + unquote_splicing(common.([:created])) + # multimixins + unquote_splicing(common.([:controlled])) + # virtuals for changesets + field(:hashtags, {:array, :any}, virtual: true) + field(:mentions, {:array, :any}, virtual: true) + end) config :bonfire_data_social, Replied, - [code: quote do - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) + code: + (quote do + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) - @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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id - 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 - 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] + @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_one(:activity, unquote(Activity), foreign_key: :object_id, references: :id) + # used in changesets + field(:replying_to, :map, virtual: true) + 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 + ) + + 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) 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 - # mixins - shouldn't be here really - unquote_splicing(common.([:peered])) - has_one :post, unquote(Post), unquote(mixin) # huh? - end] + 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 + ) + + # mixins - shouldn't be here really + unquote_splicing(common.([:peered])) + # huh? + has_one(:post, unquote(Post), unquote(mixin)) + end) config :bonfire_data_social, Profile, - [code: quote do - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) + end) ######### other extensions config :bonfire_files, Media, - [code: quote do - field :url, :string, virtual: true - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:url, :string, virtual: true) + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) + end) config :bonfire_classify, Category, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :created, :actor, :peered, :profile, :character])) # TODO :caretaker - # multimixins - unquote_splicing(common.([:controlled, :feed_publishes])) + code: + (quote do + # mixins + # TODO :caretaker + unquote_splicing(common.([:activity, :created, :actor, :peered, :profile, :character])) + # multimixins + unquote_splicing(common.([:controlled, :feed_publishes])) - # add references of tagged objects to any Category - many_to_many :tags, unquote(Pointer), - join_through: unquote(Tagged), - unique: true, - join_keys: [tag_id: :id, id: :id], - on_replace: :delete - end] + # add references of tagged objects to any Category + many_to_many(:tags, unquote(Pointer), + join_through: unquote(Tagged), + unique: true, + join_keys: [tag_id: :id, id: :id], + 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] + 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, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + # TODO :caretaker + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.EconomicResource, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Knowledge.ResourceSpecification, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Process, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Knowledge.ProcessSpecification, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Planning.Intent, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Planning.Commitment, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Proposal, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows_observe, ValueFlows.Observe.Observation, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) diff --git a/flavours/haha/config/bonfire_fail.exs b/flavours/haha/config/bonfire_fail.exs index b4a66cb338..7a712ed231 100644 --- a/flavours/haha/config/bonfire_fail.exs +++ b/flavours/haha/config/bonfire_fail.exs @@ -11,9 +11,11 @@ config :bonfire_fail, bad_header: {400, "Bad request: malformed header."}, no_access: {403, "This site is by invitation only."}, token_expired: {403, "This link or token has expired, please request a fresh one."}, - already_claimed: {403, "This link or token was already used, please request a fresh one if necessary."}, + already_claimed: + {403, "This link or token was already used, please request a fresh one if necessary."}, token_not_found: {403, "This token was not found, please request a fresh one."}, - user_disabled: {403, "This user account is disabled. Please contact the instance administrator."}, + user_disabled: + {403, "This user account is disabled. Please contact the instance administrator."}, email_not_confirmed: {403, "Please confirm your email address first."}, unknown_resource: {400, "Unknown resource."}, invalid_argument: {400, "Invalid arguments passed."}, diff --git a/flavours/haha/config/bonfire_federate_activitypub.exs b/flavours/haha/config/bonfire_federate_activitypub.exs index 0da42fe987..5fb32657de 100644 --- a/flavours/haha/config/bonfire_federate_activitypub.exs +++ b/flavours/haha/config/bonfire_federate_activitypub.exs @@ -10,12 +10,13 @@ config :bonfire, :bonfire_me, :bonfire_social, :bonfire_valueflows - ], - log_federation: true, # enable/disable logging of federation logic + ], + # enable/disable logging of federation logic + log_federation: true, federation_fallback_module: Bonfire.Social.APActivities config :bonfire, actor_AP_types: actor_types # config :bonfire, Bonfire.Instance, - # hostname: hostname, - # description: desc +# hostname: hostname, +# description: desc diff --git a/flavours/haha/config/bonfire_files.exs b/flavours/haha/config/bonfire_files.exs index 7d59d69d8e..004256aaeb 100644 --- a/flavours/haha/config/bonfire_files.exs +++ b/flavours/haha/config/bonfire_files.exs @@ -4,48 +4,53 @@ import Config # see https://hexdocs.pm/waffle/Waffle.html#module-setup-a-storage-provider config :waffle, storage: Waffle.Storage.Local, - asset_host: "/" # or {:system, "ASSET_HOST"} + # or {:system, "ASSET_HOST"} + 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", -] +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_files, image_media_types: image_media_types config :bonfire_files, all_allowed_media_types: all_allowed_media_types config :bonfire_files, Bonfire.Files.IconUploader, allowed_media_types: image_media_types config :bonfire_files, Bonfire.Files.ImageUploader, allowed_media_types: image_media_types -config :bonfire_files, Bonfire.Files.DocumentUploader, allowed_media_types: all_allowed_media_types + +config :bonfire_files, Bonfire.Files.DocumentUploader, + allowed_media_types: all_allowed_media_types diff --git a/flavours/haha/config/bonfire_flavour_haha.exs b/flavours/haha/config/bonfire_flavour_haha.exs index 4a0c581905..30dd7e2725 100644 --- a/flavours/haha/config/bonfire_flavour_haha.exs +++ b/flavours/haha/config/bonfire_flavour_haha.exs @@ -2,4 +2,5 @@ import Config config :bonfire_me, validate_name_min: 1, - validate_name_max: 250 # needed for taxonomy + # needed for taxonomy + validate_name_max: 250 diff --git a/flavours/haha/config/bonfire_search.exs b/flavours/haha/config/bonfire_search.exs index a5c6025899..7de227c923 100644 --- a/flavours/haha/config/bonfire_search.exs +++ b/flavours/haha/config/bonfire_search.exs @@ -3,8 +3,10 @@ import Config config :bonfire_search, disable_indexing: System.get_env("SEARCH_INDEXING_DISABLED", "false"), adapter: Bonfire.Search.Meili, - instance: System.get_env("SEARCH_MEILI_INSTANCE", "http://search:7700"), # protocol, hostname and port - api_key: System.get_env("MEILI_MASTER_KEY", "make-sure-to-change-me") # secret key + # protocol, hostname and port + instance: System.get_env("SEARCH_MEILI_INSTANCE", "http://search:7700"), + # secret key + api_key: System.get_env("MEILI_MASTER_KEY", "make-sure-to-change-me") # for use by API client config :tesla, adapter: Tesla.Adapter.Hackney diff --git a/flavours/haha/config/bonfire_ui.exs b/flavours/haha/config/bonfire_ui.exs index 91ced7235c..2286df77c6 100644 --- a/flavours/haha/config/bonfire_ui.exs +++ b/flavours/haha/config/bonfire_ui.exs @@ -1,49 +1,47 @@ import Config - config :bonfire, :ui, - theme: [ - instance_name: "HAHA Academy", - instance_icon: "/images/bonfire-icon.png", - instance_image: "https://haha.academy/images/wheel.png", - instance_description: "Community roadmaps for learning every branch of human knowledge" - ], - sidebar_components: [ - {Bonfire.UI.Social.SidebarNavigationLive, []}, - ], - rich_text_editor: Bonfire.Editor.Quill, - smart_input: [ - post: true, - cw: true, - summary: true - ], - profile: [ - sections: [ - timeline: Bonfire.UI.Social.ProfileTimelineLive, - # private: Bonfire.UI.Social.MessageThreadsLive, - posts: Bonfire.UI.Social.ProfilePostsLive, - boosts: Bonfire.UI.Social.ProfileBoostsLive, - followers: Bonfire.UI.Social.ProfileFollowsLive, - followed: Bonfire.UI.Social.ProfileFollowsLive, - ], - navigation: [ - timeline: "timeline", - posts: "posts", - boosts: "boosts", - # private: "private", - ], - widgets: [ - ], - ], - smart_input_activities: [ - # offer: "Publish an offer", - # need: "Publish a need", - # transfer_resource: "Transfer a resource", - # produce_resource: "Add a resource", - # intent: "Indicate an itent", - # economic_event: "Record an economic event", - # process: "Define a process" - ], - smart_input_components: [ - post: Bonfire.UI.Social.WritePostContentLive, - ] + theme: [ + instance_name: "HAHA Academy", + instance_icon: "/images/bonfire-icon.png", + instance_image: "https://haha.academy/images/wheel.png", + instance_description: "Community roadmaps for learning every branch of human knowledge" + ], + sidebar_components: [ + {Bonfire.UI.Social.SidebarNavigationLive, []} + ], + rich_text_editor: Bonfire.Editor.Quill, + smart_input: [ + post: true, + cw: true, + summary: true + ], + profile: [ + sections: [ + timeline: Bonfire.UI.Social.ProfileTimelineLive, + # private: Bonfire.UI.Social.MessageThreadsLive, + posts: Bonfire.UI.Social.ProfilePostsLive, + boosts: Bonfire.UI.Social.ProfileBoostsLive, + followers: Bonfire.UI.Social.ProfileFollowsLive, + followed: Bonfire.UI.Social.ProfileFollowsLive + ], + navigation: [ + timeline: "timeline", + posts: "posts", + boosts: "boosts" + # private: "private", + ], + widgets: [] + ], + smart_input_activities: [ + # offer: "Publish an offer", + # need: "Publish a need", + # transfer_resource: "Transfer a resource", + # produce_resource: "Add a resource", + # intent: "Indicate an itent", + # economic_event: "Record an economic event", + # process: "Define a process" + ], + smart_input_components: [ + post: Bonfire.UI.Social.WritePostContentLive + ] diff --git a/flavours/haha/config/config.exs b/flavours/haha/config/config.exs index fc1c6b857b..841c2978aa 100644 --- a/flavours/haha/config/config.exs +++ b/flavours/haha/config/config.exs @@ -2,7 +2,7 @@ import Config default_flavour = "classic" flavour = System.get_env("FLAVOUR", default_flavour) -flavour_path = System.get_env("FLAVOUR_PATH", "flavours/"<>flavour) +flavour_path = System.get_env("FLAVOUR_PATH", "flavours/" <> flavour) #### Basic configuration @@ -33,7 +33,8 @@ config :bonfire, config :bonfire, Bonfire.Web.Endpoint, url: [host: "localhost"], http: [ - port: String.to_integer(System.get_env("SERVER_PORT", "4000")), # this gets overriden in runtime.exs + # this gets overriden in runtime.exs + port: String.to_integer(System.get_env("SERVER_PORT", "4000")), transport_options: [socket_opts: [:inet6]] ], render_errors: [view: Bonfire.UI.Common.ErrorView, accepts: ~w(html json), layout: false], @@ -43,6 +44,7 @@ config :phoenix, :json_library, Jason config :phoenix_gon, :json_library, Jason config :bonfire, :ecto_repos, [Bonfire.Common.Repo] + config :bonfire, Bonfire.Common.Repo, types: Bonfire.Geolocate.PostgresTypes, priv: flavour_path <> "/repo" @@ -73,10 +75,9 @@ config :mime, :types, %{ config :sentry, dsn: "this-will-be-overriden-by-a-secure-string-in-runtime.exs", - environment_name: Mix.env, + environment_name: Mix.env(), included_environments: [:prod] - # include config for all used Bonfire extensions for config <- "bonfire_*.exs" |> Path.expand(__DIR__) |> Path.wildcard() do # IO.inspect(include_config: config) @@ -85,6 +86,5 @@ end import_config "activity_pub.exs" - # finally, append/override config based on env, which will override any config set above (including from imported files) import_config "#{config_env()}.exs" diff --git a/flavours/haha/config/dev.exs b/flavours/haha/config/dev.exs index 4618890daa..d570c8ecb9 100644 --- a/flavours/haha/config/dev.exs +++ b/flavours/haha/config/dev.exs @@ -10,10 +10,14 @@ path_dep_dirs = |> Enum.map(&(Keyword.fetch!(elem(&1, 1), :path) <> "/lib")) config :phoenix_live_reload, - dirs: path_dep_dirs ++ ["lib/"] # watch the app's lib/ dir + the dep/lib/ dir of every locally-cloned dep + # watch the app's lib/ dir + the dep/lib/ dir of every locally-cloned dep + dirs: path_dep_dirs ++ ["lib/"] -path_dep_patterns = path_dep_dirs |> Enum.map(&(String.slice(&1, 2..1000) <>".*ex")) # to include cloned code in patterns -path_dep_patterns = path_dep_patterns ++ path_dep_dirs |> Enum.map(&(String.slice(&1, 2..1000) <>".*sface")) # Surface views +# to include cloned code in patterns +path_dep_patterns = Enum.map(path_dep_dirs, &(String.slice(&1, 2..1000) <> ".*ex")) +# Surface views +path_dep_patterns = + (path_dep_patterns ++ path_dep_dirs) |> Enum.map(&(String.slice(&1, 2..1000) <> ".*sface")) # Watch static and templates for browser reloading. config :bonfire, Bonfire.Web.Endpoint, @@ -29,31 +33,34 @@ config :bonfire, Bonfire.Web.Endpoint, yarn: [ "watch.css", cd: Path.expand("assets", File.cwd!()) - ], + ] + # yarn: [ # "watch.assets", # cd: Path.expand("assets", File.cwd!()) # ] ], live_reload: [ - patterns: [ - # ~r"^priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", - # ~r"^priv/gettext/.*(po)$", - # ~r"^web/(live|views)/.*ex$", - # ~r"^lib/.*_live\.ex$", - # ~r".*leex$", - ~r"lib/.*ex$", - ~r".*sface$", - ~r"priv/catalogue/.*(ex)$", - ] ++ path_dep_patterns - ] + patterns: + [ + # ~r"^priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", + # ~r"^priv/gettext/.*(po)$", + # ~r"^web/(live|views)/.*ex$", + # ~r"^lib/.*_live\.ex$", + # ~r".*leex$", + # defp elixirc_paths(:dev), do: ["lib"] ++ catalogues() -# defp elixirc_paths(:dev), do: ["lib"] ++ catalogues() + ~r"lib/.*ex$", + ~r".*sface$", + ~r"priv/catalogue/.*(ex)$" + ] ++ path_dep_patterns + ] config :logger, :console, level: :debug, # truncate: :infinity, - format: "[$level] $message\n" # Do not include metadata or timestamps + # Do not include metadata or timestamps + format: "[$level] $message\n" config :phoenix, :stacktrace_depth, 30 diff --git a/flavours/haha/config/prod.exs b/flavours/haha/config/prod.exs index 8a3cad9d37..dea572d579 100644 --- a/flavours/haha/config/prod.exs +++ b/flavours/haha/config/prod.exs @@ -1,13 +1,11 @@ import Config - # We include the path to a cache manifest # containing the digested version of static files. This # manifest is generated by the `mix phx.digest` task, # which you should run after static files are built and # before starting your production server. -config :bonfire, Bonfire.Web.Endpoint, - cache_static_manifest: "priv/static/cache_manifest.json" +config :bonfire, Bonfire.Web.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json" config :logger, backends: [:console, Sentry.LoggerBackend] @@ -18,4 +16,5 @@ config :logger, level: :info config :bonfire, Bonfire.Web.Endpoint, server: true config :bonfire, Bonfire.Common.Repo, - priv: "priv/repo" # in releases migrations are not in a flavour-specific directory + # in releases migrations are not in a flavour-specific directory + priv: "priv/repo" diff --git a/flavours/haha/config/runtime.exs b/flavours/haha/config/runtime.exs index 55b59a10ec..7aa902e020 100644 --- a/flavours/haha/config/runtime.exs +++ b/flavours/haha/config/runtime.exs @@ -13,16 +13,15 @@ Bonfire.Common.Config.LoadExtensionsConfig.load_configs() ## System.get_env("DATABASE_URL") || System.get_env("POSTGRES_PASSWORD") || System.get_env("CI") || - raise """ - Environment variables for database are missing. - For example: DATABASE_URL=ecto://USER:PASS@HOST/DATABASE - You can also set POSTGRES_PASSWORD (required), - and POSTGRES_USER (default: postgres) and POSTGRES_HOST (default: localhost) - """ + raise """ + Environment variables for database are missing. + For example: DATABASE_URL=ecto://USER:PASS@HOST/DATABASE + You can also set POSTGRES_PASSWORD (required), + and POSTGRES_USER (default: postgres) and POSTGRES_HOST (default: localhost) + """ if System.get_env("DATABASE_URL") do - config :bonfire, Bonfire.Common.Repo, - url: System.get_env("DATABASE_URL") + config :bonfire, Bonfire.Common.Repo, url: System.get_env("DATABASE_URL") else config :bonfire, Bonfire.Common.Repo, # ssl: true, @@ -38,12 +37,14 @@ secret_key_base = You can generate one by calling: mix phx.gen.secret """ -signing_salt = System.get_env("SIGNING_SALT") || System.get_env("CI") || +signing_salt = + System.get_env("SIGNING_SALT") || System.get_env("CI") || raise """ environment variable SIGNING_SALT is missing. """ -encryption_salt = System.get_env("ENCRYPTION_SALT") || System.get_env("CI") || +encryption_salt = + System.get_env("ENCRYPTION_SALT") || System.get_env("CI") || raise """ environment variable ENCRYPTION_SALT is missing. """ @@ -57,7 +58,10 @@ config :bonfire, encryption_salt: encryption_salt, signing_salt: signing_salt -start_server? = if config_env() == :test, do: System.get_env("START_SERVER", "true"), else: System.get_env("START_SERVER", "true") +start_server? = + if config_env() == :test, + do: System.get_env("START_SERVER", "true"), + else: System.get_env("START_SERVER", "true") config :bonfire, Bonfire.Web.Endpoint, server: String.to_existing_atom(start_server?), @@ -72,9 +76,7 @@ config :bonfire, Bonfire.Web.Endpoint, live_view: [signing_salt: signing_salt] if System.get_env("SENTRY_DSN") do - IO.puts( - "Note: errors will be reported to Sentry." - ) + IO.puts("Note: errors will be reported to Sentry.") config :sentry, dsn: System.get_env("SENTRY_DSN") @@ -86,22 +88,20 @@ end # start prod-only config if config_env() == :prod do - config :bonfire, Bonfire.Common.Repo, # ssl: true, database: System.get_env("POSTGRES_DB", "bonfire"), pool_size: String.to_integer(System.get_env("POOL_SIZE", "10")), - log: String.to_atom(System.get_env("DB_QUERIES_LOG_LEVEL", "false")) # Note: keep this disabled if using ecto_dev_logger or EctoSparkles.Log instead # - -end # prod only config + # Note: keep this disabled if using ecto_dev_logger or EctoSparkles.Log instead # + log: String.to_atom(System.get_env("DB_QUERIES_LOG_LEVEL", "false")) +end +# prod only config # start prod and dev only config if config_env() != :test do - config :bonfire, Bonfire.Common.Repo, slow_query_ms: String.to_integer(System.get_env("SLOW_QUERY_MS", "100")) - end ## bonfire_livebook diff --git a/flavours/haha/config/test.exs b/flavours/haha/config/test.exs index e20367afd9..dfe321a872 100644 --- a/flavours/haha/config/test.exs +++ b/flavours/haha/config/test.exs @@ -15,7 +15,6 @@ config :bonfire_search, config :logger, level: :warn # config :logger, level: :notice - # Configure your database db = "bonfire_test#{System.get_env("MIX_TEST_PARTITION")}" # @@ -46,6 +45,7 @@ config :mix_test_interactive, clear: true config :paginator, ecto_repos: [Bonfire.Common.Repo] + config :paginator, Paginator.Repo, pool: Ecto.Adapters.SQL.Sandbox, username: System.get_env("POSTGRES_USER", "postgres"), diff --git a/flavours/haha/repo/migrations/20200523081010_citext.exs b/flavours/haha/repo/migrations/20200523081010_citext.exs index bad3ec5df0..8de33932f7 100644 --- a/flavours/haha/repo/migrations/20200523081010_citext.exs +++ b/flavours/haha/repo/migrations/20200523081010_citext.exs @@ -2,11 +2,10 @@ defmodule Bonfire.Repo.Migrations.HelloWorld do use Ecto.Migration def up do - execute "CREATE EXTENSION IF NOT EXISTS \"citext\"" + execute("CREATE EXTENSION IF NOT EXISTS \"citext\"") end def down do - execute "DROP EXTENSION IF EXISTS \"citext\"" + execute("DROP EXTENSION IF EXISTS \"citext\"") end - end diff --git a/flavours/haha/repo/migrations/20200523081012_init_pointers.exs b/flavours/haha/repo/migrations/20200523081012_init_pointers.exs index 7fa1ef977d..4d75827e8e 100644 --- a/flavours/haha/repo/migrations/20200523081012_init_pointers.exs +++ b/flavours/haha/repo/migrations/20200523081012_init_pointers.exs @@ -6,9 +6,9 @@ defmodule Bonfire.Repo.Migrations.InitPointers do init_pointers_ulid_extra() init_pointers() end + def down do init_pointers_ulid_extra() init_pointers() end - end diff --git a/flavours/haha/repo/migrations/20200523081014_init_edges.exs b/flavours/haha/repo/migrations/20200523081014_init_edges.exs index 523e0e8258..6a9051db55 100644 --- a/flavours/haha/repo/migrations/20200523081014_init_edges.exs +++ b/flavours/haha/repo/migrations/20200523081014_init_edges.exs @@ -2,7 +2,6 @@ defmodule Bonfire.Repo.Migrations.InitEdges do use Ecto.Migration alias Bonfire.Data.Edges.Migration - def up do Migration.up() end @@ -10,5 +9,4 @@ defmodule Bonfire.Repo.Migrations.InitEdges do def down do Migration.down() end - end diff --git a/flavours/haha/repo/migrations/20200818094943_import_ap.exs b/flavours/haha/repo/migrations/20200818094943_import_ap.exs index 38cea36742..bfdc4815e6 100644 --- a/flavours/haha/repo/migrations/20200818094943_import_ap.exs +++ b/flavours/haha/repo/migrations/20200818094943_import_ap.exs @@ -6,5 +6,4 @@ defmodule Bonfire.Federate.ActivityPub.Repo.Migrations.ImportMe do def up, do: migrate_activity_pub def down, do: migrate_activity_pub - end diff --git a/flavours/haha/repo/migrations/20200820094941_import_boundaries.exs b/flavours/haha/repo/migrations/20200820094941_import_boundaries.exs index 21ef29e5c9..51908b3a52 100644 --- a/flavours/haha/repo/migrations/20200820094941_import_boundaries.exs +++ b/flavours/haha/repo/migrations/20200820094941_import_boundaries.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.ImportBoundaries do def up, do: migrate_boundaries() def down, do: migrate_boundaries() - end diff --git a/flavours/haha/repo/migrations/20200828094944_import_me.exs b/flavours/haha/repo/migrations/20200828094944_import_me.exs index 5b9e9a8c3f..97ac819380 100644 --- a/flavours/haha/repo/migrations/20200828094944_import_me.exs +++ b/flavours/haha/repo/migrations/20200828094944_import_me.exs @@ -9,5 +9,4 @@ defmodule Bonfire.Repo.Migrations.ImportMe do end def down, do: migrate_me() - end diff --git a/flavours/haha/repo/migrations/20200828094945_import_social.exs b/flavours/haha/repo/migrations/20200828094945_import_social.exs index 3f8c6db408..2ee83ee871 100644 --- a/flavours/haha/repo/migrations/20200828094945_import_social.exs +++ b/flavours/haha/repo/migrations/20200828094945_import_social.exs @@ -5,10 +5,8 @@ defmodule Bonfire.Social.Repo.Migrations.ImportSocial do import Pointers.Migration def up do - migrate_social() - end - def down, do: migrate_social() + def down, do: migrate_social() end diff --git a/flavours/haha/repo/migrations/20200829004946_boundaries_fixtures.exs b/flavours/haha/repo/migrations/20200829004946_boundaries_fixtures.exs index 87fd61baf6..7a8eb123c7 100644 --- a/flavours/haha/repo/migrations/20200829004946_boundaries_fixtures.exs +++ b/flavours/haha/repo/migrations/20200829004946_boundaries_fixtures.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.BoundariesFixtures do def up, do: Bonfire.Boundaries.Fixtures.insert() def down, do: nil - end diff --git a/flavours/haha/repo/migrations/20210402105128_ap_test_table.exs b/flavours/haha/repo/migrations/20210402105128_ap_test_table.exs index 929b6324f6..ecc4b56355 100644 --- a/flavours/haha/repo/migrations/20210402105128_ap_test_table.exs +++ b/flavours/haha/repo/migrations/20210402105128_ap_test_table.exs @@ -4,12 +4,12 @@ defmodule ActivityPub.Repo.Migrations.APTestTable do def change do # This table only exists for test purposes create table("local_actor", primary_key: false) do - add :id, :uuid, primary_key: true - add :username, :citext - add :data, :map - add :local, :boolean - add :keys, :text - add :followers, {:array, :string} + add(:id, :uuid, primary_key: true) + add(:username, :citext) + add(:data, :map) + add(:local, :boolean) + add(:keys, :text) + add(:followers, {:array, :string}) end end end diff --git a/flavours/haha/repo/migrations/20210410094945_profile_images.exs b/flavours/haha/repo/migrations/20210410094945_profile_images.exs index c0a07043eb..8294d2b957 100644 --- a/flavours/haha/repo/migrations/20210410094945_profile_images.exs +++ b/flavours/haha/repo/migrations/20210410094945_profile_images.exs @@ -4,15 +4,19 @@ defmodule Bonfire.Social.Repo.Migrations.ProfileImages do import Pointers.Migration def up do + drop_if_exists( + constraint("bonfire_data_social_profile", "bonfire_data_social_profile_icon_id_fkey") + ) - drop_if_exists constraint "bonfire_data_social_profile", "bonfire_data_social_profile_icon_id_fkey" - drop_if_exists constraint "bonfire_data_social_profile", "bonfire_data_social_profile_image_id_fkey" + drop_if_exists( + constraint("bonfire_data_social_profile", "bonfire_data_social_profile_image_id_fkey") + ) alter table("bonfire_data_social_profile") do - Ecto.Migration.add_if_not_exists :icon_id, strong_pointer(Bonfire.Files.Media) - Ecto.Migration.add_if_not_exists :image_id, strong_pointer(Bonfire.Files.Media) + Ecto.Migration.add_if_not_exists(:icon_id, strong_pointer(Bonfire.Files.Media)) + Ecto.Migration.add_if_not_exists(:image_id, strong_pointer(Bonfire.Files.Media)) end end - def down, do: nil + def down, do: nil end diff --git a/flavours/haha/repo/migrations/20210412094946_fp.exs b/flavours/haha/repo/migrations/20210412094946_fp.exs index 4e13f8b533..1966abd46a 100644 --- a/flavours/haha/repo/migrations/20210412094946_fp.exs +++ b/flavours/haha/repo/migrations/20210412094946_fp.exs @@ -1,7 +1,6 @@ defmodule Bonfire.Repo.Migrations.FP do use Ecto.Migration - def up do execute("create or replace function column_exists(ptable text, pcolumn text, pschema text default 'public') @@ -18,7 +17,8 @@ defmodule Bonfire.Repo.Migrations.FP do ); $body$;") - execute("CREATE OR REPLACE FUNCTION rename_column_if_exists(ptable TEXT, pcolumn TEXT, new_name TEXT) + execute( + "CREATE OR REPLACE FUNCTION rename_column_if_exists(ptable TEXT, pcolumn TEXT, new_name TEXT) RETURNS VOID AS $BODY$ BEGIN -- Rename the column if it exists. @@ -27,14 +27,15 @@ defmodule Bonfire.Repo.Migrations.FP do ptable, pcolumn, new_name); END IF; END$BODY$ - LANGUAGE plpgsql VOLATILE;") + LANGUAGE plpgsql VOLATILE;" + ) flush() - execute("SELECT rename_column_if_exists('bonfire_data_social_feed_publish', 'object_id', 'activity_id') ") - + execute( + "SELECT rename_column_if_exists('bonfire_data_social_feed_publish', 'object_id', 'activity_id') " + ) end def down, do: nil - end diff --git a/flavours/haha/repo/migrations/20210618094945_peered_uri.exs b/flavours/haha/repo/migrations/20210618094945_peered_uri.exs index ce0bb3c412..1aff450e95 100644 --- a/flavours/haha/repo/migrations/20210618094945_peered_uri.exs +++ b/flavours/haha/repo/migrations/20210618094945_peered_uri.exs @@ -5,9 +5,9 @@ defmodule Bonfire.Social.Repo.Migrations.PeeredURI do def up do alter table("bonfire_data_activity_pub_peered") do - Ecto.Migration.add_if_not_exists :canonical_uri, :text, null: true + Ecto.Migration.add_if_not_exists(:canonical_uri, :text, null: true) end end - def down, do: nil + def down, do: nil end diff --git a/flavours/haha/repo/migrations/20210924094943_taxonomy_seeder.exs b/flavours/haha/repo/migrations/20210924094943_taxonomy_seeder.exs index 87225006fa..c8417700de 100644 --- a/flavours/haha/repo/migrations/20210924094943_taxonomy_seeder.exs +++ b/flavours/haha/repo/migrations/20210924094943_taxonomy_seeder.exs @@ -11,5 +11,4 @@ defmodule Bonfire.Repo.Migrations.TaxonomySeeder do end # def change, do: nil - end diff --git a/flavours/haha/repo/migrations/20210925094942_import_classify.exs b/flavours/haha/repo/migrations/20210925094942_import_classify.exs index 2f83f7b214..d8c04f13ec 100644 --- a/flavours/haha/repo/migrations/20210925094942_import_classify.exs +++ b/flavours/haha/repo/migrations/20210925094942_import_classify.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportClassify do use Ecto.Migration def up do - Bonfire.Classify.Migrations.up + Bonfire.Classify.Migrations.up() end def down do - Bonfire.Classify.Migrations.down + Bonfire.Classify.Migrations.down() end end diff --git a/flavours/haha/repo/migrations/20220208094942_import_invite_link.exs b/flavours/haha/repo/migrations/20220208094942_import_invite_link.exs index aead406a7e..4fa8d4f44c 100644 --- a/flavours/haha/repo/migrations/20220208094942_import_invite_link.exs +++ b/flavours/haha/repo/migrations/20220208094942_import_invite_link.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportInviteLink do use Ecto.Migration def up do - Bonfire.Invites.Link.Migration.up + Bonfire.Invites.Link.Migration.up() end def down do - Bonfire.Invites.Link.Migration.down + Bonfire.Invites.Link.Migration.down() end end diff --git a/flavours/haha/repo/migrations/20220304081300_care_closure.exs b/flavours/haha/repo/migrations/20220304081300_care_closure.exs index 30a0dbc621..2e41085d5c 100644 --- a/flavours/haha/repo/migrations/20220304081300_care_closure.exs +++ b/flavours/haha/repo/migrations/20220304081300_care_closure.exs @@ -4,5 +4,4 @@ defmodule Bonfire.Data.Identity.Repo.Migrations.CareClosure do alias Bonfire.Data.Identity.CareClosure.Migration def change, do: Migration.migrate_care_closure_view() - end diff --git a/flavours/haha/repo/migrations/20220408094940_settings.exs b/flavours/haha/repo/migrations/20220408094940_settings.exs index c7a22dcd23..57f6ac5987 100644 --- a/flavours/haha/repo/migrations/20220408094940_settings.exs +++ b/flavours/haha/repo/migrations/20220408094940_settings.exs @@ -2,7 +2,7 @@ defmodule Bonfire.Repo.Migrations.ImportSettings do use Ecto.Migration require Bonfire.Data.Identity.Settings.Migration - def up do + def up do Bonfire.Data.Identity.Settings.Migration.migrate_settings(:up) end diff --git a/flavours/haha/repo/migrations/20220428094200_add_files_mixin.exs b/flavours/haha/repo/migrations/20220428094200_add_files_mixin.exs index 0fd23546a9..ae2f93b48f 100644 --- a/flavours/haha/repo/migrations/20220428094200_add_files_mixin.exs +++ b/flavours/haha/repo/migrations/20220428094200_add_files_mixin.exs @@ -5,9 +5,10 @@ defmodule Bonfire.Repo.Migrations.AddFilesMixin do 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 + # cleanup old stuff + alter table("bonfire_files_media") do + remove_if_exists(:created_at, :utc_datetime_usec) + remove_if_exists(:updated_at, :utc_datetime_usec) end Bonfire.Files.Migrations.migrate_files() diff --git a/flavours/haha/repo/seeds.disabled/20210925131234_taxonomy_seeder_create_categories.exs b/flavours/haha/repo/seeds.disabled/20210925131234_taxonomy_seeder_create_categories.exs index a6c760853a..8261c3a90e 100644 --- a/flavours/haha/repo/seeds.disabled/20210925131234_taxonomy_seeder_create_categories.exs +++ b/flavours/haha/repo/seeds.disabled/20210925131234_taxonomy_seeder_create_categories.exs @@ -1,7 +1,7 @@ defmodule Bonfire.Repo.Seeds.TaxonomySeeds do use Bonfire.Seeder - envs [:dev, :prod, :test] + envs([:dev, :prod, :test]) def up(repo), do: Bonfire.TaxonomySeeder.ImportBatch.batch(repo) end diff --git a/flavours/haha/repo/seeds.exs b/flavours/haha/repo/seeds.exs index 38134deb7f..8318765a4a 100644 --- a/flavours/haha/repo/seeds.exs +++ b/flavours/haha/repo/seeds.exs @@ -6,19 +6,20 @@ import Bonfire.Me.Fake System.put_env("INVITE_ONLY", "false") System.put_env("SEARCH_INDEXING_DISABLED", "true") -%{ - preferred_username: System.get_env("SEEDS_USER", "root"), - name: System.get_env("SEEDS_USER", "Seed User") -} -|> fake_user!(%{confirm_email: true}) +fake_user!( + %{ + preferred_username: System.get_env("SEEDS_USER", "root"), + name: System.get_env("SEEDS_USER", "Seed User") + }, + %{confirm_email: true} +) # create some users users = for _ <- 1..3, do: fake_user!() random_user = fn -> Faker.Util.pick(users) end - # start fake threads -#for _ <- 1..3 do +# for _ <- 1..3 do # user = random_user.() # thread = fake_thread!(user) # comment = fake_comment!(user, thread) @@ -26,15 +27,14 @@ random_user = fn -> Faker.Util.pick(users) end # reply = fake_comment!(random_user.(), thread, %{in_reply_to_id: comment.id}) # subreply = fake_comment!(random_user.(), thread, %{in_reply_to_id: reply.id}) # subreply2 = fake_comment!(random_user.(), thread, %{in_reply_to_id: subreply.id}) -#end +# end # ## more fake threads -#for _ <- 1..2 do +# for _ <- 1..2 do # user = random_user.() # thread = fake_thread!(user) # comment = fake_comment!(user, thread) -#end - +# end # define some tags/categories if(Bonfire.Common.Extend.extension_enabled?(Bonfire.Classify.Simulate)) do diff --git a/flavours/reflow/config/activity_pub.exs b/flavours/reflow/config/activity_pub.exs index 5ff237c437..762b30fd44 100644 --- a/flavours/reflow/config/activity_pub.exs +++ b/flavours/reflow/config/activity_pub.exs @@ -38,7 +38,7 @@ config :activity_pub, ActivityPubWeb.Endpoint, render_errors: [view: ActivityPubWeb.ErrorView, accepts: ~w(json), layout: false] config :activity_pub, :json_contexts, %{ - "Hashtag"=> "as:Hashtag", - "ValueFlows" => "https://w3id.org/valueflows#", - "om2" => "http://www.ontology-of-units-of-measure.org/resource/om-2/" - } + "Hashtag" => "as:Hashtag", + "ValueFlows" => "https://w3id.org/valueflows#", + "om2" => "http://www.ontology-of-units-of-measure.org/resource/om-2/" +} diff --git a/flavours/reflow/config/activity_pub_test.exs b/flavours/reflow/config/activity_pub_test.exs index 2ed934cdf4..123c1be13d 100644 --- a/flavours/reflow/config/activity_pub_test.exs +++ b/flavours/reflow/config/activity_pub_test.exs @@ -13,8 +13,10 @@ config :activity_pub, Oban, queues: false config :activity_pub, :instance, - federating: false #(if System.get_env("TEST_INSTANCE")=="yes", do: true, else: false) - # rewrite_policy: [ActivityPub.MRF.SimplePolicy] + # (if System.get_env("TEST_INSTANCE")=="yes", do: true, else: false) + federating: false + +# rewrite_policy: [ActivityPub.MRF.SimplePolicy] config :tesla, adapter: Tesla.Mock diff --git a/flavours/reflow/config/bonfire_common.exs b/flavours/reflow/config/bonfire_common.exs index fa0fe71e6d..9dd428f9de 100644 --- a/flavours/reflow/config/bonfire_common.exs +++ b/flavours/reflow/config/bonfire_common.exs @@ -8,7 +8,8 @@ config :bonfire_common, # internationalisation config :bonfire_common, Bonfire.Common.Localise.Cldr, default_locale: default_locale, - locales: ["fr", "en", "es"], # locales that will be made available on top of those for which gettext localisation files are available + # locales that will be made available on top of those for which gettext localisation files are available + locales: ["fr", "en", "es"], providers: [Cldr.Language], gettext: Bonfire.Common.Localise.Gettext, data_dir: "./priv/cldr", diff --git a/flavours/reflow/config/bonfire_data.exs b/flavours/reflow/config/bonfire_data.exs index 9e1edc00bc..3298a6b001 100644 --- a/flavours/reflow/config/bonfire_data.exs +++ b/flavours/reflow/config/bonfire_data.exs @@ -2,51 +2,69 @@ import Config #### Base configuration -verbs = ["Boost", "Create", "Delete", "Edit", "Flag", "Follow", "Like", "Mention", - "Message", "Read", "Reply", "Request", "See", "Tag"] +verbs = [ + "Boost", + "Create", + "Delete", + "Edit", + "Flag", + "Follow", + "Like", + "Mention", + "Message", + "Read", + "Reply", + "Request", + "See", + "Tag" +] # 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 +config :bonfire_data_identity, Bonfire.Data.Identity.Credential, hasher_module: hasher #### Sentinel Data Services # Search these apps/extensions for Pointable ecto schema definitions to index pointable_schema_extensions = [ - :bonfire, - :bonfire_data_access_control, - :bonfire_data_activity_pub, - :bonfire_data_identity, - :bonfire_data_social, - :bonfire_data_edges, - :bonfire_tag, - :bonfire_classify, - :bonfire_data_shared_users, - :bonfire_files, - :bonfire_quantify, - :bonfire_geolocate, - :bonfire_valueflows, - :bonfire_valueflows_observe, - ] + :bonfire, + :bonfire_data_access_control, + :bonfire_data_activity_pub, + :bonfire_data_identity, + :bonfire_data_social, + :bonfire_data_edges, + :bonfire_tag, + :bonfire_classify, + :bonfire_data_shared_users, + :bonfire_files, + :bonfire_quantify, + :bonfire_geolocate, + :bonfire_valueflows, + :bonfire_valueflows_observe +] + 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, - ] +context_and_queries_extensions = + pointable_schema_extensions ++ + [ + :bonfire_common, + :bonfire_me, + :bonfire_social + ] -extensions_with_config = context_and_queries_extensions ++ [ - :bonfire_boundaries, - :bonfire_federate_activitypub, - :bonfire_search, - :bonfire_mailer, - :bonfire_geolocate - ] +extensions_with_config = + context_and_queries_extensions ++ + [ + :bonfire_boundaries, + :bonfire_federate_activitypub, + :bonfire_search, + :bonfire_mailer, + :bonfire_geolocate + ] config :bonfire, :verb_names, verbs config :bonfire, :context_modules_search_path, context_and_queries_extensions @@ -57,31 +75,74 @@ config :bonfire, :config_modules_search_path, extensions_with_config config :bonfire_data_access_control, search_path: [ # :bonfire_me, - :bonfire_boundaries, + :bonfire_boundaries + # :bonfire_social, # :bonfire, ] #### Alias modules for readability -alias Pointers.{Pointer, Table} -alias Bonfire.Data.AccessControl.{ - Acl, Circle, Encircle, Controlled, InstanceAdmin, Grant, Verb, -} -alias Bonfire.Data.ActivityPub.{Actor, Peer, Peered} -alias Bonfire.Boundaries.{Permitted, Stereotyped} -alias Bonfire.Data.Edges.{Edge,EdgeTotal} -alias Bonfire.Data.Identity.{ - Account, Accounted, AuthSecondFactor, Caretaker, CareClosure, Character, Credential, Email, ExtraInfo, Named, Self, Settings, User, -} -alias Bonfire.Data.Social.{ - Activity, APActivity, Article, Block, Bookmark, Boost, Created, Feed, FeedPublish, - Flag, Follow, Like, Mention, Message, Post, PostContent, Profile, Replied, Request, -} +alias Pointers.Pointer +alias Pointers.Table + +alias Bonfire.Data.AccessControl.Acl +alias Bonfire.Data.AccessControl.Circle +alias Bonfire.Data.AccessControl.Encircle +alias Bonfire.Data.AccessControl.Controlled +alias Bonfire.Data.AccessControl.InstanceAdmin +alias Bonfire.Data.AccessControl.Grant +alias Bonfire.Data.AccessControl.Verb + +alias Bonfire.Data.ActivityPub.Actor +alias Bonfire.Data.ActivityPub.Peer +alias Bonfire.Data.ActivityPub.Peered + +alias Bonfire.Boundaries.Permitted +alias Bonfire.Boundaries.Stereotyped + +alias Bonfire.Data.Edges.Edge +alias Bonfire.Data.Edges.EdgeTotal + +alias Bonfire.Data.Identity.Account +alias Bonfire.Data.Identity.Accounted +alias Bonfire.Data.Identity.AuthSecondFactor +alias Bonfire.Data.Identity.Caretaker +alias Bonfire.Data.Identity.CareClosure +alias Bonfire.Data.Identity.Character +alias Bonfire.Data.Identity.Credential +alias Bonfire.Data.Identity.Email +alias Bonfire.Data.Identity.ExtraInfo +alias Bonfire.Data.Identity.Named +alias Bonfire.Data.Identity.Self +alias Bonfire.Data.Identity.Settings +alias Bonfire.Data.Identity.User + +alias Bonfire.Data.Social.Activity +alias Bonfire.Data.Social.APActivity +alias Bonfire.Data.Social.Article +alias Bonfire.Data.Social.Block +alias Bonfire.Data.Social.Bookmark +alias Bonfire.Data.Social.Boost +alias Bonfire.Data.Social.Created +alias Bonfire.Data.Social.Feed +alias Bonfire.Data.Social.FeedPublish +alias Bonfire.Data.Social.Flag +alias Bonfire.Data.Social.Follow +alias Bonfire.Data.Social.Like +alias Bonfire.Data.Social.Mention +alias Bonfire.Data.Social.Message +alias Bonfire.Data.Social.Post +alias Bonfire.Data.Social.PostContent +alias Bonfire.Data.Social.Profile +alias Bonfire.Data.Social.Replied +alias Bonfire.Data.Social.Request + alias Bonfire.Classify.Category alias Bonfire.Geolocate.Geolocation alias Bonfire.Files alias Bonfire.Files.Media -alias Bonfire.{Tag, Tag.Tagged} +alias Bonfire.Tag +alias Bonfire.Tag.Tagged #### Flexto Stitching @@ -97,177 +158,234 @@ common_assocs = %{ ### Mixins # A summary of an object that can appear in a feed. - activity: quote(do: has_one(:activity, unquote(Activity), unquote(mixin))), + activity: quote(do: has_one(:activity, unquote(Activity), unquote(mixin))), # ActivityPub actor information - actor: quote(do: has_one(:actor, unquote(Actor), unquote(mixin))), + actor: quote(do: has_one(:actor, unquote(Actor), unquote(mixin))), # Indicates the entity responsible for an activity. Sort of like creator, but transferrable. Used # during deletion - when the caretaker is deleted, all their stuff will be too. - caretaker: quote(do: has_one(:caretaker, unquote(Caretaker), unquote(mixin))), + caretaker: quote(do: has_one(:caretaker, unquote(Caretaker), unquote(mixin))), # A Character has a unique username and some feeds. - character: quote(do: has_one(:character, unquote(Character), unquote(mixin))), + character: quote(do: has_one(:character, unquote(Character), unquote(mixin))), # Indicates the creator of an object - created: quote(do: has_one(:created, unquote(Created), unquote(mixin))), + created: quote(do: has_one(:created, unquote(Created), unquote(mixin))), # Used for non-textual interactions such as likes and follows to indicate the other object. - edge: quote(do: has_one(:edge, unquote(Edge), unquote(mixin))), + edge: quote(do: has_one(:edge, unquote(Edge), unquote(mixin))), # Adds a name that can appear in the user interface for an object. e.g. for an ACL. - named: quote(do: has_one(:named, unquote(Named), unquote(mixin))), + named: quote(do: has_one(:named, unquote(Named), unquote(mixin))), # Adds extra info that can appear in the user interface for an object. e.g. a summary or JSON-encoded data. - extra_info: quote(do: has_one(:extra_info, unquote(ExtraInfo), unquote(mixin))), + extra_info: quote(do: has_one(:extra_info, unquote(ExtraInfo), unquote(mixin))), # Information about the remote instance the object is from, if it is not local. - peered: quote(do: has_one(:peered, unquote(Peered), unquote(mixin))), + peered: quote(do: has_one(:peered, unquote(Peered), unquote(mixin))), # Information about the content of posts, e.g. a scrubbed html body post_content: quote(do: has_one(:post_content, unquote(PostContent), unquote(mixin))), # Information about a user or other object that they wish to make available - profile: quote(do: has_one(:profile, unquote(Profile), unquote(mixin))), + profile: quote(do: has_one(:profile, unquote(Profile), unquote(mixin))), # Threading information, for threaded discussions. - replied: quote(do: has_one(:replied, unquote(Replied), unquote(mixin))), + replied: quote(do: has_one(:replied, unquote(Replied), unquote(mixin))), # Information that allows the system to identify special system-managed ACLS. - stereotyped: quote(do: has_one(:stereotyped, unquote(Stereotyped), unquote(mixin))), - + stereotyped: quote(do: has_one(:stereotyped, unquote(Stereotyped), unquote(mixin))), ### Multimixins # Links to access control information for this object. - controlled: quote(do: has_many(:controlled, unquote(Controlled), unquote(mixin))), + 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))), + 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)), + 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))), + 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)), - + 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 # The objects which reply to this object. - direct_replies: quote(do: has_many(:direct_replies, unquote(Replied), foreign_key: :reply_to_id)), + direct_replies: + quote(do: has_many(:direct_replies, unquote(Replied), foreign_key: :reply_to_id)), # A recursive view of caretakers of caretakers of... used during deletion. - care_closure: quote(do: has_many(:care_closure, unquote(CareClosure), foreign_key: :branch_id)), + care_closure: quote(do: has_many(:care_closure, unquote(CareClosure), foreign_key: :branch_id)), # Retrieves activities where we are the object. e.g. if we are a # post or a user, this could turn up activities from likes or follows. - activities: quote(do: has_many(:activities, unquote(Activity), foreign_key: :object_id, references: :id)), + activities: + quote(do: has_many(:activities, unquote(Activity), foreign_key: :object_id, references: :id)), ### Stuff I'm not sure how to categorise yet # Used currently only for requesting to follow a user, but more general - request: quote(do: has_one(:request, unquote(Request), unquote(mixin))), + request: quote(do: has_one(:request, unquote(Request), unquote(mixin))) } # retrieves a list of quoted forms suitable for use with unquote_splicing common = fn names -> for name <- List.wrap(names) do with nil <- common_assocs[name], - do: raise(RuntimeError, message: "Expected a common association name, got #{inspect(name)}") + do: + raise(RuntimeError, message: "Expected a common association name, got #{inspect(name)}") end end -edge = common.([:controlled, :activities, :request, :created]) -edges = common.([:controlled, :activities, :request, :created, :caretaker, :activity, :feed_publishes]) +edge = common.([:controlled, :activities, :request, :created]) + +edges = + common.([:controlled, :activities, :request, :created, :caretaker, :activity, :feed_publishes]) # first up, pointers could have all the mixins we're using. TODO -pointer_mixins = common.([ - :activity, :actor, :caretaker, :character, :created, :edge, - :named, :extra_info, :peered, :post_content, :profile, :replied, :stereotyped -]) +pointer_mixins = + common.([ + :activity, + :actor, + :caretaker, + :character, + :created, + :edge, + :named, + :extra_info, + :peered, + :post_content, + :profile, + :replied, + :stereotyped + ]) + config :pointers, Pointer, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - field :dummy, :any, virtual: true - # pointables - has_one :circle, unquote(Circle), foreign_key: :id - many_to_many :encircle_subjects, Pointer, join_through: Encircle, join_keys: [circle_id: :id, subject_id: :id] - has_one :permitted, unquote(Permitted), foreign_key: :object_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 - has_one :category, unquote(Category), foreign_key: :id - has_one :geolocation, unquote(Geolocation), foreign_key: :id - # mixins - unquote_splicing(pointer_mixins) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media])) - # has_many - unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes])) + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + field(:dummy, :any, virtual: true) + # pointables + has_one(:circle, unquote(Circle), foreign_key: :id) - ## special things - # these should go away in future and they should be populated by a single query. - 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] + many_to_many(:encircle_subjects, Pointer, + join_through: Encircle, + join_keys: [circle_id: :id, subject_id: :id] + ) - end] + has_one(:permitted, unquote(Permitted), foreign_key: :object_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) + has_one(:category, unquote(Category), foreign_key: :id) + has_one(:geolocation, unquote(Geolocation), foreign_key: :id) + # mixins + unquote_splicing(pointer_mixins) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media])) + # has_many + unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes])) + + ## special things + # these should go away in future and they should be populated by a single query. + 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] + ) + end) config :pointers, Table, [] # now let's weave everything else together for convenience - # bonfire_data_access_control config :bonfire_data_access_control, Acl, - [code: quote do - field :grants_count, :integer, virtual: true - field :controlled_count, :integer, virtual: true - # mixins - unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) - # multimixins - # unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:grants_count, :integer, virtual: true) + field(:controlled_count, :integer, virtual: true) + # mixins + unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) + + # multimixins + # unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Circle, - [code: quote do - field :encircles_count, :integer, virtual: true - # mixins - unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) - # multimixins - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:encircles_count, :integer, virtual: true) + # mixins + unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) + # multimixins + unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Controlled, [] config :bonfire_data_access_control, Encircle, - [code: quote do - has_one :peer, unquote(Peer), foreign_key: :id, references: :subject_id - end] + code: + (quote do + has_one(:peer, unquote(Peer), foreign_key: :id, references: :subject_id) + end) config :bonfire_data_access_control, Grant, - [code: quote do - # mixins - unquote_splicing(common.([:caretaker])) - # multimixins - # unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:caretaker]))) + + # multimixins + # unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Verb, [] config :bonfire_boundaries, Stereotyped, - [code: quote do - has_one(:named, unquote(Named), [foreign_key: :id, references: :stereotype_id]) - end] + code: + (quote do + has_one(:named, unquote(Named), foreign_key: :id, references: :stereotype_id) + end) # bonfire_data_activity_pub config :bonfire_data_activity_pub, Actor, - [code: quote do - # hacks - belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - # mixins - unquote_splicing(common.([:peered])) - # multimixins - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # hacks + belongs_to(:character, unquote(Character), foreign_key: :id, define_field: false) + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + # mixins + unquote_splicing(common.([:peered])) + # multimixins + unquote_splicing(common.([:controlled])) + end) config :bonfire_data_activity_pub, Peer, [] config :bonfire_data_activity_pub, Peered, [] @@ -275,86 +393,128 @@ config :bonfire_data_activity_pub, Peered, [] # bonfire_data_identity config :bonfire_data_identity, Account, - [code: quote do - has_one :credential, unquote(Credential),foreign_key: :id - has_one :email, unquote(Email), foreign_key: :id - has_one :auth_second_factor, unquote(AuthSecondFactor), foreign_key: :id - has_one :settings, unquote(Settings), foreign_key: :id - many_to_many :users, unquote(User), - join_through: Accounted, - join_keys: [account_id: :id, id: :id] - many_to_many :shared_users, unquote(User), # optional - join_through: "bonfire_data_shared_user_accounts", - join_keys: [account_id: :id, shared_user_id: :id] - end] + code: + (quote do + has_one(:credential, unquote(Credential), foreign_key: :id) + has_one(:email, unquote(Email), foreign_key: :id) + has_one(:auth_second_factor, unquote(AuthSecondFactor), foreign_key: :id) + has_one(:settings, unquote(Settings), foreign_key: :id) + + many_to_many(:users, unquote(User), + join_through: Accounted, + join_keys: [account_id: :id, id: :id] + ) + + # optional + many_to_many(:shared_users, unquote(User), + join_through: "bonfire_data_shared_user_accounts", + join_keys: [account_id: :id, shared_user_id: :id] + ) + end) config :bonfire_data_identity, Accounted, - [code: quote do - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Caretaker, - [code: quote do - has_one :user, unquote(User), foreign_key: :id, references: :caretaker_id - # mixins - unquote_splicing(common.([:character, :profile])) - end] + code: + (quote do + has_one(:user, unquote(User), foreign_key: :id, references: :caretaker_id) + # mixins + unquote_splicing(common.([:character, :profile])) + end) config :bonfire_data_identity, Character, - [code: quote do - @follow_ulid "70110WTHE1EADER1EADER1EADE" - # mixins - unquote_splicing(common.([:actor, :peered, :profile])) - has_one :user, unquote(User), unquote(mixin) - has_one :feed, unquote(Feed), unquote(mixin) - has_many :followers, unquote(Follow), foreign_key: :following_id, references: :id - has_many :followed, unquote(Follow), foreign_key: :follower_id, references: :id - has_one :follow_count, unquote(EdgeTotal), foreign_key: :id, references: :id, - where: [table_id: @follow_ulid] - end] + code: + (quote do + @follow_ulid "70110WTHE1EADER1EADER1EADE" + # mixins + unquote_splicing(common.([:actor, :peered, :profile])) + has_one(:user, unquote(User), unquote(mixin)) + has_one(:feed, unquote(Feed), unquote(mixin)) + has_many(:followers, unquote(Follow), foreign_key: :following_id, references: :id) + has_many(:followed, unquote(Follow), foreign_key: :follower_id, references: :id) + + has_one(:follow_count, unquote(EdgeTotal), + foreign_key: :id, + references: :id, + where: [table_id: @follow_ulid] + ) + end) config :bonfire_data_identity, Credential, - [code: quote do - belongs_to :account, unquote(Account), foreign_key: :id, define_field: false - end] + code: + (quote do + belongs_to(:account, unquote(Account), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Email, - [must_confirm: true, - code: quote do - belongs_to :account, unquote(Account), foreign_key: :id, define_field: false - end] + must_confirm: true, + code: + (quote do + belongs_to(:account, unquote(Account), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Self, [] config :bonfire_data_identity, User, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - # mixins - has_one :accounted, unquote(Accounted), foreign_key: :id - has_one :instance_admin, unquote(InstanceAdmin), foreign_key: :id, on_replace: :update - has_one :self, unquote(Self), foreign_key: :id - has_one :shared_user, unquote(Bonfire.Data.SharedUser), foreign_key: :id - has_one :settings, unquote(Settings), foreign_key: :id - unquote_splicing(common.([:actor, :character, :created, :peered, :profile])) - # multimixins - unquote_splicing(common.([:controlled])) - # manies - has_many :encircles, unquote(Encircle), foreign_key: :subject_id - has_many :creations, through: [:created, :pointer] # todo: stop through - has_many :posts, through: [:created, :post] # todo: stop through - has_many :followers, unquote(Edge), foreign_key: :object_id, references: :id, where: [table_id: @follow_ulid] - has_many :followed, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @follow_ulid] - has_many :user_activities, unquote(Activity), foreign_key: :subject_id, references: :id - has_many :boost_activities, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @boost_ulid] - has_many :like_activities, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @like_ulid] - many_to_many :caretaker_accounts, unquote(Account), - 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 # enable if using Geolocate extension - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + # mixins + has_one(:accounted, unquote(Accounted), foreign_key: :id) + has_one(:instance_admin, unquote(InstanceAdmin), foreign_key: :id, on_replace: :update) + has_one(:self, unquote(Self), foreign_key: :id) + has_one(:shared_user, unquote(Bonfire.Data.SharedUser), foreign_key: :id) + has_one(:settings, unquote(Settings), foreign_key: :id) + unquote_splicing(common.([:actor, :character, :created, :peered, :profile])) + # multimixins + unquote_splicing(common.([:controlled])) + # manies + has_many(:encircles, unquote(Encircle), foreign_key: :subject_id) + # todo: stop through + has_many(:creations, through: [:created, :pointer]) + # todo: stop through + has_many(:posts, through: [:created, :post]) + + has_many(:followers, unquote(Edge), + foreign_key: :object_id, + references: :id, + where: [table_id: @follow_ulid] + ) + + has_many(:followed, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @follow_ulid] + ) + + has_many(:user_activities, unquote(Activity), foreign_key: :subject_id, references: :id) + + has_many(:boost_activities, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @boost_ulid] + ) + + has_many(:like_activities, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @like_ulid] + ) + + many_to_many(:caretaker_accounts, unquote(Account), + 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 # enable if using Geolocate extension + end) config :bonfire_data_identity, Named, [] config :bonfire_data_identity, ExtraInfo, [] @@ -362,328 +522,439 @@ config :bonfire_data_identity, ExtraInfo, [] ### bonfire_data_social config :bonfire_data_social, Activity, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - has_many :feed_publishes, unquote(FeedPublish), unquote(mixin) - has_one :seen, unquote(Edge), foreign_key: :object_id, references: :id - # ugly workaround needed for certain queries (TODO: check if still needed) - has_one :activity, unquote(Activity), foreign_key: :id, references: :id - # 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] - has_many :controlled, unquote(Controlled), foreign_key: :id, references: :object_id - has_many :tagged, unquote(Tagged), foreign_key: :id, references: :object_id - many_to_many :tags, unquote(Pointer), - join_through: unquote(Tagged), - 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] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + has_many(:feed_publishes, unquote(FeedPublish), unquote(mixin)) + has_one(:seen, unquote(Edge), foreign_key: :object_id, references: :id) + # ugly workaround needed for certain queries (TODO: check if still needed) + has_one(:activity, unquote(Activity), foreign_key: :id, references: :id) + # 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] + ) + + has_many(:controlled, unquote(Controlled), foreign_key: :id, references: :object_id) + has_many(:tagged, unquote(Tagged), foreign_key: :id, references: :object_id) + + many_to_many(:tags, unquote(Pointer), + join_through: unquote(Tagged), + 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, - [code: quote do - unquote_splicing(common.([:activity, :caretaker, :controlled])) - end] + code: + (quote do + (unquote_splicing(common.([:activity, :caretaker, :controlled]))) + end) config :bonfire_data_edges, Edge, - [code: quote do - unquote_splicing(edge) - # TODO: requires composite foreign keys: - # has_one :activity, unquote(Activity), - # foreign_key: [:table_id, :object_id], references: [:table_id, :object_id] - end] + code: + (quote do + (unquote_splicing(edge)) + + # TODO: requires composite foreign keys: + # has_one :activity, unquote(Activity), + # foreign_key: [:table_id, :object_id], references: [:table_id, :object_id] + end) config :bonfire_data_social, Feed, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker])) - # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - # belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:activity, :caretaker]))) + + # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false + # belongs_to :user, unquote(User), foreign_key: :id, define_field: false + end) config :bonfire_data_social, FeedPublish, - [code: quote do - field :dummy, :any, virtual: true - has_one :activity, unquote(Activity), foreign_key: :object_id, references: :id - # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - # belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + field(:dummy, :any, virtual: true) + has_one(:activity, unquote(Activity), foreign_key: :object_id, references: :id) + # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false + # belongs_to :user, unquote(User), foreign_key: :id, define_field: false + end) config :bonfire_data_social, Follow, - [code: quote do - unquote_splicing(edges) - end] - # 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}] + code: + (quote do + (unquote_splicing(edges)) + end) + +# 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}] config :bonfire_data_social, Block, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Boost, - [code: quote do - unquote_splicing(edges) - end] - # has_one: [activity: {Activity, foreign_key: :object_id, references: :boosted_id}] # requires an ON clause + code: + (quote do + (unquote_splicing(edges)) + end) + +# has_one: [activity: {Activity, foreign_key: :object_id, references: :boosted_id}] # requires an ON clause config :bonfire_data_social, Like, - [code: quote do - unquote_splicing(edges) - end] - # has_one: [activity: {Activity, foreign_key: :object_id, references: :liked_id}] # requires an ON clause + code: + (quote do + (unquote_splicing(edges)) + end) + +# has_one: [activity: {Activity, foreign_key: :object_id, references: :liked_id}] # requires an ON clause config :bonfire_data_social, Flag, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Request, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Bookmark, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Message, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - # mixins - unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied])) - # multimixins - 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] - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + # mixins + unquote_splicing( + common.([:activity, :caretaker, :created, :peered, :post_content, :replied]) + ) + + # multimixins + 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] + ) + end) config :bonfire_data_social, Mention, [] config :bonfire_data_social, Post, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - # mixins - unquote_splicing(common.([:activities, :activity, :caretaker, :created, :peered, :post_content, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - # special - has_one :permitted, unquote(Permitted), foreign_key: :object_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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause - # 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 :like_count, unquote(EdgeTotal), - 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] - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + # mixins + unquote_splicing( + common.([:activities, :activity, :caretaker, :created, :peered, :post_content, :replied]) + ) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + # special + has_one(:permitted, unquote(Permitted), foreign_key: :object_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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause + # 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(:like_count, unquote(EdgeTotal), + 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] + ) + end) config :bonfire_data_social, PostContent, - [code: quote do - # mixins - unquote_splicing(common.([:created])) - # multimixins - unquote_splicing(common.([:controlled])) - # virtuals for changesets - field :hashtags, {:array, :any}, virtual: true - field :mentions, {:array, :any}, virtual: true - field :urls, {:array, :any}, virtual: true - end] + code: + (quote do + # mixins + unquote_splicing(common.([:created])) + # multimixins + unquote_splicing(common.([:controlled])) + # virtuals for changesets + field(:hashtags, {:array, :any}, virtual: true) + field(:mentions, {:array, :any}, virtual: true) + field(:urls, {:array, :any}, virtual: true) + end) config :bonfire_data_social, Replied, - [code: quote do - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) + code: + (quote do + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) - @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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id - 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 - 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] + @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_one(:activity, unquote(Activity), foreign_key: :object_id, references: :id) + # used in changesets + field(:replying_to, :map, virtual: true) + 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 + ) + + 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) 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 - # mixins - shouldn't be here really - unquote_splicing(common.([:peered])) - has_one :post, unquote(Post), unquote(mixin) # huh? - end] + 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 + ) + + # mixins - shouldn't be here really + unquote_splicing(common.([:peered])) + # huh? + has_one(:post, unquote(Post), unquote(mixin)) + end) config :bonfire_data_social, Profile, - [code: quote do - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) + end) ######### other extensions config :bonfire_files, Media, - [code: quote do - field :url, :string, virtual: true - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:url, :string, virtual: true) + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) + end) config :bonfire_classify, Category, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :created, :actor, :peered, :profile, :character])) # TODO :caretaker - # multimixins - unquote_splicing(common.([:controlled, :feed_publishes])) + code: + (quote do + # mixins + # TODO :caretaker + unquote_splicing(common.([:activity, :created, :actor, :peered, :profile, :character])) + # multimixins + unquote_splicing(common.([:controlled, :feed_publishes])) - # add references of tagged objects to any Category - many_to_many :tags, unquote(Pointer), - join_through: unquote(Tagged), - unique: true, - join_keys: [tag_id: :id, id: :id], - on_replace: :delete - end] + # add references of tagged objects to any Category + many_to_many(:tags, unquote(Pointer), + join_through: unquote(Tagged), + unique: true, + join_keys: [tag_id: :id, id: :id], + 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] + 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, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + # TODO :caretaker + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.EconomicResource, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Knowledge.ResourceSpecification, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Process, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Knowledge.ProcessSpecification, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Planning.Intent, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Planning.Commitment, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Proposal, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows_observe, ValueFlows.Observe.Observation, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) diff --git a/flavours/reflow/config/bonfire_fail.exs b/flavours/reflow/config/bonfire_fail.exs index b4a66cb338..7a712ed231 100644 --- a/flavours/reflow/config/bonfire_fail.exs +++ b/flavours/reflow/config/bonfire_fail.exs @@ -11,9 +11,11 @@ config :bonfire_fail, bad_header: {400, "Bad request: malformed header."}, no_access: {403, "This site is by invitation only."}, token_expired: {403, "This link or token has expired, please request a fresh one."}, - already_claimed: {403, "This link or token was already used, please request a fresh one if necessary."}, + already_claimed: + {403, "This link or token was already used, please request a fresh one if necessary."}, token_not_found: {403, "This token was not found, please request a fresh one."}, - user_disabled: {403, "This user account is disabled. Please contact the instance administrator."}, + user_disabled: + {403, "This user account is disabled. Please contact the instance administrator."}, email_not_confirmed: {403, "Please confirm your email address first."}, unknown_resource: {400, "Unknown resource."}, invalid_argument: {400, "Invalid arguments passed."}, diff --git a/flavours/reflow/config/bonfire_federate_activitypub.exs b/flavours/reflow/config/bonfire_federate_activitypub.exs index 28e917ce5f..fc758f2aaa 100644 --- a/flavours/reflow/config/bonfire_federate_activitypub.exs +++ b/flavours/reflow/config/bonfire_federate_activitypub.exs @@ -13,12 +13,13 @@ config :bonfire, :bonfire_classify, :bonfire_geolocate, :bonfire_quantify - ], - log_federation: true, # enable/disable logging of federation logic + ], + # enable/disable logging of federation logic + log_federation: true, federation_fallback_module: Bonfire.Social.APActivities config :bonfire, actor_AP_types: actor_types # config :bonfire, Bonfire.Instance, - # hostname: hostname, - # description: desc +# hostname: hostname, +# description: desc diff --git a/flavours/reflow/config/bonfire_files.exs b/flavours/reflow/config/bonfire_files.exs index 7d59d69d8e..004256aaeb 100644 --- a/flavours/reflow/config/bonfire_files.exs +++ b/flavours/reflow/config/bonfire_files.exs @@ -4,48 +4,53 @@ import Config # see https://hexdocs.pm/waffle/Waffle.html#module-setup-a-storage-provider config :waffle, storage: Waffle.Storage.Local, - asset_host: "/" # or {:system, "ASSET_HOST"} + # or {:system, "ASSET_HOST"} + 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", -] +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_files, image_media_types: image_media_types config :bonfire_files, all_allowed_media_types: all_allowed_media_types config :bonfire_files, Bonfire.Files.IconUploader, allowed_media_types: image_media_types config :bonfire_files, Bonfire.Files.ImageUploader, allowed_media_types: image_media_types -config :bonfire_files, Bonfire.Files.DocumentUploader, allowed_media_types: all_allowed_media_types + +config :bonfire_files, Bonfire.Files.DocumentUploader, + allowed_media_types: all_allowed_media_types diff --git a/flavours/reflow/config/bonfire_geolocate.exs b/flavours/reflow/config/bonfire_geolocate.exs index 49c9723926..1d5142d211 100644 --- a/flavours/reflow/config/bonfire_geolocate.exs +++ b/flavours/reflow/config/bonfire_geolocate.exs @@ -3,5 +3,4 @@ import Config config :bonfire_geolocate, templates_path: "lib" -config :bonfire, :js_config, - mapbox_api_key: System.get_env("MAPBOX_API_KEY") +config :bonfire, :js_config, mapbox_api_key: System.get_env("MAPBOX_API_KEY") diff --git a/flavours/reflow/config/bonfire_quantify.exs b/flavours/reflow/config/bonfire_quantify.exs index 6cfe4174f1..521c304be9 100755 --- a/flavours/reflow/config/bonfire_quantify.exs +++ b/flavours/reflow/config/bonfire_quantify.exs @@ -3,4 +3,5 @@ import Config config :bonfire_quantify, templates_path: "lib" -config :bonfire_quantify, Bonfire.Quantify.Units, valid_contexts: [Bonfire.Quantify.Units, Bonfire.Data.Identity.User] +config :bonfire_quantify, Bonfire.Quantify.Units, + valid_contexts: [Bonfire.Quantify.Units, Bonfire.Data.Identity.User] diff --git a/flavours/reflow/config/bonfire_search.exs b/flavours/reflow/config/bonfire_search.exs index a5c6025899..7de227c923 100644 --- a/flavours/reflow/config/bonfire_search.exs +++ b/flavours/reflow/config/bonfire_search.exs @@ -3,8 +3,10 @@ import Config config :bonfire_search, disable_indexing: System.get_env("SEARCH_INDEXING_DISABLED", "false"), adapter: Bonfire.Search.Meili, - instance: System.get_env("SEARCH_MEILI_INSTANCE", "http://search:7700"), # protocol, hostname and port - api_key: System.get_env("MEILI_MASTER_KEY", "make-sure-to-change-me") # secret key + # protocol, hostname and port + instance: System.get_env("SEARCH_MEILI_INSTANCE", "http://search:7700"), + # secret key + api_key: System.get_env("MEILI_MASTER_KEY", "make-sure-to-change-me") # for use by API client config :tesla, adapter: Tesla.Adapter.Hackney diff --git a/flavours/reflow/config/bonfire_ui.exs b/flavours/reflow/config/bonfire_ui.exs index 201018cd04..d2a518bdc8 100755 --- a/flavours/reflow/config/bonfire_ui.exs +++ b/flavours/reflow/config/bonfire_ui.exs @@ -1,95 +1,95 @@ import Config - config :bonfire, :ui, - theme: [ - instance_name: "Reflow Demo", - instance_icon: "https://reflowproject.eu/wp-content/themes/reflow/images/logoWhite.svg", - instance_image: "https://reflowproject.eu/wp-content/uploads/2020/06/reflow-blog-1600x900.jpg", - instance_description: "This is a Reflow demo instance", - instance_welcome: [ - links: [ - "About Bonfire": "https://bonfirenetworks.org/", - "About Reflow": "https://reflowproject.eu/", - "Contribute": "https://bonfirenetworks.org/contribute/" - ] + theme: [ + instance_name: "Reflow Demo", + instance_icon: "https://reflowproject.eu/wp-content/themes/reflow/images/logoWhite.svg", + instance_image: + "https://reflowproject.eu/wp-content/uploads/2020/06/reflow-blog-1600x900.jpg", + instance_description: "This is a Reflow demo instance", + instance_welcome: [ + links: [ + "About Bonfire": "https://bonfirenetworks.org/", + "About Reflow": "https://reflowproject.eu/", + Contribute: "https://bonfirenetworks.org/contribute/" ] - ], - sidebar_components: [ - {Bonfire.UI.Social.SidebarNavigationLive, []}, - {Bonfire.UI.Reflow.SidebarNavigationLive, []}, - # {Bonfire.UI.ValueFlows.ProcessesListLive, [title: "Processes", process_url: "/process/"]}, - ], - smart_input: [ - post: false, - cw: true, - summary: true - ], - rich_text_editor: Bonfire.Editor.Quill, - default_smart_input: Bonfire.UI.ValueFlows.CreateProcessSmartInputLive, - profile: [ - sections: [ - timeline: Bonfire.UI.Social.ProfileTimelineLive, - # private: Bonfire.UI.Social.MessageThreadsLive, - posts: Bonfire.UI.Social.ProfilePostsLive, - boosts: Bonfire.UI.Social.ProfileBoostsLive, - followers: Bonfire.UI.Social.ProfileFollowsLive, - followed: Bonfire.UI.Social.ProfileFollowsLive, - inventory: Bonfire.UI.Reflow.ProfileInventoryLive, - ], - navigation: [ - timeline: "timeline", - inventory: "inventory", - # posts: "posts", - # boosts: "boosts", - # private: "private", - ], - widgets: [ - ], - ], - smart_input_activities: [ - # offer: "Publish an offer", - # need: "Publish a need", - transfer_resource: "Transfer a resource", - produce_resource: "Add a resource", - # intent: "Indicate an itent", - # economic_event: "Record an economic event", - process: "Create a process" - ], - smart_input_components: [ - post: Bonfire.UI.Social.WritePostContentLive, - # economic_event: Bonfire.UI.ValueFlows.SelectEconomicEventLive, - # intent: Bonfire.UI.ValueFlows.CreateIntentLive, - # task: Bonfire.UI.Coordination.CreateTaskLive, - process: Bonfire.UI.ValueFlows.CreateProcessSmartInputLive - ], - resource: [ - navigation: [ - trace: "trace", - track: "track", - ], - widgets: [ - # Bonfire.UI.Social.SubscribeWidgetLive - Bonfire.UI.ValueFlows.LocationWidgetLive, - Bonfire.UI.ValueFlows.PrimaryAccountableWidgetLive, - ], - ], - default_instance_feed_previews: [ - process: Bonfire.UI.Social.Activity.ProcessReflowLive - ] - # process: [ - # navigation: [ - # events: "Economic events", - # intents: "Intents", - # # material_passport: "material passport", - # ], - # sections: [ - # events: Bonfire.UI.ValueFlows.EconomicEventsLive, - # intents: Bonfire.UI.ValueFlows.IntentsLive, - # ], - # widgets: [ - # # Bonfire.UI.Social.SubscribeWidgetLive, - # # Bonfire.UI.ValueFlows.LocationWidgetLive, - # # Bonfire.UI.Social.HashtagsWidgetLive, - # ], - # ] + ] + ], + sidebar_components: [ + {Bonfire.UI.Social.SidebarNavigationLive, []}, + {Bonfire.UI.Reflow.SidebarNavigationLive, []} + # {Bonfire.UI.ValueFlows.ProcessesListLive, [title: "Processes", process_url: "/process/"]}, + ], + smart_input: [ + post: false, + cw: true, + summary: true + ], + rich_text_editor: Bonfire.Editor.Quill, + default_smart_input: Bonfire.UI.ValueFlows.CreateProcessSmartInputLive, + profile: [ + sections: [ + timeline: Bonfire.UI.Social.ProfileTimelineLive, + # private: Bonfire.UI.Social.MessageThreadsLive, + posts: Bonfire.UI.Social.ProfilePostsLive, + boosts: Bonfire.UI.Social.ProfileBoostsLive, + followers: Bonfire.UI.Social.ProfileFollowsLive, + followed: Bonfire.UI.Social.ProfileFollowsLive, + inventory: Bonfire.UI.Reflow.ProfileInventoryLive + ], + navigation: [ + timeline: "timeline", + inventory: "inventory" + # posts: "posts", + # boosts: "boosts", + # private: "private", + ], + widgets: [] + ], + smart_input_activities: [ + # offer: "Publish an offer", + # need: "Publish a need", + transfer_resource: "Transfer a resource", + produce_resource: "Add a resource", + # intent: "Indicate an itent", + # economic_event: "Record an economic event", + process: "Create a process" + ], + smart_input_components: [ + post: Bonfire.UI.Social.WritePostContentLive, + # economic_event: Bonfire.UI.ValueFlows.SelectEconomicEventLive, + # intent: Bonfire.UI.ValueFlows.CreateIntentLive, + # task: Bonfire.UI.Coordination.CreateTaskLive, + process: Bonfire.UI.ValueFlows.CreateProcessSmartInputLive + ], + resource: [ + navigation: [ + trace: "trace", + track: "track" + ], + widgets: [ + # Bonfire.UI.Social.SubscribeWidgetLive + Bonfire.UI.ValueFlows.LocationWidgetLive, + Bonfire.UI.ValueFlows.PrimaryAccountableWidgetLive + ] + ], + default_instance_feed_previews: [ + process: Bonfire.UI.Social.Activity.ProcessReflowLive + ] + +# process: [ +# navigation: [ +# events: "Economic events", +# intents: "Intents", +# # material_passport: "material passport", +# ], +# sections: [ +# events: Bonfire.UI.ValueFlows.EconomicEventsLive, +# intents: Bonfire.UI.ValueFlows.IntentsLive, +# ], +# widgets: [ +# # Bonfire.UI.Social.SubscribeWidgetLive, +# # Bonfire.UI.ValueFlows.LocationWidgetLive, +# # Bonfire.UI.Social.HashtagsWidgetLive, +# ], +# ] diff --git a/flavours/reflow/config/config.exs b/flavours/reflow/config/config.exs index 19706a68e3..aba2e1b2dc 100644 --- a/flavours/reflow/config/config.exs +++ b/flavours/reflow/config/config.exs @@ -2,7 +2,7 @@ import Config default_flavour = "classic" flavour = System.get_env("FLAVOUR", default_flavour) -flavour_path = System.get_env("FLAVOUR_PATH", "flavours/"<>flavour) +flavour_path = System.get_env("FLAVOUR_PATH", "flavours/" <> flavour) #### Basic configuration @@ -33,7 +33,8 @@ config :bonfire, config :bonfire, Bonfire.Web.Endpoint, url: [host: "localhost"], http: [ - port: String.to_integer(System.get_env("SERVER_PORT", "4000")), # this gets overriden in runtime.exs + # this gets overriden in runtime.exs + port: String.to_integer(System.get_env("SERVER_PORT", "4000")), transport_options: [socket_opts: [:inet6]] ], render_errors: [view: Bonfire.UI.Common.ErrorView, accepts: ~w(html json), layout: false], @@ -44,6 +45,7 @@ config :phoenix_gon, :json_library, Jason config :ecto_sparkles, :otp_app, :bonfire config :bonfire, :ecto_repos, [Bonfire.Common.Repo] + config :bonfire, Bonfire.Common.Repo, types: Bonfire.Geolocate.PostgresTypes, priv: flavour_path <> "/repo" @@ -74,10 +76,9 @@ config :mime, :types, %{ config :sentry, dsn: "this-will-be-overriden-by-a-secure-string-in-runtime.exs", - environment_name: Mix.env, + environment_name: Mix.env(), included_environments: [:prod] - # include config for all used Bonfire extensions for config <- "bonfire_*.exs" |> Path.expand(__DIR__) |> Path.wildcard() do # IO.inspect(include_config: config) @@ -86,6 +87,5 @@ end import_config "activity_pub.exs" - # finally, append/override config based on env, which will override any config set above (including from imported files) import_config "#{config_env()}.exs" diff --git a/flavours/reflow/config/dev.exs b/flavours/reflow/config/dev.exs index b3a86e5054..35861a015d 100644 --- a/flavours/reflow/config/dev.exs +++ b/flavours/reflow/config/dev.exs @@ -10,10 +10,14 @@ path_dep_dirs = |> Enum.map(&(Keyword.fetch!(elem(&1, 1), :path) <> "/lib")) config :phoenix_live_reload, - dirs: path_dep_dirs ++ ["lib/"] # watch the app's lib/ dir + the dep/lib/ dir of every locally-cloned dep + # watch the app's lib/ dir + the dep/lib/ dir of every locally-cloned dep + dirs: path_dep_dirs ++ ["lib/"] -path_dep_patterns = path_dep_dirs |> Enum.map(&(String.slice(&1, 2..1000) <>".*ex")) # to include cloned code in patterns -path_dep_patterns = path_dep_patterns ++ path_dep_dirs |> Enum.map(&(String.slice(&1, 2..1000) <>".*sface")) # Surface views +# to include cloned code in patterns +path_dep_patterns = Enum.map(path_dep_dirs, &(String.slice(&1, 2..1000) <> ".*ex")) +# Surface views +path_dep_patterns = + (path_dep_patterns ++ path_dep_dirs) |> Enum.map(&(String.slice(&1, 2..1000) <> ".*sface")) # Watch static and templates for browser reloading. config :bonfire, Bonfire.Web.Endpoint, @@ -36,24 +40,26 @@ config :bonfire, Bonfire.Web.Endpoint, ] ], live_reload: [ - patterns: [ - # ~r"^priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", - # ~r"^priv/gettext/.*(po)$", - # ~r"^web/(live|views)/.*ex$", - # ~r"^lib/.*_live\.ex$", - # ~r".*leex$", - ~r"lib/.*ex$", - ~r".*sface$", - ~r"priv/catalogue/.*(ex)$", - ] ++ path_dep_patterns - ] + patterns: + [ + # ~r"^priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$", + # ~r"^priv/gettext/.*(po)$", + # ~r"^web/(live|views)/.*ex$", + # ~r"^lib/.*_live\.ex$", + # ~r".*leex$", + # defp elixirc_paths(:dev), do: ["lib"] ++ catalogues() -# defp elixirc_paths(:dev), do: ["lib"] ++ catalogues() + ~r"lib/.*ex$", + ~r".*sface$", + ~r"priv/catalogue/.*(ex)$" + ] ++ path_dep_patterns + ] config :logger, :console, level: :debug, # truncate: :infinity, - format: "[$level] $message\n" # Do not include metadata or timestamps + # Do not include metadata or timestamps + format: "[$level] $message\n" config :phoenix, :stacktrace_depth, 30 diff --git a/flavours/reflow/config/prod.exs b/flavours/reflow/config/prod.exs index 546317cec9..a8e06763a6 100644 --- a/flavours/reflow/config/prod.exs +++ b/flavours/reflow/config/prod.exs @@ -5,8 +5,7 @@ import Config # manifest is generated by the `mix phx.digest` task, # which you should run after static files are built and # before starting your production server. -config :bonfire, Bonfire.Web.Endpoint, - cache_static_manifest: "priv/static/cache_manifest.json" +config :bonfire, Bonfire.Web.Endpoint, cache_static_manifest: "priv/static/cache_manifest.json" config :logger, backends: [:console, Sentry.LoggerBackend] @@ -17,4 +16,5 @@ config :logger, level: :info config :bonfire, Bonfire.Web.Endpoint, server: true config :bonfire, Bonfire.Common.Repo, - priv: "priv/repo" # in releases migrations are not in a flavour-specific directory + # in releases migrations are not in a flavour-specific directory + priv: "priv/repo" diff --git a/flavours/reflow/config/runtime.exs b/flavours/reflow/config/runtime.exs index 55b59a10ec..7aa902e020 100644 --- a/flavours/reflow/config/runtime.exs +++ b/flavours/reflow/config/runtime.exs @@ -13,16 +13,15 @@ Bonfire.Common.Config.LoadExtensionsConfig.load_configs() ## System.get_env("DATABASE_URL") || System.get_env("POSTGRES_PASSWORD") || System.get_env("CI") || - raise """ - Environment variables for database are missing. - For example: DATABASE_URL=ecto://USER:PASS@HOST/DATABASE - You can also set POSTGRES_PASSWORD (required), - and POSTGRES_USER (default: postgres) and POSTGRES_HOST (default: localhost) - """ + raise """ + Environment variables for database are missing. + For example: DATABASE_URL=ecto://USER:PASS@HOST/DATABASE + You can also set POSTGRES_PASSWORD (required), + and POSTGRES_USER (default: postgres) and POSTGRES_HOST (default: localhost) + """ if System.get_env("DATABASE_URL") do - config :bonfire, Bonfire.Common.Repo, - url: System.get_env("DATABASE_URL") + config :bonfire, Bonfire.Common.Repo, url: System.get_env("DATABASE_URL") else config :bonfire, Bonfire.Common.Repo, # ssl: true, @@ -38,12 +37,14 @@ secret_key_base = You can generate one by calling: mix phx.gen.secret """ -signing_salt = System.get_env("SIGNING_SALT") || System.get_env("CI") || +signing_salt = + System.get_env("SIGNING_SALT") || System.get_env("CI") || raise """ environment variable SIGNING_SALT is missing. """ -encryption_salt = System.get_env("ENCRYPTION_SALT") || System.get_env("CI") || +encryption_salt = + System.get_env("ENCRYPTION_SALT") || System.get_env("CI") || raise """ environment variable ENCRYPTION_SALT is missing. """ @@ -57,7 +58,10 @@ config :bonfire, encryption_salt: encryption_salt, signing_salt: signing_salt -start_server? = if config_env() == :test, do: System.get_env("START_SERVER", "true"), else: System.get_env("START_SERVER", "true") +start_server? = + if config_env() == :test, + do: System.get_env("START_SERVER", "true"), + else: System.get_env("START_SERVER", "true") config :bonfire, Bonfire.Web.Endpoint, server: String.to_existing_atom(start_server?), @@ -72,9 +76,7 @@ config :bonfire, Bonfire.Web.Endpoint, live_view: [signing_salt: signing_salt] if System.get_env("SENTRY_DSN") do - IO.puts( - "Note: errors will be reported to Sentry." - ) + IO.puts("Note: errors will be reported to Sentry.") config :sentry, dsn: System.get_env("SENTRY_DSN") @@ -86,22 +88,20 @@ end # start prod-only config if config_env() == :prod do - config :bonfire, Bonfire.Common.Repo, # ssl: true, database: System.get_env("POSTGRES_DB", "bonfire"), pool_size: String.to_integer(System.get_env("POOL_SIZE", "10")), - log: String.to_atom(System.get_env("DB_QUERIES_LOG_LEVEL", "false")) # Note: keep this disabled if using ecto_dev_logger or EctoSparkles.Log instead # - -end # prod only config + # Note: keep this disabled if using ecto_dev_logger or EctoSparkles.Log instead # + log: String.to_atom(System.get_env("DB_QUERIES_LOG_LEVEL", "false")) +end +# prod only config # start prod and dev only config if config_env() != :test do - config :bonfire, Bonfire.Common.Repo, slow_query_ms: String.to_integer(System.get_env("SLOW_QUERY_MS", "100")) - end ## bonfire_livebook diff --git a/flavours/reflow/config/test.exs b/flavours/reflow/config/test.exs index 38eff7db06..27be4847c3 100644 --- a/flavours/reflow/config/test.exs +++ b/flavours/reflow/config/test.exs @@ -15,7 +15,6 @@ config :bonfire_search, config :logger, level: :info # config :logger, level: :notice - # Configure your database db = "bonfire_test#{System.get_env("MIX_TEST_PARTITION")}" # @@ -32,7 +31,7 @@ config :bonfire, Bonfire.Common.Repo, # These defaults are overriden in runtime.exs config :bonfire, Bonfire.Web.Endpoint, http: [port: 4001], - server: (if System.get_env("TEST_INSTANCE")=="yes", do: true, else: false) + server: if(System.get_env("TEST_INSTANCE") == "yes", do: true, else: false) # Run a 2nd endpoint for testing federation (not currently used) config :bonfire, Bonfire.Web.FakeRemoteEndpoint, @@ -59,6 +58,7 @@ config :mix_test_interactive, clear: true config :paginator, ecto_repos: [Bonfire.Common.Repo] + config :paginator, Paginator.Repo, pool: Ecto.Adapters.SQL.Sandbox, username: System.get_env("POSTGRES_USER", "postgres"), @@ -66,4 +66,6 @@ config :paginator, Paginator.Repo, hostname: System.get_env("POSTGRES_HOST", "localhost"), database: db -config :tesla, adapter: (if System.get_env("TEST_INSTANCE")=="yes", do: Tesla.Adapter.Hackney, else: Tesla.Mock) +config :tesla, + adapter: + if(System.get_env("TEST_INSTANCE") == "yes", do: Tesla.Adapter.Hackney, else: Tesla.Mock) diff --git a/flavours/reflow/repo/migrations/20200523081010_citext.exs b/flavours/reflow/repo/migrations/20200523081010_citext.exs index bad3ec5df0..8de33932f7 100644 --- a/flavours/reflow/repo/migrations/20200523081010_citext.exs +++ b/flavours/reflow/repo/migrations/20200523081010_citext.exs @@ -2,11 +2,10 @@ defmodule Bonfire.Repo.Migrations.HelloWorld do use Ecto.Migration def up do - execute "CREATE EXTENSION IF NOT EXISTS \"citext\"" + execute("CREATE EXTENSION IF NOT EXISTS \"citext\"") end def down do - execute "DROP EXTENSION IF EXISTS \"citext\"" + execute("DROP EXTENSION IF EXISTS \"citext\"") end - end diff --git a/flavours/reflow/repo/migrations/20200523081012_init_pointers.exs b/flavours/reflow/repo/migrations/20200523081012_init_pointers.exs index 7fa1ef977d..4d75827e8e 100644 --- a/flavours/reflow/repo/migrations/20200523081012_init_pointers.exs +++ b/flavours/reflow/repo/migrations/20200523081012_init_pointers.exs @@ -6,9 +6,9 @@ defmodule Bonfire.Repo.Migrations.InitPointers do init_pointers_ulid_extra() init_pointers() end + def down do init_pointers_ulid_extra() init_pointers() end - end diff --git a/flavours/reflow/repo/migrations/20200523081014_init_edges.exs b/flavours/reflow/repo/migrations/20200523081014_init_edges.exs index 523e0e8258..6a9051db55 100644 --- a/flavours/reflow/repo/migrations/20200523081014_init_edges.exs +++ b/flavours/reflow/repo/migrations/20200523081014_init_edges.exs @@ -2,7 +2,6 @@ defmodule Bonfire.Repo.Migrations.InitEdges do use Ecto.Migration alias Bonfire.Data.Edges.Migration - def up do Migration.up() end @@ -10,5 +9,4 @@ defmodule Bonfire.Repo.Migrations.InitEdges do def down do Migration.down() end - end diff --git a/flavours/reflow/repo/migrations/20200818094943_import_ap.exs b/flavours/reflow/repo/migrations/20200818094943_import_ap.exs index 38cea36742..bfdc4815e6 100644 --- a/flavours/reflow/repo/migrations/20200818094943_import_ap.exs +++ b/flavours/reflow/repo/migrations/20200818094943_import_ap.exs @@ -6,5 +6,4 @@ defmodule Bonfire.Federate.ActivityPub.Repo.Migrations.ImportMe do def up, do: migrate_activity_pub def down, do: migrate_activity_pub - end diff --git a/flavours/reflow/repo/migrations/20200820094941_import_boundaries.exs b/flavours/reflow/repo/migrations/20200820094941_import_boundaries.exs index bc21caeec0..f46503012a 100644 --- a/flavours/reflow/repo/migrations/20200820094941_import_boundaries.exs +++ b/flavours/reflow/repo/migrations/20200820094941_import_boundaries.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.ImportBoundaries do def up, do: migrate_boundaries def down, do: migrate_boundaries - end diff --git a/flavours/reflow/repo/migrations/20200828094944_import_me.exs b/flavours/reflow/repo/migrations/20200828094944_import_me.exs index 5b9e9a8c3f..97ac819380 100644 --- a/flavours/reflow/repo/migrations/20200828094944_import_me.exs +++ b/flavours/reflow/repo/migrations/20200828094944_import_me.exs @@ -9,5 +9,4 @@ defmodule Bonfire.Repo.Migrations.ImportMe do end def down, do: migrate_me() - end diff --git a/flavours/reflow/repo/migrations/20200828094945_import_social.exs b/flavours/reflow/repo/migrations/20200828094945_import_social.exs index 3f8c6db408..2ee83ee871 100644 --- a/flavours/reflow/repo/migrations/20200828094945_import_social.exs +++ b/flavours/reflow/repo/migrations/20200828094945_import_social.exs @@ -5,10 +5,8 @@ defmodule Bonfire.Social.Repo.Migrations.ImportSocial do import Pointers.Migration def up do - migrate_social() - end - def down, do: migrate_social() + def down, do: migrate_social() end diff --git a/flavours/reflow/repo/migrations/20200829004946_boundaries_fixtures.exs b/flavours/reflow/repo/migrations/20200829004946_boundaries_fixtures.exs index 87fd61baf6..7a8eb123c7 100644 --- a/flavours/reflow/repo/migrations/20200829004946_boundaries_fixtures.exs +++ b/flavours/reflow/repo/migrations/20200829004946_boundaries_fixtures.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.BoundariesFixtures do def up, do: Bonfire.Boundaries.Fixtures.insert() def down, do: nil - end diff --git a/flavours/reflow/repo/migrations/20201205094943_import_quantify.exs b/flavours/reflow/repo/migrations/20201205094943_import_quantify.exs index 5c0bce0506..4a60dd1763 100644 --- a/flavours/reflow/repo/migrations/20201205094943_import_quantify.exs +++ b/flavours/reflow/repo/migrations/20201205094943_import_quantify.exs @@ -2,12 +2,12 @@ defmodule Bonfire.Repo.Migrations.ImportQuantify do use Ecto.Migration def up do - Bonfire.Quantify.Migrations.change - Bonfire.Quantify.Migrations.change_measure + Bonfire.Quantify.Migrations.change() + Bonfire.Quantify.Migrations.change_measure() end def down do - Bonfire.Quantify.Migrations.change - Bonfire.Quantify.Migrations.change_measure + Bonfire.Quantify.Migrations.change() + Bonfire.Quantify.Migrations.change_measure() end end diff --git a/flavours/reflow/repo/migrations/20201208094940_import_geolocation.exs b/flavours/reflow/repo/migrations/20201208094940_import_geolocation.exs index 479d9e680c..42178a098b 100644 --- a/flavours/reflow/repo/migrations/20201208094940_import_geolocation.exs +++ b/flavours/reflow/repo/migrations/20201208094940_import_geolocation.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportGeolocation do use Ecto.Migration def up do - Bonfire.Geolocate.Migrations.change + Bonfire.Geolocate.Migrations.change() end def down do - Bonfire.Geolocate.Migrations.change + Bonfire.Geolocate.Migrations.change() end end diff --git a/flavours/reflow/repo/migrations/20201212094942_import_valueflows.exs b/flavours/reflow/repo/migrations/20201212094942_import_valueflows.exs index 87b60d305d..17868173f8 100644 --- a/flavours/reflow/repo/migrations/20201212094942_import_valueflows.exs +++ b/flavours/reflow/repo/migrations/20201212094942_import_valueflows.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportValueFlows do use Ecto.Migration def up do - ValueFlows.AllMigrations.up + ValueFlows.AllMigrations.up() end def down do - ValueFlows.AllMigrations.down + ValueFlows.AllMigrations.down() end end diff --git a/flavours/reflow/repo/migrations/20210102094944_import_shared_user.exs b/flavours/reflow/repo/migrations/20210102094944_import_shared_user.exs index 09845637a3..e55a68d7fa 100644 --- a/flavours/reflow/repo/migrations/20210102094944_import_shared_user.exs +++ b/flavours/reflow/repo/migrations/20210102094944_import_shared_user.exs @@ -6,5 +6,4 @@ defmodule Bonfire.Repo.Migrations.ImportSharedUser do def up, do: migrate_shared_user() def down, do: migrate_shared_user() - end diff --git a/flavours/reflow/repo/migrations/20210113094942_import_valueflows_observe.exs b/flavours/reflow/repo/migrations/20210113094942_import_valueflows_observe.exs index f71a9dc765..4f67bd579a 100644 --- a/flavours/reflow/repo/migrations/20210113094942_import_valueflows_observe.exs +++ b/flavours/reflow/repo/migrations/20210113094942_import_valueflows_observe.exs @@ -4,10 +4,10 @@ defmodule Bonfire.Repo.Migrations.ImportValueFlowsObserve do alias ValueFlows.Observe.Migrations def up do - Migrations.up + Migrations.up() end def down do - Migrations.down + Migrations.down() end end diff --git a/flavours/reflow/repo/migrations/20210402105128_ap_test_table.exs b/flavours/reflow/repo/migrations/20210402105128_ap_test_table.exs index 929b6324f6..ecc4b56355 100644 --- a/flavours/reflow/repo/migrations/20210402105128_ap_test_table.exs +++ b/flavours/reflow/repo/migrations/20210402105128_ap_test_table.exs @@ -4,12 +4,12 @@ defmodule ActivityPub.Repo.Migrations.APTestTable do def change do # This table only exists for test purposes create table("local_actor", primary_key: false) do - add :id, :uuid, primary_key: true - add :username, :citext - add :data, :map - add :local, :boolean - add :keys, :text - add :followers, {:array, :string} + add(:id, :uuid, primary_key: true) + add(:username, :citext) + add(:data, :map) + add(:local, :boolean) + add(:keys, :text) + add(:followers, {:array, :string}) end end end diff --git a/flavours/reflow/repo/migrations/20210407094946_message.exs b/flavours/reflow/repo/migrations/20210407094946_message.exs index 9cb0cc34b9..9a23628612 100644 --- a/flavours/reflow/repo/migrations/20210407094946_message.exs +++ b/flavours/reflow/repo/migrations/20210407094946_message.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Repo.Migrations.Message do def up, do: migrate_message() def down, do: migrate_message() - end diff --git a/flavours/reflow/repo/migrations/20210410094945_profile_images.exs b/flavours/reflow/repo/migrations/20210410094945_profile_images.exs index c0a07043eb..8294d2b957 100644 --- a/flavours/reflow/repo/migrations/20210410094945_profile_images.exs +++ b/flavours/reflow/repo/migrations/20210410094945_profile_images.exs @@ -4,15 +4,19 @@ defmodule Bonfire.Social.Repo.Migrations.ProfileImages do import Pointers.Migration def up do + drop_if_exists( + constraint("bonfire_data_social_profile", "bonfire_data_social_profile_icon_id_fkey") + ) - drop_if_exists constraint "bonfire_data_social_profile", "bonfire_data_social_profile_icon_id_fkey" - drop_if_exists constraint "bonfire_data_social_profile", "bonfire_data_social_profile_image_id_fkey" + drop_if_exists( + constraint("bonfire_data_social_profile", "bonfire_data_social_profile_image_id_fkey") + ) alter table("bonfire_data_social_profile") do - Ecto.Migration.add_if_not_exists :icon_id, strong_pointer(Bonfire.Files.Media) - Ecto.Migration.add_if_not_exists :image_id, strong_pointer(Bonfire.Files.Media) + Ecto.Migration.add_if_not_exists(:icon_id, strong_pointer(Bonfire.Files.Media)) + Ecto.Migration.add_if_not_exists(:image_id, strong_pointer(Bonfire.Files.Media)) end end - def down, do: nil + def down, do: nil end diff --git a/flavours/reflow/repo/migrations/20210412094946_fp.exs b/flavours/reflow/repo/migrations/20210412094946_fp.exs index 4e13f8b533..1966abd46a 100644 --- a/flavours/reflow/repo/migrations/20210412094946_fp.exs +++ b/flavours/reflow/repo/migrations/20210412094946_fp.exs @@ -1,7 +1,6 @@ defmodule Bonfire.Repo.Migrations.FP do use Ecto.Migration - def up do execute("create or replace function column_exists(ptable text, pcolumn text, pschema text default 'public') @@ -18,7 +17,8 @@ defmodule Bonfire.Repo.Migrations.FP do ); $body$;") - execute("CREATE OR REPLACE FUNCTION rename_column_if_exists(ptable TEXT, pcolumn TEXT, new_name TEXT) + execute( + "CREATE OR REPLACE FUNCTION rename_column_if_exists(ptable TEXT, pcolumn TEXT, new_name TEXT) RETURNS VOID AS $BODY$ BEGIN -- Rename the column if it exists. @@ -27,14 +27,15 @@ defmodule Bonfire.Repo.Migrations.FP do ptable, pcolumn, new_name); END IF; END$BODY$ - LANGUAGE plpgsql VOLATILE;") + LANGUAGE plpgsql VOLATILE;" + ) flush() - execute("SELECT rename_column_if_exists('bonfire_data_social_feed_publish', 'object_id', 'activity_id') ") - + execute( + "SELECT rename_column_if_exists('bonfire_data_social_feed_publish', 'object_id', 'activity_id') " + ) end def down, do: nil - end diff --git a/flavours/reflow/repo/migrations/20210618094945_peered_uri.exs b/flavours/reflow/repo/migrations/20210618094945_peered_uri.exs index ce0bb3c412..1aff450e95 100644 --- a/flavours/reflow/repo/migrations/20210618094945_peered_uri.exs +++ b/flavours/reflow/repo/migrations/20210618094945_peered_uri.exs @@ -5,9 +5,9 @@ defmodule Bonfire.Social.Repo.Migrations.PeeredURI do def up do alter table("bonfire_data_activity_pub_peered") do - Ecto.Migration.add_if_not_exists :canonical_uri, :text, null: true + Ecto.Migration.add_if_not_exists(:canonical_uri, :text, null: true) end end - def down, do: nil + def down, do: nil end diff --git a/flavours/reflow/repo/migrations/20210925094942_import_classify.exs b/flavours/reflow/repo/migrations/20210925094942_import_classify.exs index 2f83f7b214..d8c04f13ec 100644 --- a/flavours/reflow/repo/migrations/20210925094942_import_classify.exs +++ b/flavours/reflow/repo/migrations/20210925094942_import_classify.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportClassify do use Ecto.Migration def up do - Bonfire.Classify.Migrations.up + Bonfire.Classify.Migrations.up() end def down do - Bonfire.Classify.Migrations.down + Bonfire.Classify.Migrations.down() end end diff --git a/flavours/reflow/repo/migrations/20211001094942_import_assort_ranked.exs b/flavours/reflow/repo/migrations/20211001094942_import_assort_ranked.exs index daf2c99385..93aaa5b18e 100644 --- a/flavours/reflow/repo/migrations/20211001094942_import_assort_ranked.exs +++ b/flavours/reflow/repo/migrations/20211001094942_import_assort_ranked.exs @@ -2,7 +2,6 @@ defmodule Bonfire.Repo.Migrations.ImportRanked do use Ecto.Migration require Bonfire.Data.Assort.Ranked.Migration - def up, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked - def down, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked - + def up, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked() + def down, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked() end diff --git a/flavours/reflow/repo/migrations/20211112094942_import_commitment_satisfaction.exs b/flavours/reflow/repo/migrations/20211112094942_import_commitment_satisfaction.exs index 8e08f938ed..fc46a93de8 100644 --- a/flavours/reflow/repo/migrations/20211112094942_import_commitment_satisfaction.exs +++ b/flavours/reflow/repo/migrations/20211112094942_import_commitment_satisfaction.exs @@ -3,7 +3,7 @@ defmodule Bonfire.Repo.Migrations.ImportCommitmentSatisfaction do def up do ValueFlows.Planning.Commitment.Migrations.up() - ValueFlows.Planning.Satisfaction.Migrations.up() + ValueFlows.Planning.Satisfaction.Migrations.up() end def down do diff --git a/flavours/reflow/repo/migrations/20220208094942_import_invite_link.exs b/flavours/reflow/repo/migrations/20220208094942_import_invite_link.exs index aead406a7e..4fa8d4f44c 100644 --- a/flavours/reflow/repo/migrations/20220208094942_import_invite_link.exs +++ b/flavours/reflow/repo/migrations/20220208094942_import_invite_link.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportInviteLink do use Ecto.Migration def up do - Bonfire.Invites.Link.Migration.up + Bonfire.Invites.Link.Migration.up() end def down do - Bonfire.Invites.Link.Migration.down + Bonfire.Invites.Link.Migration.down() end end diff --git a/flavours/reflow/repo/migrations/20220304081300_care_closure.exs b/flavours/reflow/repo/migrations/20220304081300_care_closure.exs index 30a0dbc621..2e41085d5c 100644 --- a/flavours/reflow/repo/migrations/20220304081300_care_closure.exs +++ b/flavours/reflow/repo/migrations/20220304081300_care_closure.exs @@ -4,5 +4,4 @@ defmodule Bonfire.Data.Identity.Repo.Migrations.CareClosure do alias Bonfire.Data.Identity.CareClosure.Migration def change, do: Migration.migrate_care_closure_view() - end diff --git a/flavours/reflow/repo/migrations/20220408094940_settings.exs b/flavours/reflow/repo/migrations/20220408094940_settings.exs index c7a22dcd23..57f6ac5987 100644 --- a/flavours/reflow/repo/migrations/20220408094940_settings.exs +++ b/flavours/reflow/repo/migrations/20220408094940_settings.exs @@ -2,7 +2,7 @@ defmodule Bonfire.Repo.Migrations.ImportSettings do use Ecto.Migration require Bonfire.Data.Identity.Settings.Migration - def up do + def up do Bonfire.Data.Identity.Settings.Migration.migrate_settings(:up) end diff --git a/flavours/reflow/repo/migrations/20220428094200_add_files_mixin.exs b/flavours/reflow/repo/migrations/20220428094200_add_files_mixin.exs index 0fd23546a9..ae2f93b48f 100644 --- a/flavours/reflow/repo/migrations/20220428094200_add_files_mixin.exs +++ b/flavours/reflow/repo/migrations/20220428094200_add_files_mixin.exs @@ -5,9 +5,10 @@ defmodule Bonfire.Repo.Migrations.AddFilesMixin do 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 + # cleanup old stuff + alter table("bonfire_files_media") do + remove_if_exists(:created_at, :utc_datetime_usec) + remove_if_exists(:updated_at, :utc_datetime_usec) end Bonfire.Files.Migrations.migrate_files() diff --git a/flavours/reflow/repo/seeds.exs b/flavours/reflow/repo/seeds.exs index 930c8c6bff..7504f8e90b 100755 --- a/flavours/reflow/repo/seeds.exs +++ b/flavours/reflow/repo/seeds.exs @@ -3,28 +3,30 @@ import Bonfire.Me.Fake System.put_env("INVITE_ONLY", "false") System.put_env("SEARCH_INDEXING_DISABLED", "true") -%{ - preferred_username: System.get_env("SEEDS_USER", "root"), - name: System.get_env("SEEDS_USER", "Seed User") -} -|> fake_user!(%{confirm_email: true}) +fake_user!( + %{ + preferred_username: System.get_env("SEEDS_USER", "root"), + name: System.get_env("SEEDS_USER", "Seed User") + }, + %{confirm_email: true} +) # create some users users = for _ <- 1..2, do: fake_user!() random_user = fn -> Faker.Util.pick(users) end # start some communities -#communities = for _ <- 1..2, do: fake_community!(random_user.()) -#subcommunities = for _ <- 1..2, do: fake_community!(random_user.(), Faker.Util.pick(communities)) -#maybe_random_community = fn -> maybe_one_of(communities ++ subcommunities) end +# communities = for _ <- 1..2, do: fake_community!(random_user.()) +# subcommunities = for _ <- 1..2, do: fake_community!(random_user.(), Faker.Util.pick(communities)) +# maybe_random_community = fn -> maybe_one_of(communities ++ subcommunities) end # create fake collections -#collections = for _ <- 1..4, do: fake_collection!(random_user.(), maybe_random_community.()) -#subcollections = for _ <- 1..2, do: fake_collection!(random_user.(), Faker.Util.pick(collections)) -#maybe_random_collection = fn -> maybe_one_of(collections ++ subcollections) end +# collections = for _ <- 1..4, do: fake_collection!(random_user.(), maybe_random_community.()) +# subcollections = for _ <- 1..2, do: fake_collection!(random_user.(), Faker.Util.pick(collections)) +# maybe_random_collection = fn -> maybe_one_of(collections ++ subcollections) end # start fake threads -#for _ <- 1..3 do +# for _ <- 1..3 do # user = random_user.() # thread = fake_thread!(user, maybe_random_community.()) # comment = fake_comment!(user, thread) @@ -32,18 +34,18 @@ random_user = fn -> Faker.Util.pick(users) end # reply = fake_comment!(random_user.(), thread, %{in_reply_to_id: comment.id}) # subreply = fake_comment!(random_user.(), thread, %{in_reply_to_id: reply.id}) # subreply2 = fake_comment!(random_user.(), thread, %{in_reply_to_id: subreply.id}) -#end +# end # ## more fake threads -#for _ <- 1..2 do +# for _ <- 1..2 do # user = random_user.() # thread = fake_thread!(user, maybe_random_collection.()) # comment = fake_comment!(user, thread) -#end +# end # post some links/resources -#for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_community.()) -#for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_collection.()) +# for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_community.()) +# for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_collection.()) # define some tags/categories if(Bonfire.Common.Extend.extension_enabled?(Bonfire.Classify.Simulate)) do @@ -89,18 +91,22 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do # some proposed intents action_id = ValueFlows.Simulate.action_id() - intent = ValueFlows.Simulate.fake_intent!(user, %{resource_conforms_to: res_spec, action_id: action_id}) + + intent = + ValueFlows.Simulate.fake_intent!(user, %{ + resource_conforms_to: res_spec, + action_id: action_id + }) + proposal = ValueFlows.Simulate.fake_proposal!(user) ValueFlows.Simulate.fake_proposed_to!(random_user.(), proposal) ValueFlows.Simulate.fake_proposed_intent!(proposal, intent) # define some geolocations if(Bonfire.Common.Extend.extension_enabled?(Bonfire.Geolocate.Simulate)) do - places = for _ <- 1..2, do: Bonfire.Geolocate.Simulate.fake_geolocation!(random_user.()) random_place = fn -> Faker.Util.pick(places) end - for _ <- 1..2 do # define some intents with geolocation _intent = @@ -110,7 +116,8 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do ) # define some proposals with geolocation - _proposal = ValueFlows.Simulate.fake_proposal!(user, %{eligible_location: random_place.()}) + _proposal = + ValueFlows.Simulate.fake_proposal!(user, %{eligible_location: random_place.()}) # both with geo intent = @@ -125,8 +132,13 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do # some economic events user = random_user.() - resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(user, %{current_location: random_place.()}) - to_resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{current_location: random_place.()}) + resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(user, %{current_location: random_place.()}) + + to_resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{ + current_location: random_place.() + }) ValueFlows.Simulate.fake_economic_event!( user, @@ -162,7 +174,9 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do unit = Faker.Util.pick([unit1, unit2]) resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(user, %{}, unit) - to_resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{}, unit) + + to_resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{}, unit) ValueFlows.Simulate.fake_economic_event!( user, diff --git a/flavours/reflow/repo/seeds/20210122131234_observe_classifications.exs b/flavours/reflow/repo/seeds/20210122131234_observe_classifications.exs index 098393c298..05581b6cc5 100755 --- a/flavours/reflow/repo/seeds/20210122131234_observe_classifications.exs +++ b/flavours/reflow/repo/seeds/20210122131234_observe_classifications.exs @@ -1,7 +1,7 @@ defmodule Bonfire.Repo.Seeds.ObserveClassifications do use Bonfire.Seeder - envs [:dev, :prod, :test] + envs([:dev, :prod, :test]) def up(repo), do: ValueFlows.Observe.Seeds.up(repo) end diff --git a/flavours/upcycle/config/bonfire_data.exs b/flavours/upcycle/config/bonfire_data.exs index 9e1edc00bc..3298a6b001 100644 --- a/flavours/upcycle/config/bonfire_data.exs +++ b/flavours/upcycle/config/bonfire_data.exs @@ -2,51 +2,69 @@ import Config #### Base configuration -verbs = ["Boost", "Create", "Delete", "Edit", "Flag", "Follow", "Like", "Mention", - "Message", "Read", "Reply", "Request", "See", "Tag"] +verbs = [ + "Boost", + "Create", + "Delete", + "Edit", + "Flag", + "Follow", + "Like", + "Mention", + "Message", + "Read", + "Reply", + "Request", + "See", + "Tag" +] # 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 +config :bonfire_data_identity, Bonfire.Data.Identity.Credential, hasher_module: hasher #### Sentinel Data Services # Search these apps/extensions for Pointable ecto schema definitions to index pointable_schema_extensions = [ - :bonfire, - :bonfire_data_access_control, - :bonfire_data_activity_pub, - :bonfire_data_identity, - :bonfire_data_social, - :bonfire_data_edges, - :bonfire_tag, - :bonfire_classify, - :bonfire_data_shared_users, - :bonfire_files, - :bonfire_quantify, - :bonfire_geolocate, - :bonfire_valueflows, - :bonfire_valueflows_observe, - ] + :bonfire, + :bonfire_data_access_control, + :bonfire_data_activity_pub, + :bonfire_data_identity, + :bonfire_data_social, + :bonfire_data_edges, + :bonfire_tag, + :bonfire_classify, + :bonfire_data_shared_users, + :bonfire_files, + :bonfire_quantify, + :bonfire_geolocate, + :bonfire_valueflows, + :bonfire_valueflows_observe +] + 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, - ] +context_and_queries_extensions = + pointable_schema_extensions ++ + [ + :bonfire_common, + :bonfire_me, + :bonfire_social + ] -extensions_with_config = context_and_queries_extensions ++ [ - :bonfire_boundaries, - :bonfire_federate_activitypub, - :bonfire_search, - :bonfire_mailer, - :bonfire_geolocate - ] +extensions_with_config = + context_and_queries_extensions ++ + [ + :bonfire_boundaries, + :bonfire_federate_activitypub, + :bonfire_search, + :bonfire_mailer, + :bonfire_geolocate + ] config :bonfire, :verb_names, verbs config :bonfire, :context_modules_search_path, context_and_queries_extensions @@ -57,31 +75,74 @@ config :bonfire, :config_modules_search_path, extensions_with_config config :bonfire_data_access_control, search_path: [ # :bonfire_me, - :bonfire_boundaries, + :bonfire_boundaries + # :bonfire_social, # :bonfire, ] #### Alias modules for readability -alias Pointers.{Pointer, Table} -alias Bonfire.Data.AccessControl.{ - Acl, Circle, Encircle, Controlled, InstanceAdmin, Grant, Verb, -} -alias Bonfire.Data.ActivityPub.{Actor, Peer, Peered} -alias Bonfire.Boundaries.{Permitted, Stereotyped} -alias Bonfire.Data.Edges.{Edge,EdgeTotal} -alias Bonfire.Data.Identity.{ - Account, Accounted, AuthSecondFactor, Caretaker, CareClosure, Character, Credential, Email, ExtraInfo, Named, Self, Settings, User, -} -alias Bonfire.Data.Social.{ - Activity, APActivity, Article, Block, Bookmark, Boost, Created, Feed, FeedPublish, - Flag, Follow, Like, Mention, Message, Post, PostContent, Profile, Replied, Request, -} +alias Pointers.Pointer +alias Pointers.Table + +alias Bonfire.Data.AccessControl.Acl +alias Bonfire.Data.AccessControl.Circle +alias Bonfire.Data.AccessControl.Encircle +alias Bonfire.Data.AccessControl.Controlled +alias Bonfire.Data.AccessControl.InstanceAdmin +alias Bonfire.Data.AccessControl.Grant +alias Bonfire.Data.AccessControl.Verb + +alias Bonfire.Data.ActivityPub.Actor +alias Bonfire.Data.ActivityPub.Peer +alias Bonfire.Data.ActivityPub.Peered + +alias Bonfire.Boundaries.Permitted +alias Bonfire.Boundaries.Stereotyped + +alias Bonfire.Data.Edges.Edge +alias Bonfire.Data.Edges.EdgeTotal + +alias Bonfire.Data.Identity.Account +alias Bonfire.Data.Identity.Accounted +alias Bonfire.Data.Identity.AuthSecondFactor +alias Bonfire.Data.Identity.Caretaker +alias Bonfire.Data.Identity.CareClosure +alias Bonfire.Data.Identity.Character +alias Bonfire.Data.Identity.Credential +alias Bonfire.Data.Identity.Email +alias Bonfire.Data.Identity.ExtraInfo +alias Bonfire.Data.Identity.Named +alias Bonfire.Data.Identity.Self +alias Bonfire.Data.Identity.Settings +alias Bonfire.Data.Identity.User + +alias Bonfire.Data.Social.Activity +alias Bonfire.Data.Social.APActivity +alias Bonfire.Data.Social.Article +alias Bonfire.Data.Social.Block +alias Bonfire.Data.Social.Bookmark +alias Bonfire.Data.Social.Boost +alias Bonfire.Data.Social.Created +alias Bonfire.Data.Social.Feed +alias Bonfire.Data.Social.FeedPublish +alias Bonfire.Data.Social.Flag +alias Bonfire.Data.Social.Follow +alias Bonfire.Data.Social.Like +alias Bonfire.Data.Social.Mention +alias Bonfire.Data.Social.Message +alias Bonfire.Data.Social.Post +alias Bonfire.Data.Social.PostContent +alias Bonfire.Data.Social.Profile +alias Bonfire.Data.Social.Replied +alias Bonfire.Data.Social.Request + alias Bonfire.Classify.Category alias Bonfire.Geolocate.Geolocation alias Bonfire.Files alias Bonfire.Files.Media -alias Bonfire.{Tag, Tag.Tagged} +alias Bonfire.Tag +alias Bonfire.Tag.Tagged #### Flexto Stitching @@ -97,177 +158,234 @@ common_assocs = %{ ### Mixins # A summary of an object that can appear in a feed. - activity: quote(do: has_one(:activity, unquote(Activity), unquote(mixin))), + activity: quote(do: has_one(:activity, unquote(Activity), unquote(mixin))), # ActivityPub actor information - actor: quote(do: has_one(:actor, unquote(Actor), unquote(mixin))), + actor: quote(do: has_one(:actor, unquote(Actor), unquote(mixin))), # Indicates the entity responsible for an activity. Sort of like creator, but transferrable. Used # during deletion - when the caretaker is deleted, all their stuff will be too. - caretaker: quote(do: has_one(:caretaker, unquote(Caretaker), unquote(mixin))), + caretaker: quote(do: has_one(:caretaker, unquote(Caretaker), unquote(mixin))), # A Character has a unique username and some feeds. - character: quote(do: has_one(:character, unquote(Character), unquote(mixin))), + character: quote(do: has_one(:character, unquote(Character), unquote(mixin))), # Indicates the creator of an object - created: quote(do: has_one(:created, unquote(Created), unquote(mixin))), + created: quote(do: has_one(:created, unquote(Created), unquote(mixin))), # Used for non-textual interactions such as likes and follows to indicate the other object. - edge: quote(do: has_one(:edge, unquote(Edge), unquote(mixin))), + edge: quote(do: has_one(:edge, unquote(Edge), unquote(mixin))), # Adds a name that can appear in the user interface for an object. e.g. for an ACL. - named: quote(do: has_one(:named, unquote(Named), unquote(mixin))), + named: quote(do: has_one(:named, unquote(Named), unquote(mixin))), # Adds extra info that can appear in the user interface for an object. e.g. a summary or JSON-encoded data. - extra_info: quote(do: has_one(:extra_info, unquote(ExtraInfo), unquote(mixin))), + extra_info: quote(do: has_one(:extra_info, unquote(ExtraInfo), unquote(mixin))), # Information about the remote instance the object is from, if it is not local. - peered: quote(do: has_one(:peered, unquote(Peered), unquote(mixin))), + peered: quote(do: has_one(:peered, unquote(Peered), unquote(mixin))), # Information about the content of posts, e.g. a scrubbed html body post_content: quote(do: has_one(:post_content, unquote(PostContent), unquote(mixin))), # Information about a user or other object that they wish to make available - profile: quote(do: has_one(:profile, unquote(Profile), unquote(mixin))), + profile: quote(do: has_one(:profile, unquote(Profile), unquote(mixin))), # Threading information, for threaded discussions. - replied: quote(do: has_one(:replied, unquote(Replied), unquote(mixin))), + replied: quote(do: has_one(:replied, unquote(Replied), unquote(mixin))), # Information that allows the system to identify special system-managed ACLS. - stereotyped: quote(do: has_one(:stereotyped, unquote(Stereotyped), unquote(mixin))), - + stereotyped: quote(do: has_one(:stereotyped, unquote(Stereotyped), unquote(mixin))), ### Multimixins # Links to access control information for this object. - controlled: quote(do: has_many(:controlled, unquote(Controlled), unquote(mixin))), + 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))), + 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)), + 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))), + 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)), - + 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 # The objects which reply to this object. - direct_replies: quote(do: has_many(:direct_replies, unquote(Replied), foreign_key: :reply_to_id)), + direct_replies: + quote(do: has_many(:direct_replies, unquote(Replied), foreign_key: :reply_to_id)), # A recursive view of caretakers of caretakers of... used during deletion. - care_closure: quote(do: has_many(:care_closure, unquote(CareClosure), foreign_key: :branch_id)), + care_closure: quote(do: has_many(:care_closure, unquote(CareClosure), foreign_key: :branch_id)), # Retrieves activities where we are the object. e.g. if we are a # post or a user, this could turn up activities from likes or follows. - activities: quote(do: has_many(:activities, unquote(Activity), foreign_key: :object_id, references: :id)), + activities: + quote(do: has_many(:activities, unquote(Activity), foreign_key: :object_id, references: :id)), ### Stuff I'm not sure how to categorise yet # Used currently only for requesting to follow a user, but more general - request: quote(do: has_one(:request, unquote(Request), unquote(mixin))), + request: quote(do: has_one(:request, unquote(Request), unquote(mixin))) } # retrieves a list of quoted forms suitable for use with unquote_splicing common = fn names -> for name <- List.wrap(names) do with nil <- common_assocs[name], - do: raise(RuntimeError, message: "Expected a common association name, got #{inspect(name)}") + do: + raise(RuntimeError, message: "Expected a common association name, got #{inspect(name)}") end end -edge = common.([:controlled, :activities, :request, :created]) -edges = common.([:controlled, :activities, :request, :created, :caretaker, :activity, :feed_publishes]) +edge = common.([:controlled, :activities, :request, :created]) + +edges = + common.([:controlled, :activities, :request, :created, :caretaker, :activity, :feed_publishes]) # first up, pointers could have all the mixins we're using. TODO -pointer_mixins = common.([ - :activity, :actor, :caretaker, :character, :created, :edge, - :named, :extra_info, :peered, :post_content, :profile, :replied, :stereotyped -]) +pointer_mixins = + common.([ + :activity, + :actor, + :caretaker, + :character, + :created, + :edge, + :named, + :extra_info, + :peered, + :post_content, + :profile, + :replied, + :stereotyped + ]) + config :pointers, Pointer, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - field :dummy, :any, virtual: true - # pointables - has_one :circle, unquote(Circle), foreign_key: :id - many_to_many :encircle_subjects, Pointer, join_through: Encircle, join_keys: [circle_id: :id, subject_id: :id] - has_one :permitted, unquote(Permitted), foreign_key: :object_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 - has_one :category, unquote(Category), foreign_key: :id - has_one :geolocation, unquote(Geolocation), foreign_key: :id - # mixins - unquote_splicing(pointer_mixins) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media])) - # has_many - unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes])) + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + field(:dummy, :any, virtual: true) + # pointables + has_one(:circle, unquote(Circle), foreign_key: :id) - ## special things - # these should go away in future and they should be populated by a single query. - 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] + many_to_many(:encircle_subjects, Pointer, + join_through: Encircle, + join_keys: [circle_id: :id, subject_id: :id] + ) - end] + has_one(:permitted, unquote(Permitted), foreign_key: :object_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) + has_one(:category, unquote(Category), foreign_key: :id) + has_one(:geolocation, unquote(Geolocation), foreign_key: :id) + # mixins + unquote_splicing(pointer_mixins) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media])) + # has_many + unquote_splicing(common.([:activities, :care_closure, :direct_replies, :feed_publishes])) + + ## special things + # these should go away in future and they should be populated by a single query. + 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] + ) + end) config :pointers, Table, [] # now let's weave everything else together for convenience - # bonfire_data_access_control config :bonfire_data_access_control, Acl, - [code: quote do - field :grants_count, :integer, virtual: true - field :controlled_count, :integer, virtual: true - # mixins - unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) - # multimixins - # unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:grants_count, :integer, virtual: true) + field(:controlled_count, :integer, virtual: true) + # mixins + unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) + + # multimixins + # unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Circle, - [code: quote do - field :encircles_count, :integer, virtual: true - # mixins - unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) - # multimixins - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:encircles_count, :integer, virtual: true) + # mixins + unquote_splicing(common.([:caretaker, :named, :extra_info, :stereotyped])) + # multimixins + unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Controlled, [] config :bonfire_data_access_control, Encircle, - [code: quote do - has_one :peer, unquote(Peer), foreign_key: :id, references: :subject_id - end] + code: + (quote do + has_one(:peer, unquote(Peer), foreign_key: :id, references: :subject_id) + end) config :bonfire_data_access_control, Grant, - [code: quote do - # mixins - unquote_splicing(common.([:caretaker])) - # multimixins - # unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:caretaker]))) + + # multimixins + # unquote_splicing(common.([:controlled])) + end) config :bonfire_data_access_control, Verb, [] config :bonfire_boundaries, Stereotyped, - [code: quote do - has_one(:named, unquote(Named), [foreign_key: :id, references: :stereotype_id]) - end] + code: + (quote do + has_one(:named, unquote(Named), foreign_key: :id, references: :stereotype_id) + end) # bonfire_data_activity_pub config :bonfire_data_activity_pub, Actor, - [code: quote do - # hacks - belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - # mixins - unquote_splicing(common.([:peered])) - # multimixins - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + # hacks + belongs_to(:character, unquote(Character), foreign_key: :id, define_field: false) + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + # mixins + unquote_splicing(common.([:peered])) + # multimixins + unquote_splicing(common.([:controlled])) + end) config :bonfire_data_activity_pub, Peer, [] config :bonfire_data_activity_pub, Peered, [] @@ -275,86 +393,128 @@ config :bonfire_data_activity_pub, Peered, [] # bonfire_data_identity config :bonfire_data_identity, Account, - [code: quote do - has_one :credential, unquote(Credential),foreign_key: :id - has_one :email, unquote(Email), foreign_key: :id - has_one :auth_second_factor, unquote(AuthSecondFactor), foreign_key: :id - has_one :settings, unquote(Settings), foreign_key: :id - many_to_many :users, unquote(User), - join_through: Accounted, - join_keys: [account_id: :id, id: :id] - many_to_many :shared_users, unquote(User), # optional - join_through: "bonfire_data_shared_user_accounts", - join_keys: [account_id: :id, shared_user_id: :id] - end] + code: + (quote do + has_one(:credential, unquote(Credential), foreign_key: :id) + has_one(:email, unquote(Email), foreign_key: :id) + has_one(:auth_second_factor, unquote(AuthSecondFactor), foreign_key: :id) + has_one(:settings, unquote(Settings), foreign_key: :id) + + many_to_many(:users, unquote(User), + join_through: Accounted, + join_keys: [account_id: :id, id: :id] + ) + + # optional + many_to_many(:shared_users, unquote(User), + join_through: "bonfire_data_shared_user_accounts", + join_keys: [account_id: :id, shared_user_id: :id] + ) + end) config :bonfire_data_identity, Accounted, - [code: quote do - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Caretaker, - [code: quote do - has_one :user, unquote(User), foreign_key: :id, references: :caretaker_id - # mixins - unquote_splicing(common.([:character, :profile])) - end] + code: + (quote do + has_one(:user, unquote(User), foreign_key: :id, references: :caretaker_id) + # mixins + unquote_splicing(common.([:character, :profile])) + end) config :bonfire_data_identity, Character, - [code: quote do - @follow_ulid "70110WTHE1EADER1EADER1EADE" - # mixins - unquote_splicing(common.([:actor, :peered, :profile])) - has_one :user, unquote(User), unquote(mixin) - has_one :feed, unquote(Feed), unquote(mixin) - has_many :followers, unquote(Follow), foreign_key: :following_id, references: :id - has_many :followed, unquote(Follow), foreign_key: :follower_id, references: :id - has_one :follow_count, unquote(EdgeTotal), foreign_key: :id, references: :id, - where: [table_id: @follow_ulid] - end] + code: + (quote do + @follow_ulid "70110WTHE1EADER1EADER1EADE" + # mixins + unquote_splicing(common.([:actor, :peered, :profile])) + has_one(:user, unquote(User), unquote(mixin)) + has_one(:feed, unquote(Feed), unquote(mixin)) + has_many(:followers, unquote(Follow), foreign_key: :following_id, references: :id) + has_many(:followed, unquote(Follow), foreign_key: :follower_id, references: :id) + + has_one(:follow_count, unquote(EdgeTotal), + foreign_key: :id, + references: :id, + where: [table_id: @follow_ulid] + ) + end) config :bonfire_data_identity, Credential, - [code: quote do - belongs_to :account, unquote(Account), foreign_key: :id, define_field: false - end] + code: + (quote do + belongs_to(:account, unquote(Account), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Email, - [must_confirm: true, - code: quote do - belongs_to :account, unquote(Account), foreign_key: :id, define_field: false - end] + must_confirm: true, + code: + (quote do + belongs_to(:account, unquote(Account), foreign_key: :id, define_field: false) + end) config :bonfire_data_identity, Self, [] config :bonfire_data_identity, User, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - # mixins - has_one :accounted, unquote(Accounted), foreign_key: :id - has_one :instance_admin, unquote(InstanceAdmin), foreign_key: :id, on_replace: :update - has_one :self, unquote(Self), foreign_key: :id - has_one :shared_user, unquote(Bonfire.Data.SharedUser), foreign_key: :id - has_one :settings, unquote(Settings), foreign_key: :id - unquote_splicing(common.([:actor, :character, :created, :peered, :profile])) - # multimixins - unquote_splicing(common.([:controlled])) - # manies - has_many :encircles, unquote(Encircle), foreign_key: :subject_id - has_many :creations, through: [:created, :pointer] # todo: stop through - has_many :posts, through: [:created, :post] # todo: stop through - has_many :followers, unquote(Edge), foreign_key: :object_id, references: :id, where: [table_id: @follow_ulid] - has_many :followed, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @follow_ulid] - has_many :user_activities, unquote(Activity), foreign_key: :subject_id, references: :id - has_many :boost_activities, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @boost_ulid] - has_many :like_activities, unquote(Edge), foreign_key: :subject_id, references: :id, where: [table_id: @like_ulid] - many_to_many :caretaker_accounts, unquote(Account), - 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 # enable if using Geolocate extension - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + # mixins + has_one(:accounted, unquote(Accounted), foreign_key: :id) + has_one(:instance_admin, unquote(InstanceAdmin), foreign_key: :id, on_replace: :update) + has_one(:self, unquote(Self), foreign_key: :id) + has_one(:shared_user, unquote(Bonfire.Data.SharedUser), foreign_key: :id) + has_one(:settings, unquote(Settings), foreign_key: :id) + unquote_splicing(common.([:actor, :character, :created, :peered, :profile])) + # multimixins + unquote_splicing(common.([:controlled])) + # manies + has_many(:encircles, unquote(Encircle), foreign_key: :subject_id) + # todo: stop through + has_many(:creations, through: [:created, :pointer]) + # todo: stop through + has_many(:posts, through: [:created, :post]) + + has_many(:followers, unquote(Edge), + foreign_key: :object_id, + references: :id, + where: [table_id: @follow_ulid] + ) + + has_many(:followed, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @follow_ulid] + ) + + has_many(:user_activities, unquote(Activity), foreign_key: :subject_id, references: :id) + + has_many(:boost_activities, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @boost_ulid] + ) + + has_many(:like_activities, unquote(Edge), + foreign_key: :subject_id, + references: :id, + where: [table_id: @like_ulid] + ) + + many_to_many(:caretaker_accounts, unquote(Account), + 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 # enable if using Geolocate extension + end) config :bonfire_data_identity, Named, [] config :bonfire_data_identity, ExtraInfo, [] @@ -362,328 +522,439 @@ config :bonfire_data_identity, ExtraInfo, [] ### bonfire_data_social config :bonfire_data_social, Activity, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - @follow_ulid "70110WTHE1EADER1EADER1EADE" - has_many :feed_publishes, unquote(FeedPublish), unquote(mixin) - has_one :seen, unquote(Edge), foreign_key: :object_id, references: :id - # ugly workaround needed for certain queries (TODO: check if still needed) - has_one :activity, unquote(Activity), foreign_key: :id, references: :id - # 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] - has_many :controlled, unquote(Controlled), foreign_key: :id, references: :object_id - has_many :tagged, unquote(Tagged), foreign_key: :id, references: :object_id - many_to_many :tags, unquote(Pointer), - join_through: unquote(Tagged), - 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] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + @follow_ulid "70110WTHE1EADER1EADER1EADE" + has_many(:feed_publishes, unquote(FeedPublish), unquote(mixin)) + has_one(:seen, unquote(Edge), foreign_key: :object_id, references: :id) + # ugly workaround needed for certain queries (TODO: check if still needed) + has_one(:activity, unquote(Activity), foreign_key: :id, references: :id) + # 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] + ) + + has_many(:controlled, unquote(Controlled), foreign_key: :id, references: :object_id) + has_many(:tagged, unquote(Tagged), foreign_key: :id, references: :object_id) + + many_to_many(:tags, unquote(Pointer), + join_through: unquote(Tagged), + 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, - [code: quote do - unquote_splicing(common.([:activity, :caretaker, :controlled])) - end] + code: + (quote do + (unquote_splicing(common.([:activity, :caretaker, :controlled]))) + end) config :bonfire_data_edges, Edge, - [code: quote do - unquote_splicing(edge) - # TODO: requires composite foreign keys: - # has_one :activity, unquote(Activity), - # foreign_key: [:table_id, :object_id], references: [:table_id, :object_id] - end] + code: + (quote do + (unquote_splicing(edge)) + + # TODO: requires composite foreign keys: + # has_one :activity, unquote(Activity), + # foreign_key: [:table_id, :object_id], references: [:table_id, :object_id] + end) config :bonfire_data_social, Feed, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker])) - # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - # belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + # mixins + (unquote_splicing(common.([:activity, :caretaker]))) + + # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false + # belongs_to :user, unquote(User), foreign_key: :id, define_field: false + end) config :bonfire_data_social, FeedPublish, - [code: quote do - field :dummy, :any, virtual: true - has_one :activity, unquote(Activity), foreign_key: :object_id, references: :id - # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false - # belongs_to :user, unquote(User), foreign_key: :id, define_field: false - end] + code: + (quote do + field(:dummy, :any, virtual: true) + has_one(:activity, unquote(Activity), foreign_key: :object_id, references: :id) + # belongs_to :character, unquote(Character), foreign_key: :id, define_field: false + # belongs_to :user, unquote(User), foreign_key: :id, define_field: false + end) config :bonfire_data_social, Follow, - [code: quote do - unquote_splicing(edges) - end] - # 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}] + code: + (quote do + (unquote_splicing(edges)) + end) + +# 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}] config :bonfire_data_social, Block, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Boost, - [code: quote do - unquote_splicing(edges) - end] - # has_one: [activity: {Activity, foreign_key: :object_id, references: :boosted_id}] # requires an ON clause + code: + (quote do + (unquote_splicing(edges)) + end) + +# has_one: [activity: {Activity, foreign_key: :object_id, references: :boosted_id}] # requires an ON clause config :bonfire_data_social, Like, - [code: quote do - unquote_splicing(edges) - end] - # has_one: [activity: {Activity, foreign_key: :object_id, references: :liked_id}] # requires an ON clause + code: + (quote do + (unquote_splicing(edges)) + end) + +# has_one: [activity: {Activity, foreign_key: :object_id, references: :liked_id}] # requires an ON clause config :bonfire_data_social, Flag, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Request, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Bookmark, - [code: quote do - unquote_splicing(edges) - end] + code: + (quote do + (unquote_splicing(edges)) + end) config :bonfire_data_social, Message, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - # mixins - unquote_splicing(common.([:activity, :caretaker, :created, :peered, :post_content, :replied])) - # multimixins - 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] - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + # mixins + unquote_splicing( + common.([:activity, :caretaker, :created, :peered, :post_content, :replied]) + ) + + # multimixins + 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] + ) + end) config :bonfire_data_social, Mention, [] config :bonfire_data_social, Post, - [code: quote do - @like_ulid "11KES11KET0BE11KEDY0VKN0WS" - @boost_ulid "300STANN0VNCERESHARESH0VTS" - # mixins - unquote_splicing(common.([:activities, :activity, :caretaker, :created, :peered, :post_content, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - # special - has_one :permitted, unquote(Permitted), foreign_key: :object_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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause - # 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 :like_count, unquote(EdgeTotal), - 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] - end] + code: + (quote do + @like_ulid "11KES11KET0BE11KEDY0VKN0WS" + @boost_ulid "300STANN0VNCERESHARESH0VTS" + # mixins + unquote_splicing( + common.([:activities, :activity, :caretaker, :created, :peered, :post_content, :replied]) + ) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :files, :media, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + # special + has_one(:permitted, unquote(Permitted), foreign_key: :object_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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause + # 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(:like_count, unquote(EdgeTotal), + 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] + ) + end) config :bonfire_data_social, PostContent, - [code: quote do - # mixins - unquote_splicing(common.([:created])) - # multimixins - unquote_splicing(common.([:controlled])) - # virtuals for changesets - field :hashtags, {:array, :any}, virtual: true - field :mentions, {:array, :any}, virtual: true - field :urls, {:array, :any}, virtual: true - end] + code: + (quote do + # mixins + unquote_splicing(common.([:created])) + # multimixins + unquote_splicing(common.([:controlled])) + # virtuals for changesets + field(:hashtags, {:array, :any}, virtual: true) + field(:mentions, {:array, :any}, virtual: true) + field(:urls, {:array, :any}, virtual: true) + end) config :bonfire_data_social, Replied, - [code: quote do - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) + code: + (quote do + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) - @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_one :activity, unquote(Activity), foreign_key: :object_id, references: :id - 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 - 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] + @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_one(:activity, unquote(Activity), foreign_key: :object_id, references: :id) + # used in changesets + field(:replying_to, :map, virtual: true) + 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 + ) + + 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) 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 - # mixins - shouldn't be here really - unquote_splicing(common.([:peered])) - has_one :post, unquote(Post), unquote(mixin) # huh? - end] + 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 + ) + + # mixins - shouldn't be here really + unquote_splicing(common.([:peered])) + # huh? + has_one(:post, unquote(Post), unquote(mixin)) + end) config :bonfire_data_social, Profile, - [code: quote do - belongs_to :user, unquote(User), foreign_key: :id, define_field: false - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + belongs_to(:user, unquote(User), foreign_key: :id, define_field: false) + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) + end) ######### other extensions config :bonfire_files, Media, - [code: quote do - field :url, :string, virtual: true - # multimixins - shouldn't be here really - unquote_splicing(common.([:controlled])) - end] + code: + (quote do + field(:url, :string, virtual: true) + # multimixins - shouldn't be here really + unquote_splicing(common.([:controlled])) + end) config :bonfire_classify, Category, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :created, :actor, :peered, :profile, :character])) # TODO :caretaker - # multimixins - unquote_splicing(common.([:controlled, :feed_publishes])) + code: + (quote do + # mixins + # TODO :caretaker + unquote_splicing(common.([:activity, :created, :actor, :peered, :profile, :character])) + # multimixins + unquote_splicing(common.([:controlled, :feed_publishes])) - # add references of tagged objects to any Category - many_to_many :tags, unquote(Pointer), - join_through: unquote(Tagged), - unique: true, - join_keys: [tag_id: :id, id: :id], - on_replace: :delete - end] + # add references of tagged objects to any Category + many_to_many(:tags, unquote(Pointer), + join_through: unquote(Tagged), + unique: true, + join_keys: [tag_id: :id, id: :id], + 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] + 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, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + # TODO :caretaker + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.EconomicResource, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Knowledge.ResourceSpecification, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Process, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Knowledge.ProcessSpecification, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Planning.Intent, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Planning.Commitment, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows, ValueFlows.Proposal, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) config :bonfire_valueflows_observe, ValueFlows.Observe.Observation, - [code: quote do - # mixins - unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) - # multimixins - unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) - # has - unquote_splicing(common.([:direct_replies])) - end] + code: + (quote do + # mixins + unquote_splicing(common.([:activity, :caretaker, :peered, :replied])) + # multimixins + unquote_splicing(common.([:controlled, :tagged, :tags, :feed_publishes])) + # has + unquote_splicing(common.([:direct_replies])) + end) diff --git a/flavours/upcycle/config/bonfire_files.exs b/flavours/upcycle/config/bonfire_files.exs index 7d59d69d8e..004256aaeb 100644 --- a/flavours/upcycle/config/bonfire_files.exs +++ b/flavours/upcycle/config/bonfire_files.exs @@ -4,48 +4,53 @@ import Config # see https://hexdocs.pm/waffle/Waffle.html#module-setup-a-storage-provider config :waffle, storage: Waffle.Storage.Local, - asset_host: "/" # or {:system, "ASSET_HOST"} + # or {:system, "ASSET_HOST"} + 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", -] +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_files, image_media_types: image_media_types config :bonfire_files, all_allowed_media_types: all_allowed_media_types config :bonfire_files, Bonfire.Files.IconUploader, allowed_media_types: image_media_types config :bonfire_files, Bonfire.Files.ImageUploader, allowed_media_types: image_media_types -config :bonfire_files, Bonfire.Files.DocumentUploader, allowed_media_types: all_allowed_media_types + +config :bonfire_files, Bonfire.Files.DocumentUploader, + allowed_media_types: all_allowed_media_types diff --git a/flavours/upcycle/config/bonfire_quantify.exs b/flavours/upcycle/config/bonfire_quantify.exs index 6cfe4174f1..521c304be9 100644 --- a/flavours/upcycle/config/bonfire_quantify.exs +++ b/flavours/upcycle/config/bonfire_quantify.exs @@ -3,4 +3,5 @@ import Config config :bonfire_quantify, templates_path: "lib" -config :bonfire_quantify, Bonfire.Quantify.Units, valid_contexts: [Bonfire.Quantify.Units, Bonfire.Data.Identity.User] +config :bonfire_quantify, Bonfire.Quantify.Units, + valid_contexts: [Bonfire.Quantify.Units, Bonfire.Data.Identity.User] diff --git a/flavours/upcycle/config/bonfire_ui.exs b/flavours/upcycle/config/bonfire_ui.exs index 5c5d3a7398..f21804afc5 100644 --- a/flavours/upcycle/config/bonfire_ui.exs +++ b/flavours/upcycle/config/bonfire_ui.exs @@ -1,91 +1,93 @@ import Config - config :bonfire, :ui, - theme: [ - instance_name: "Bonfire", - instance_icon: "/images/bonfire-icon.png", - instance_image: "https://bonfirenetworks.org/img/brand2.png", - instance_description: "This is a bonfire demo instance for testing purposes" - ], - app_menu_extension_paths: %{ # TODO: make dynamic based on active extensions - "Social" => Bonfire.UI.Social.FeedsLive, - "Breadpub" => Bonfire.Breadpub.Web.HomeLive, - "Kanban" => Bonfire.UI.Kanban.HomeLive, - "Coordination" => Bonfire.UI.Coordination.ProcessesLive - }, - sidebar_components: [ # TODO: make dynamic based on active extensions - {Bonfire.UI.Social.SidebarNavigationLive, []}, - # {Bonfire.UI.Coordination.SidebarNavigationLive, []}, - #{Bonfire.Breadpub.SidebarNavigationLive, []}, - # {Bonfire.UI.ValueFlows.ProcessesListLive, [title: "Processes", process_url: "/process/"]}, - # {Bonfire.UI.ValueFlows.ProcessesListLive, [title: "Lists", process_url: "/breadpub/list/"]} - ], - rich_text_editor: Bonfire.Editor.Quill, - smart_input: [ - post: true, - cw: true, - summary: true - ], - profile: [ - sections: [ # TODO: make dynamic based on active extensions - timeline: Bonfire.UI.Social.ProfileTimelineLive, - # private: Bonfire.UI.Social.MessageThreadsLive, - posts: Bonfire.UI.Social.ProfilePostsLive, - boosts: Bonfire.UI.Social.ProfileBoostsLive, - followers: Bonfire.UI.Social.ProfileFollowsLive, - followed: Bonfire.UI.Social.ProfileFollowsLive, - # inventory: Bonfire.UI.Reflow.ProfileInventoryLive, - ], - navigation: [ - timeline: "timeline", - # inventory: "inventory", - posts: "posts", - boosts: "boosts", - # private: "private", - ], - widgets: [ - ], - ], - smart_input_activities: [ - # offer: "Publish an offer", - # need: "Publish a need", - # transfer_resource: "Transfer a resource", - # produce_resource: "Add a resource", - # intent: "Indicate an itent", - # economic_event: "Record an economic event", - # process: "Define a process" - ], - smart_input_components: [ - post: Bonfire.UI.Social.WritePostContentLive, - economic_event: Bonfire.UI.ValueFlows.SelectEconomicEventLive, - intent: Bonfire.UI.ValueFlows.CreateIntentLive, - process: Bonfire.UI.ValueFlows.CreateProcessSmartInputLive - ], - resource: [ - navigation: [ - timeline: "timeline", - material_passport: "material passport", - ], - widgets: [ - # Bonfire.UI.Social.SubscribeWidgetLive, - Bonfire.UI.ValueFlows.LocationWidgetLive, - Bonfire.UI.Social.HashtagsWidgetLive, - ], - ] - # process: [ - # navigation: [ - # events: "Economic events", - # intents: "Intents", - # # material_passport: "material passport", - # ], - # sections: [ - # events: Bonfire.UI.ValueFlows.EconomicEventsLive, - # intents: Bonfire.UI.ValueFlows.IntentsLive, - # ], - # widgets: [ - # # Bonfire.UI.Social.SubscribeWidgetLive, - # # Bonfire.UI.ValueFlows.LocationWidgetLive, - # # Bonfire.UI.Social.HashtagsWidgetLive, - # ], - # ] + theme: [ + instance_name: "Bonfire", + instance_icon: "/images/bonfire-icon.png", + instance_image: "https://bonfirenetworks.org/img/brand2.png", + instance_description: "This is a bonfire demo instance for testing purposes" + ], + # TODO: make dynamic based on active extensions + app_menu_extension_paths: %{ + "Social" => Bonfire.UI.Social.FeedsLive, + "Breadpub" => Bonfire.Breadpub.Web.HomeLive, + "Kanban" => Bonfire.UI.Kanban.HomeLive, + "Coordination" => Bonfire.UI.Coordination.ProcessesLive + }, + # TODO: make dynamic based on active extensions + sidebar_components: [ + {Bonfire.UI.Social.SidebarNavigationLive, []} + # {Bonfire.UI.Coordination.SidebarNavigationLive, []}, + # {Bonfire.Breadpub.SidebarNavigationLive, []}, + # {Bonfire.UI.ValueFlows.ProcessesListLive, [title: "Processes", process_url: "/process/"]}, + # {Bonfire.UI.ValueFlows.ProcessesListLive, [title: "Lists", process_url: "/breadpub/list/"]} + ], + rich_text_editor: Bonfire.Editor.Quill, + smart_input: [ + post: true, + cw: true, + summary: true + ], + profile: [ + # TODO: make dynamic based on active extensions + sections: [ + timeline: Bonfire.UI.Social.ProfileTimelineLive, + # private: Bonfire.UI.Social.MessageThreadsLive, + posts: Bonfire.UI.Social.ProfilePostsLive, + boosts: Bonfire.UI.Social.ProfileBoostsLive, + followers: Bonfire.UI.Social.ProfileFollowsLive, + followed: Bonfire.UI.Social.ProfileFollowsLive + # inventory: Bonfire.UI.Reflow.ProfileInventoryLive, + ], + navigation: [ + timeline: "timeline", + # inventory: "inventory", + posts: "posts", + boosts: "boosts" + # private: "private", + ], + widgets: [] + ], + smart_input_activities: [ + # offer: "Publish an offer", + # need: "Publish a need", + # transfer_resource: "Transfer a resource", + # produce_resource: "Add a resource", + # intent: "Indicate an itent", + # economic_event: "Record an economic event", + # process: "Define a process" + ], + smart_input_components: [ + post: Bonfire.UI.Social.WritePostContentLive, + economic_event: Bonfire.UI.ValueFlows.SelectEconomicEventLive, + intent: Bonfire.UI.ValueFlows.CreateIntentLive, + process: Bonfire.UI.ValueFlows.CreateProcessSmartInputLive + ], + resource: [ + navigation: [ + timeline: "timeline", + material_passport: "material passport" + ], + widgets: [ + # Bonfire.UI.Social.SubscribeWidgetLive, + Bonfire.UI.ValueFlows.LocationWidgetLive, + Bonfire.UI.Social.HashtagsWidgetLive + ] + ] + +# process: [ +# navigation: [ +# events: "Economic events", +# intents: "Intents", +# # material_passport: "material passport", +# ], +# sections: [ +# events: Bonfire.UI.ValueFlows.EconomicEventsLive, +# intents: Bonfire.UI.ValueFlows.IntentsLive, +# ], +# widgets: [ +# # Bonfire.UI.Social.SubscribeWidgetLive, +# # Bonfire.UI.ValueFlows.LocationWidgetLive, +# # Bonfire.UI.Social.HashtagsWidgetLive, +# ], +# ] diff --git a/flavours/upcycle/repo/migrations/20200523081010_hello_world.exs b/flavours/upcycle/repo/migrations/20200523081010_hello_world.exs index bad3ec5df0..8de33932f7 100644 --- a/flavours/upcycle/repo/migrations/20200523081010_hello_world.exs +++ b/flavours/upcycle/repo/migrations/20200523081010_hello_world.exs @@ -2,11 +2,10 @@ defmodule Bonfire.Repo.Migrations.HelloWorld do use Ecto.Migration def up do - execute "CREATE EXTENSION IF NOT EXISTS \"citext\"" + execute("CREATE EXTENSION IF NOT EXISTS \"citext\"") end def down do - execute "DROP EXTENSION IF EXISTS \"citext\"" + execute("DROP EXTENSION IF EXISTS \"citext\"") end - end diff --git a/flavours/upcycle/repo/migrations/20200523081012_init_pointers.exs b/flavours/upcycle/repo/migrations/20200523081012_init_pointers.exs index 59eec8e05d..e862965fe2 100644 --- a/flavours/upcycle/repo/migrations/20200523081012_init_pointers.exs +++ b/flavours/upcycle/repo/migrations/20200523081012_init_pointers.exs @@ -6,6 +6,7 @@ defmodule Bonfire.Repo.Migrations.InitPointers do def up do init_pointers() end + def down do init_pointers() end diff --git a/flavours/upcycle/repo/migrations/20200523081013_init_pointers_ulid.exs b/flavours/upcycle/repo/migrations/20200523081013_init_pointers_ulid.exs index 25d4f3d5f8..bbe6639cb4 100644 --- a/flavours/upcycle/repo/migrations/20200523081013_init_pointers_ulid.exs +++ b/flavours/upcycle/repo/migrations/20200523081013_init_pointers_ulid.exs @@ -7,5 +7,4 @@ defmodule Bonfire.Repo.Migrations.InitPointersULID do init_pointers_ulid_extra() # init_pointers() end - end diff --git a/flavours/upcycle/repo/migrations/20200523081014_init_edges.exs b/flavours/upcycle/repo/migrations/20200523081014_init_edges.exs index 523e0e8258..6a9051db55 100644 --- a/flavours/upcycle/repo/migrations/20200523081014_init_edges.exs +++ b/flavours/upcycle/repo/migrations/20200523081014_init_edges.exs @@ -2,7 +2,6 @@ defmodule Bonfire.Repo.Migrations.InitEdges do use Ecto.Migration alias Bonfire.Data.Edges.Migration - def up do Migration.up() end @@ -10,5 +9,4 @@ defmodule Bonfire.Repo.Migrations.InitEdges do def down do Migration.down() end - end diff --git a/flavours/upcycle/repo/migrations/20200818094943_import_ap.exs b/flavours/upcycle/repo/migrations/20200818094943_import_ap.exs index 38cea36742..bfdc4815e6 100644 --- a/flavours/upcycle/repo/migrations/20200818094943_import_ap.exs +++ b/flavours/upcycle/repo/migrations/20200818094943_import_ap.exs @@ -6,5 +6,4 @@ defmodule Bonfire.Federate.ActivityPub.Repo.Migrations.ImportMe do def up, do: migrate_activity_pub def down, do: migrate_activity_pub - end diff --git a/flavours/upcycle/repo/migrations/20200820094941_import_boundaries.exs b/flavours/upcycle/repo/migrations/20200820094941_import_boundaries.exs index bc21caeec0..f46503012a 100644 --- a/flavours/upcycle/repo/migrations/20200820094941_import_boundaries.exs +++ b/flavours/upcycle/repo/migrations/20200820094941_import_boundaries.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.ImportBoundaries do def up, do: migrate_boundaries def down, do: migrate_boundaries - end diff --git a/flavours/upcycle/repo/migrations/20200828094944_import_me.exs b/flavours/upcycle/repo/migrations/20200828094944_import_me.exs index 5b9e9a8c3f..97ac819380 100644 --- a/flavours/upcycle/repo/migrations/20200828094944_import_me.exs +++ b/flavours/upcycle/repo/migrations/20200828094944_import_me.exs @@ -9,5 +9,4 @@ defmodule Bonfire.Repo.Migrations.ImportMe do end def down, do: migrate_me() - end diff --git a/flavours/upcycle/repo/migrations/20200828094945_import_social.exs b/flavours/upcycle/repo/migrations/20200828094945_import_social.exs index 3f8c6db408..2ee83ee871 100644 --- a/flavours/upcycle/repo/migrations/20200828094945_import_social.exs +++ b/flavours/upcycle/repo/migrations/20200828094945_import_social.exs @@ -5,10 +5,8 @@ defmodule Bonfire.Social.Repo.Migrations.ImportSocial do import Pointers.Migration def up do - migrate_social() - end - def down, do: migrate_social() + def down, do: migrate_social() end diff --git a/flavours/upcycle/repo/migrations/20200829004946_boundaries_fixtures.exs b/flavours/upcycle/repo/migrations/20200829004946_boundaries_fixtures.exs index 87fd61baf6..7a8eb123c7 100644 --- a/flavours/upcycle/repo/migrations/20200829004946_boundaries_fixtures.exs +++ b/flavours/upcycle/repo/migrations/20200829004946_boundaries_fixtures.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Boundaries.Repo.Migrations.BoundariesFixtures do def up, do: Bonfire.Boundaries.Fixtures.insert() def down, do: nil - end diff --git a/flavours/upcycle/repo/migrations/20201205094943_import_quantify.exs b/flavours/upcycle/repo/migrations/20201205094943_import_quantify.exs index 5c0bce0506..4a60dd1763 100644 --- a/flavours/upcycle/repo/migrations/20201205094943_import_quantify.exs +++ b/flavours/upcycle/repo/migrations/20201205094943_import_quantify.exs @@ -2,12 +2,12 @@ defmodule Bonfire.Repo.Migrations.ImportQuantify do use Ecto.Migration def up do - Bonfire.Quantify.Migrations.change - Bonfire.Quantify.Migrations.change_measure + Bonfire.Quantify.Migrations.change() + Bonfire.Quantify.Migrations.change_measure() end def down do - Bonfire.Quantify.Migrations.change - Bonfire.Quantify.Migrations.change_measure + Bonfire.Quantify.Migrations.change() + Bonfire.Quantify.Migrations.change_measure() end end diff --git a/flavours/upcycle/repo/migrations/20201208094940_import_geolocation.exs b/flavours/upcycle/repo/migrations/20201208094940_import_geolocation.exs index 479d9e680c..42178a098b 100644 --- a/flavours/upcycle/repo/migrations/20201208094940_import_geolocation.exs +++ b/flavours/upcycle/repo/migrations/20201208094940_import_geolocation.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportGeolocation do use Ecto.Migration def up do - Bonfire.Geolocate.Migrations.change + Bonfire.Geolocate.Migrations.change() end def down do - Bonfire.Geolocate.Migrations.change + Bonfire.Geolocate.Migrations.change() end end diff --git a/flavours/upcycle/repo/migrations/20201212094942_import_valueflows.exs b/flavours/upcycle/repo/migrations/20201212094942_import_valueflows.exs index 87b60d305d..17868173f8 100644 --- a/flavours/upcycle/repo/migrations/20201212094942_import_valueflows.exs +++ b/flavours/upcycle/repo/migrations/20201212094942_import_valueflows.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportValueFlows do use Ecto.Migration def up do - ValueFlows.AllMigrations.up + ValueFlows.AllMigrations.up() end def down do - ValueFlows.AllMigrations.down + ValueFlows.AllMigrations.down() end end diff --git a/flavours/upcycle/repo/migrations/20210102094944_import_shared_user.exs b/flavours/upcycle/repo/migrations/20210102094944_import_shared_user.exs index 09845637a3..e55a68d7fa 100644 --- a/flavours/upcycle/repo/migrations/20210102094944_import_shared_user.exs +++ b/flavours/upcycle/repo/migrations/20210102094944_import_shared_user.exs @@ -6,5 +6,4 @@ defmodule Bonfire.Repo.Migrations.ImportSharedUser do def up, do: migrate_shared_user() def down, do: migrate_shared_user() - end diff --git a/flavours/upcycle/repo/migrations/20210113094942_import_valueflows_observe.exs b/flavours/upcycle/repo/migrations/20210113094942_import_valueflows_observe.exs index f71a9dc765..4f67bd579a 100644 --- a/flavours/upcycle/repo/migrations/20210113094942_import_valueflows_observe.exs +++ b/flavours/upcycle/repo/migrations/20210113094942_import_valueflows_observe.exs @@ -4,10 +4,10 @@ defmodule Bonfire.Repo.Migrations.ImportValueFlowsObserve do alias ValueFlows.Observe.Migrations def up do - Migrations.up + Migrations.up() end def down do - Migrations.down + Migrations.down() end end diff --git a/flavours/upcycle/repo/migrations/20210302094944_import_boost.exs b/flavours/upcycle/repo/migrations/20210302094944_import_boost.exs index d94a7eab85..7aaebb62b8 100644 --- a/flavours/upcycle/repo/migrations/20210302094944_import_boost.exs +++ b/flavours/upcycle/repo/migrations/20210302094944_import_boost.exs @@ -6,8 +6,8 @@ defmodule Bonfire.Repo.Migrations.ImportBoost do def up do migrate_boost() end + def down do migrate_boost() end - end diff --git a/flavours/upcycle/repo/migrations/20210302094945_import_flag.exs b/flavours/upcycle/repo/migrations/20210302094945_import_flag.exs index baee09802b..546011a489 100644 --- a/flavours/upcycle/repo/migrations/20210302094945_import_flag.exs +++ b/flavours/upcycle/repo/migrations/20210302094945_import_flag.exs @@ -10,5 +10,4 @@ defmodule Bonfire.Repo.Migrations.ImportFlag do def down do migrate_flag() end - end diff --git a/flavours/upcycle/repo/migrations/20210302094946_import_inbox.exs b/flavours/upcycle/repo/migrations/20210302094946_import_inbox.exs index d8a63ac164..6a05ef0d24 100644 --- a/flavours/upcycle/repo/migrations/20210302094946_import_inbox.exs +++ b/flavours/upcycle/repo/migrations/20210302094946_import_inbox.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Repo.Migrations.ImportInbox do def up, do: migrate_inbox() def down, do: migrate_inbox() - end diff --git a/flavours/upcycle/repo/migrations/20210402105128_ap_test_table.exs b/flavours/upcycle/repo/migrations/20210402105128_ap_test_table.exs index 929b6324f6..ecc4b56355 100644 --- a/flavours/upcycle/repo/migrations/20210402105128_ap_test_table.exs +++ b/flavours/upcycle/repo/migrations/20210402105128_ap_test_table.exs @@ -4,12 +4,12 @@ defmodule ActivityPub.Repo.Migrations.APTestTable do def change do # This table only exists for test purposes create table("local_actor", primary_key: false) do - add :id, :uuid, primary_key: true - add :username, :citext - add :data, :map - add :local, :boolean - add :keys, :text - add :followers, {:array, :string} + add(:id, :uuid, primary_key: true) + add(:username, :citext) + add(:data, :map) + add(:local, :boolean) + add(:keys, :text) + add(:followers, {:array, :string}) end end end diff --git a/flavours/upcycle/repo/migrations/20210407094946_message.exs b/flavours/upcycle/repo/migrations/20210407094946_message.exs index 9cb0cc34b9..9a23628612 100644 --- a/flavours/upcycle/repo/migrations/20210407094946_message.exs +++ b/flavours/upcycle/repo/migrations/20210407094946_message.exs @@ -5,5 +5,4 @@ defmodule Bonfire.Repo.Migrations.Message do def up, do: migrate_message() def down, do: migrate_message() - end diff --git a/flavours/upcycle/repo/migrations/20210410094945_profile_images.exs b/flavours/upcycle/repo/migrations/20210410094945_profile_images.exs index c0a07043eb..8294d2b957 100644 --- a/flavours/upcycle/repo/migrations/20210410094945_profile_images.exs +++ b/flavours/upcycle/repo/migrations/20210410094945_profile_images.exs @@ -4,15 +4,19 @@ defmodule Bonfire.Social.Repo.Migrations.ProfileImages do import Pointers.Migration def up do + drop_if_exists( + constraint("bonfire_data_social_profile", "bonfire_data_social_profile_icon_id_fkey") + ) - drop_if_exists constraint "bonfire_data_social_profile", "bonfire_data_social_profile_icon_id_fkey" - drop_if_exists constraint "bonfire_data_social_profile", "bonfire_data_social_profile_image_id_fkey" + drop_if_exists( + constraint("bonfire_data_social_profile", "bonfire_data_social_profile_image_id_fkey") + ) alter table("bonfire_data_social_profile") do - Ecto.Migration.add_if_not_exists :icon_id, strong_pointer(Bonfire.Files.Media) - Ecto.Migration.add_if_not_exists :image_id, strong_pointer(Bonfire.Files.Media) + Ecto.Migration.add_if_not_exists(:icon_id, strong_pointer(Bonfire.Files.Media)) + Ecto.Migration.add_if_not_exists(:image_id, strong_pointer(Bonfire.Files.Media)) end end - def down, do: nil + def down, do: nil end diff --git a/flavours/upcycle/repo/migrations/20210412094946_fp.exs b/flavours/upcycle/repo/migrations/20210412094946_fp.exs index 4e13f8b533..1966abd46a 100644 --- a/flavours/upcycle/repo/migrations/20210412094946_fp.exs +++ b/flavours/upcycle/repo/migrations/20210412094946_fp.exs @@ -1,7 +1,6 @@ defmodule Bonfire.Repo.Migrations.FP do use Ecto.Migration - def up do execute("create or replace function column_exists(ptable text, pcolumn text, pschema text default 'public') @@ -18,7 +17,8 @@ defmodule Bonfire.Repo.Migrations.FP do ); $body$;") - execute("CREATE OR REPLACE FUNCTION rename_column_if_exists(ptable TEXT, pcolumn TEXT, new_name TEXT) + execute( + "CREATE OR REPLACE FUNCTION rename_column_if_exists(ptable TEXT, pcolumn TEXT, new_name TEXT) RETURNS VOID AS $BODY$ BEGIN -- Rename the column if it exists. @@ -27,14 +27,15 @@ defmodule Bonfire.Repo.Migrations.FP do ptable, pcolumn, new_name); END IF; END$BODY$ - LANGUAGE plpgsql VOLATILE;") + LANGUAGE plpgsql VOLATILE;" + ) flush() - execute("SELECT rename_column_if_exists('bonfire_data_social_feed_publish', 'object_id', 'activity_id') ") - + execute( + "SELECT rename_column_if_exists('bonfire_data_social_feed_publish', 'object_id', 'activity_id') " + ) end def down, do: nil - end diff --git a/flavours/upcycle/repo/migrations/20210618094945_peered_uri.exs b/flavours/upcycle/repo/migrations/20210618094945_peered_uri.exs index ce0bb3c412..1aff450e95 100644 --- a/flavours/upcycle/repo/migrations/20210618094945_peered_uri.exs +++ b/flavours/upcycle/repo/migrations/20210618094945_peered_uri.exs @@ -5,9 +5,9 @@ defmodule Bonfire.Social.Repo.Migrations.PeeredURI do def up do alter table("bonfire_data_activity_pub_peered") do - Ecto.Migration.add_if_not_exists :canonical_uri, :text, null: true + Ecto.Migration.add_if_not_exists(:canonical_uri, :text, null: true) end end - def down, do: nil + def down, do: nil end diff --git a/flavours/upcycle/repo/migrations/20210925094942_import_classify.exs b/flavours/upcycle/repo/migrations/20210925094942_import_classify.exs index 2f83f7b214..d8c04f13ec 100644 --- a/flavours/upcycle/repo/migrations/20210925094942_import_classify.exs +++ b/flavours/upcycle/repo/migrations/20210925094942_import_classify.exs @@ -2,10 +2,10 @@ defmodule Bonfire.Repo.Migrations.ImportClassify do use Ecto.Migration def up do - Bonfire.Classify.Migrations.up + Bonfire.Classify.Migrations.up() end def down do - Bonfire.Classify.Migrations.down + Bonfire.Classify.Migrations.down() end end diff --git a/flavours/upcycle/repo/migrations/20211001094942_import_assort_ranked.exs b/flavours/upcycle/repo/migrations/20211001094942_import_assort_ranked.exs index daf2c99385..93aaa5b18e 100644 --- a/flavours/upcycle/repo/migrations/20211001094942_import_assort_ranked.exs +++ b/flavours/upcycle/repo/migrations/20211001094942_import_assort_ranked.exs @@ -2,7 +2,6 @@ defmodule Bonfire.Repo.Migrations.ImportRanked do use Ecto.Migration require Bonfire.Data.Assort.Ranked.Migration - def up, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked - def down, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked - + def up, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked() + def down, do: Bonfire.Data.Assort.Ranked.Migration.migrate_ranked() end diff --git a/flavours/upcycle/repo/migrations/20211112094942_import_commitment_satisfaction.exs b/flavours/upcycle/repo/migrations/20211112094942_import_commitment_satisfaction.exs index 8e08f938ed..fc46a93de8 100644 --- a/flavours/upcycle/repo/migrations/20211112094942_import_commitment_satisfaction.exs +++ b/flavours/upcycle/repo/migrations/20211112094942_import_commitment_satisfaction.exs @@ -3,7 +3,7 @@ defmodule Bonfire.Repo.Migrations.ImportCommitmentSatisfaction do def up do ValueFlows.Planning.Commitment.Migrations.up() - ValueFlows.Planning.Satisfaction.Migrations.up() + ValueFlows.Planning.Satisfaction.Migrations.up() end def down do diff --git a/flavours/upcycle/repo/migrations/20220304081300_care_closure.exs b/flavours/upcycle/repo/migrations/20220304081300_care_closure.exs index 30a0dbc621..2e41085d5c 100644 --- a/flavours/upcycle/repo/migrations/20220304081300_care_closure.exs +++ b/flavours/upcycle/repo/migrations/20220304081300_care_closure.exs @@ -4,5 +4,4 @@ defmodule Bonfire.Data.Identity.Repo.Migrations.CareClosure do alias Bonfire.Data.Identity.CareClosure.Migration def change, do: Migration.migrate_care_closure_view() - end diff --git a/flavours/upcycle/repo/migrations/20220408094940_settings.exs b/flavours/upcycle/repo/migrations/20220408094940_settings.exs index c7a22dcd23..57f6ac5987 100644 --- a/flavours/upcycle/repo/migrations/20220408094940_settings.exs +++ b/flavours/upcycle/repo/migrations/20220408094940_settings.exs @@ -2,7 +2,7 @@ defmodule Bonfire.Repo.Migrations.ImportSettings do use Ecto.Migration require Bonfire.Data.Identity.Settings.Migration - def up do + def up do Bonfire.Data.Identity.Settings.Migration.migrate_settings(:up) end diff --git a/flavours/upcycle/repo/migrations/20220428094200_add_files_mixin.exs b/flavours/upcycle/repo/migrations/20220428094200_add_files_mixin.exs index 0fd23546a9..ae2f93b48f 100644 --- a/flavours/upcycle/repo/migrations/20220428094200_add_files_mixin.exs +++ b/flavours/upcycle/repo/migrations/20220428094200_add_files_mixin.exs @@ -5,9 +5,10 @@ defmodule Bonfire.Repo.Migrations.AddFilesMixin do 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 + # cleanup old stuff + alter table("bonfire_files_media") do + remove_if_exists(:created_at, :utc_datetime_usec) + remove_if_exists(:updated_at, :utc_datetime_usec) end Bonfire.Files.Migrations.migrate_files() diff --git a/flavours/upcycle/repo/seeds.exs b/flavours/upcycle/repo/seeds.exs index 930c8c6bff..7504f8e90b 100644 --- a/flavours/upcycle/repo/seeds.exs +++ b/flavours/upcycle/repo/seeds.exs @@ -3,28 +3,30 @@ import Bonfire.Me.Fake System.put_env("INVITE_ONLY", "false") System.put_env("SEARCH_INDEXING_DISABLED", "true") -%{ - preferred_username: System.get_env("SEEDS_USER", "root"), - name: System.get_env("SEEDS_USER", "Seed User") -} -|> fake_user!(%{confirm_email: true}) +fake_user!( + %{ + preferred_username: System.get_env("SEEDS_USER", "root"), + name: System.get_env("SEEDS_USER", "Seed User") + }, + %{confirm_email: true} +) # create some users users = for _ <- 1..2, do: fake_user!() random_user = fn -> Faker.Util.pick(users) end # start some communities -#communities = for _ <- 1..2, do: fake_community!(random_user.()) -#subcommunities = for _ <- 1..2, do: fake_community!(random_user.(), Faker.Util.pick(communities)) -#maybe_random_community = fn -> maybe_one_of(communities ++ subcommunities) end +# communities = for _ <- 1..2, do: fake_community!(random_user.()) +# subcommunities = for _ <- 1..2, do: fake_community!(random_user.(), Faker.Util.pick(communities)) +# maybe_random_community = fn -> maybe_one_of(communities ++ subcommunities) end # create fake collections -#collections = for _ <- 1..4, do: fake_collection!(random_user.(), maybe_random_community.()) -#subcollections = for _ <- 1..2, do: fake_collection!(random_user.(), Faker.Util.pick(collections)) -#maybe_random_collection = fn -> maybe_one_of(collections ++ subcollections) end +# collections = for _ <- 1..4, do: fake_collection!(random_user.(), maybe_random_community.()) +# subcollections = for _ <- 1..2, do: fake_collection!(random_user.(), Faker.Util.pick(collections)) +# maybe_random_collection = fn -> maybe_one_of(collections ++ subcollections) end # start fake threads -#for _ <- 1..3 do +# for _ <- 1..3 do # user = random_user.() # thread = fake_thread!(user, maybe_random_community.()) # comment = fake_comment!(user, thread) @@ -32,18 +34,18 @@ random_user = fn -> Faker.Util.pick(users) end # reply = fake_comment!(random_user.(), thread, %{in_reply_to_id: comment.id}) # subreply = fake_comment!(random_user.(), thread, %{in_reply_to_id: reply.id}) # subreply2 = fake_comment!(random_user.(), thread, %{in_reply_to_id: subreply.id}) -#end +# end # ## more fake threads -#for _ <- 1..2 do +# for _ <- 1..2 do # user = random_user.() # thread = fake_thread!(user, maybe_random_collection.()) # comment = fake_comment!(user, thread) -#end +# end # post some links/resources -#for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_community.()) -#for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_collection.()) +# for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_community.()) +# for _ <- 1..2, do: fake_resource!(random_user.(), maybe_random_collection.()) # define some tags/categories if(Bonfire.Common.Extend.extension_enabled?(Bonfire.Classify.Simulate)) do @@ -89,18 +91,22 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do # some proposed intents action_id = ValueFlows.Simulate.action_id() - intent = ValueFlows.Simulate.fake_intent!(user, %{resource_conforms_to: res_spec, action_id: action_id}) + + intent = + ValueFlows.Simulate.fake_intent!(user, %{ + resource_conforms_to: res_spec, + action_id: action_id + }) + proposal = ValueFlows.Simulate.fake_proposal!(user) ValueFlows.Simulate.fake_proposed_to!(random_user.(), proposal) ValueFlows.Simulate.fake_proposed_intent!(proposal, intent) # define some geolocations if(Bonfire.Common.Extend.extension_enabled?(Bonfire.Geolocate.Simulate)) do - places = for _ <- 1..2, do: Bonfire.Geolocate.Simulate.fake_geolocation!(random_user.()) random_place = fn -> Faker.Util.pick(places) end - for _ <- 1..2 do # define some intents with geolocation _intent = @@ -110,7 +116,8 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do ) # define some proposals with geolocation - _proposal = ValueFlows.Simulate.fake_proposal!(user, %{eligible_location: random_place.()}) + _proposal = + ValueFlows.Simulate.fake_proposal!(user, %{eligible_location: random_place.()}) # both with geo intent = @@ -125,8 +132,13 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do # some economic events user = random_user.() - resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(user, %{current_location: random_place.()}) - to_resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{current_location: random_place.()}) + resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(user, %{current_location: random_place.()}) + + to_resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{ + current_location: random_place.() + }) ValueFlows.Simulate.fake_economic_event!( user, @@ -162,7 +174,9 @@ if(Bonfire.Common.Extend.extension_enabled?(ValueFlows.Simulate)) do unit = Faker.Util.pick([unit1, unit2]) resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(user, %{}, unit) - to_resource_inventoried_as = ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{}, unit) + + to_resource_inventoried_as = + ValueFlows.Simulate.fake_economic_resource!(random_user.(), %{}, unit) ValueFlows.Simulate.fake_economic_event!( user, diff --git a/flavours/upcycle/repo/seeds/20210122131234_observe_classifications.exs b/flavours/upcycle/repo/seeds/20210122131234_observe_classifications.exs index 098393c298..05581b6cc5 100644 --- a/flavours/upcycle/repo/seeds/20210122131234_observe_classifications.exs +++ b/flavours/upcycle/repo/seeds/20210122131234_observe_classifications.exs @@ -1,7 +1,7 @@ defmodule Bonfire.Repo.Seeds.ObserveClassifications do use Bonfire.Seeder - envs [:dev, :prod, :test] + envs([:dev, :prod, :test]) def up(repo), do: ValueFlows.Observe.Seeds.up(repo) end diff --git a/justfile b/justfile index 9b13046a55..21f06593dd 100644 --- a/justfile +++ b/justfile @@ -309,10 +309,11 @@ messctl *args='': init #### CONTRIBUTION RELATED COMMANDS #### pre-push-hooks: pre-contrib-hooks + just mix format just mix changelog pre-contrib-hooks: -# @sed -i '' 's,/forks/,/deps/,' config/deps_hooks.js + -sed -i '' 's,/forks/,/deps/,' config/deps_hooks.js # Push all changes to the app and extensions in ./forks contrib-forks: pre-push-hooks contrib-forks-publish git-publish diff --git a/lib/application.ex b/lib/application.ex index 3cb3fe961a..9ed5712043 100755 --- a/lib/application.ex +++ b/lib/application.ex @@ -1,5 +1,4 @@ defmodule Bonfire.Application do - @sup_name Bonfire.Supervisor @name Mix.Project.config()[:name] @otp_app Bonfire.Common.Config.get!(:otp_app) @@ -14,38 +13,47 @@ defmodule Bonfire.Application do require Cachex.Spec def start(_type, _args) do - EctoSparkles.Log.setup(@repo_module) # Ecto.DevLogger.install(@repo_module) Bonfire.ObanLogger.setup() Oban.Telemetry.attach_default_logger() - applications(@env, Bonfire.Common.Extend.module_enabled?(Bonfire.API.GraphQL) and Bonfire.Common.Extend.module_enabled?(Bonfire.API.GraphQL.Schema)) #|> IO.inspect + # |> IO.inspect + applications( + @env, + Bonfire.Common.Extend.module_enabled?(Bonfire.API.GraphQL) and + Bonfire.Common.Extend.module_enabled?(Bonfire.API.GraphQL.Schema) + ) |> Supervisor.start_link(strategy: :one_for_one, name: @sup_name) end - def applications(env, true = _with_graphql?) do # include GraphQL API + # include GraphQL API + def applications(env, true = _with_graphql?) do [ - {Absinthe.Schema, Bonfire.API.GraphQL.Schema} # use persistent_term backend for Absinthe - ] - ++ applications(env, :default) - ++ - [ - {Absinthe.Subscription, @endpoint_module} - ] + # use persistent_term backend for Absinthe + {Absinthe.Schema, Bonfire.API.GraphQL.Schema} + ] ++ + applications(env, :default) ++ + [ + {Absinthe.Subscription, @endpoint_module} + ] end @apps_before [ - Bonfire.Web.Telemetry, # Metrics - @repo_module, # Database + # Metrics + Bonfire.Web.Telemetry, + # Database + @repo_module, EctoSparkles.AutoMigrator, # Bonfire.Common.ConfigModules, # Bonfire.Common.Config.LoadExtensionsConfig, - Bonfire.Me.Settings.LoadInstanceConfig, # load instance Settings from DB into Config - {Phoenix.PubSub, [name: Bonfire.PubSub, adapter: Phoenix.PubSub.PG2]}, # PubSub + # load instance Settings from DB into Config + Bonfire.Me.Settings.LoadInstanceConfig, + # PubSub + {Phoenix.PubSub, [name: Bonfire.PubSub, adapter: Phoenix.PubSub.PG2]}, # Persistent Data Services - Pointers.Tables, + Pointers.Tables # Bonfire.Data.AccessControl.Accesses, ## these populate on first call, so no need to run on startup: # Bonfire.Common.ContextModules, @@ -53,31 +61,42 @@ defmodule Bonfire.Application do # Bonfire.Federate.ActivityPub.FederationModules ] - @default_cache_ttl 1_000 * 60 * 60 * 6 # 6 hours + # 6 hours + @default_cache_ttl 1_000 * 60 * 60 * 6 # Stuff that depends on all the above @apps_after [ - @endpoint_module, # Web app - {Oban, Application.fetch_env!(:bonfire, Oban)}, # Job Queue - %{ - id: :bonfire_cache, - start: {Cachex, :start_link, [ - :bonfire_cache, [ - expiration: Cachex.Spec.expiration( - default: @default_cache_ttl, - interval: 1000 - ), - limit: 5000 # increase for instances with more users (at least num. of users*2+1) - ]]}} - ] + # Web app + @endpoint_module, + # Job Queue + {Oban, Application.fetch_env!(:bonfire, Oban)}, + %{ + id: :bonfire_cache, + start: + {Cachex, :start_link, + [ + :bonfire_cache, + [ + expiration: + Cachex.Spec.expiration( + default: @default_cache_ttl, + interval: 1000 + ), + # increase for instances with more users (at least num. of users*2+1) + limit: 5000 + ] + ]} + } + ] def applications(:test, _any) do - @apps_before # ++ [Bonfire.Web.FakeRemoteEndpoint] - ++ @apps_after + @apps_before ++ + @apps_after end - def applications(_env, _any) do # default apps + # default apps + def applications(_env, _any) do @apps_before ++ @apps_after end @@ -93,5 +112,4 @@ defmodule Bonfire.Application do def named_version, do: name() <> " " <> @version def repository, do: @repository def deps, do: @deps - end diff --git a/lib/error_reporting.ex b/lib/error_reporting.ex index 2cb8db90cb..0c2f379a78 100644 --- a/lib/error_reporting.ex +++ b/lib/error_reporting.ex @@ -5,7 +5,7 @@ defmodule Bonfire.ErrorReporting do defmacro __using__(_) do quote do require Bonfire.Common.Extend - Bonfire.Common.Extend.use_if_enabled Sentry.PlugCapture + Bonfire.Common.Extend.use_if_enabled(Sentry.PlugCapture) end end @@ -16,7 +16,8 @@ defmodule Bonfire.ErrorReporting do @impl true def call(conn, opts) do - if Bonfire.Common.Extend.module_enabled?(Sentry), do: Sentry.PlugContext.call(conn, opts), else: conn + if Bonfire.Common.Extend.module_enabled?(Sentry), + do: Sentry.PlugContext.call(conn, opts), + else: conn end - end diff --git a/lib/localise.ex b/lib/localise.ex index 60e16f7060..be05b5e5bb 100644 --- a/lib/localise.ex +++ b/lib/localise.ex @@ -13,11 +13,11 @@ defmodule Bonfire.Localise do |> IO.inspect(label: "Making all object type names localisable") |> localise_strings(Bonfire.Common.Types) - l "Timeline" - l "Posts" - l "Boosts" - l "Published" - l "Submitted" + l("Timeline") + l("Posts") + l("Boosts") + l("Published") + l("Submitted") # for {item, _item} <- Bonfire.Common.Config.get([:ui, :profile, :navigation], [timeline: "timeline"]) # |> IO.inspect(label: "Making profile tab names localisable") do diff --git a/lib/mix/tasks/account/account.new.ex b/lib/mix/tasks/account/account.new.ex index 04d7edadbf..aa2fdeb180 100644 --- a/lib/mix/tasks/account/account.new.ex +++ b/lib/mix/tasks/account/account.new.ex @@ -19,18 +19,18 @@ defmodule Mix.Tasks.Bonfire.Account.New do alias Bonfire.Me.Fake - @spec run(OptionParser.argv) :: :ok + @spec run(OptionParser.argv()) :: :ok def run(args) do options = options(args, %{}) Mix.Task.run("app.start") email = get("Enter an email address: ", :email, options, true) password = password("Enter a password:") IO.inspect(password: password) - %{ - credential: %{password: password}, - email: %{email_address: email}, - } - |> Fake.fake_account!() + + Fake.fake_account!(%{ + credential: %{password: password}, + email: %{email_address: email} + }) end defp options([], opts), do: opts @@ -40,14 +40,23 @@ defmodule Mix.Tasks.Bonfire.Account.New do case opts[key] do nil -> case IO.gets(prompt) do - :eof -> raise RuntimeError, message: "EOF" - data when is_binary(data) -> get(prompt, key, Map.put(opts, key, data), must?) - data when is_list(data) -> get(prompt, key, Map.put(opts, key, to_string(data)), must?) + :eof -> + raise RuntimeError, message: "EOF" + + data when is_binary(data) -> + get(prompt, key, Map.put(opts, key, data), must?) + + data when is_list(data) -> + get(prompt, key, Map.put(opts, key, to_string(data)), must?) end + data -> data = String.trim(data) + if data == "" do - if must?, do: get(prompt, key, Map.delete(opts, key), must?), else: nil + if must?, + do: get(prompt, key, Map.delete(opts, key), must?), + else: nil else data end @@ -63,11 +72,17 @@ defmodule Mix.Tasks.Bonfire.Account.New do defp password(prompt, pid, ref) do value = String.trim(IO.gets(prompt)) + if String.length(value) < 10 do - IO.puts(:standard_error, "Password too short, must be at least 10 characters long") + IO.puts( + :standard_error, + "Password too short, must be at least 10 characters long" + ) + password(prompt, pid, ref) else send(pid, {:done, self(), ref}) + receive do {:done, ^pid, ^ref} -> value end @@ -85,5 +100,4 @@ defmodule Mix.Tasks.Bonfire.Account.New do loop(prompt) end end - end diff --git a/lib/mix/tasks/dep.compile.ex b/lib/mix/tasks/dep.compile.ex index b0744d1697..a78273263a 100644 --- a/lib/mix/tasks/dep.compile.ex +++ b/lib/mix/tasks/dep.compile.ex @@ -30,13 +30,13 @@ defmodule Mix.Tasks.Bonfire.Dep.Compile do @switches [include_children: :boolean, force: :boolean] - @spec run(OptionParser.argv) :: :ok + @spec run(OptionParser.argv()) :: :ok def run(args) do unless "--no-archives-check" in args do - Mix.Task.run "archive.check", args + Mix.Task.run("archive.check", args) end - Mix.Project.get! + Mix.Project.get!() case OptionParser.parse(args, switches: @switches) do {opts, [], _} -> @@ -44,32 +44,37 @@ defmodule Mix.Tasks.Bonfire.Dep.Compile do # dep.compile, we simply try to compile any available # dependency. compile(Enum.filter(loaded_deps(), &available?/1), opts) + {opts, tail, _} -> - compile(loaded_by_name(tail, [env: Mix.env] ++ opts), opts) + compile(loaded_by_name(tail, [env: Mix.env()] ++ opts), opts) end end @doc false def compile(deps, options \\ []) do - shell = Mix.shell - config = Mix.Project.deps_config + shell = Mix.shell() + config = Mix.Project.deps_config() - Mix.Task.run "deps.precompile" + Mix.Task.run("deps.precompile") compiled = Enum.map(deps, fn %Mix.Dep{app: app, status: status, opts: opts, scm: scm} = dep -> - check_unavailable!(app, status) - compiled? = cond do - mix?(dep) -> - maybe_clean(dep, options) - do_mix dep, config - true -> - shell.error "Could not compile #{inspect app}, no \"mix.exs\" found " <> - "(pass :compile as an option to customize compilation, set it to \"false\" to do nothing)" - false - end + compiled? = + cond do + mix?(dep) -> + maybe_clean(dep, options) + do_mix(dep, config) + + true -> + shell.error( + "Could not compile #{inspect(app)}, no \"mix.exs\" found " <> + "(pass :compile as an option to customize compilation, set it to \"false\" to do nothing)" + ) + + false + end # We should touch fetchable dependencies even if they # did not compile otherwise they will always be marked @@ -77,7 +82,6 @@ defmodule Mix.Tasks.Bonfire.Dep.Compile do fetchable? = touch_fetchable(scm, opts[:build]) compiled? and fetchable? - end) if true in compiled, do: Mix.Task.run("will_recompile"), else: :ok @@ -102,8 +106,10 @@ defmodule Mix.Tasks.Bonfire.Dep.Compile do end defp check_unavailable!(app, {:unavailable, _}) do - Mix.raise "Cannot compile dependency #{inspect app} because " <> - "it isn't available, run \"mix deps.get\" first" + Mix.raise( + "Cannot compile dependency #{inspect(app)} because " <> + "it isn't available, run \"mix deps.get\" first" + ) end defp check_unavailable!(_, _) do @@ -111,15 +117,17 @@ defmodule Mix.Tasks.Bonfire.Dep.Compile do end defp do_mix(dep, _config) do - Mix.Dep.in_dependency dep, fn _ -> - if req = old_elixir_req(Mix.Project.config) do - Mix.shell.error "warning: the dependency #{inspect dep.app} requires Elixir #{inspect req} " <> "but you are running on v#{System.version}" + Mix.Dep.in_dependency(dep, fn _ -> + if req = old_elixir_req(Mix.Project.config()) do + Mix.shell().error( + "warning: the dependency #{inspect(dep.app)} requires Elixir #{inspect(req)} " <> + "but you are running on v#{System.version()}" + ) end - Mix.shell.info "Recompiling extension #{inspect dep.app}" + Mix.shell().info("Recompiling extension #{inspect(dep.app)}") try do - # If "compile" was never called, the reenabling is a no-op and # "compile.elixir" is a no-op as well (because it wasn't reenabled after # running "compile"). If "compile" was already called, then running @@ -144,22 +152,26 @@ defmodule Mix.Tasks.Bonfire.Dep.Compile do # Mix.shell.info(inspect res) match?({:ok, _}, res) - catch kind, reason -> - stacktrace = System.stacktrace + stacktrace = System.stacktrace() app = dep.app - Mix.shell.error "could not compile dependency #{inspect app}, \"mix compile\" failed. " <> - "You can recompile this dependency with \"mix deps.compile #{app}\", update it " <> - "with \"mix deps.update #{app}\" or clean it with \"mix deps.clean #{app}\"" + + Mix.shell().error( + "could not compile dependency #{inspect(app)}, \"mix compile\" failed. " <> + "You can recompile this dependency with \"mix deps.compile #{app}\", update it " <> + "with \"mix deps.update #{app}\" or clean it with \"mix deps.clean #{app}\"" + ) + :erlang.raise(kind, reason, stacktrace) end - end + end) end defp old_elixir_req(config) do req = config[:elixir] - if req && not Version.match?(System.version, req) do + + if req && not Version.match?(System.version(), req) do req end end @@ -180,12 +192,13 @@ defmodule Mix.Tasks.Bonfire.Dep.Compile do provided in the project are in the wrong format. """ def loaded_by_name(given, all_deps \\ nil, opts) do - all_deps = (all_deps || loaded_deps()) + all_deps = all_deps || loaded_deps() # |> debug("all_deps") # Ensure all apps are atoms - apps = to_app_names(given) - |> debug("deps to recompile") + apps = + to_app_names(given) + |> debug("deps to recompile") deps = if opts[:include_children] do @@ -194,19 +207,19 @@ defmodule Mix.Tasks.Bonfire.Dep.Compile do get_deps(all_deps, apps) end - Enum.each apps, fn(app) -> + Enum.each(apps, fn app -> unless Enum.any?(all_deps, &(&1.app == app)) do - warn("Unknown dependency #{app} for environment #{Mix.env}") + warn("Unknown dependency #{app} for environment #{Mix.env()}") end - end + end) deps end defp to_app_names(given) do - Enum.map given, fn(app) -> + Enum.map(given, fn app -> if is_binary(app), do: String.to_atom(app), else: app - end + end) end defp get_deps(all_deps, apps) do @@ -215,22 +228,23 @@ defmodule Mix.Tasks.Bonfire.Dep.Compile do defp get_deps_with_children(all_deps, apps) do deps = get_children(all_deps, apps) - apps = deps |> Enum.map(& &1.app) |> Enum.uniq + apps = deps |> Enum.map(& &1.app) |> Enum.uniq() get_deps(all_deps, apps) end defp get_children(_all_deps, []), do: [] + defp get_children(all_deps, apps) do # Current deps deps = get_deps(all_deps, apps) # Children apps - apps = for %{deps: children} <- deps, - %{app: app} <- children, - do: app + apps = + for %{deps: children} <- deps, + %{app: app} <- children, + do: app # Current deps + children deps deps ++ get_children(all_deps, apps) end - end diff --git a/lib/mix/tasks/docs/deps.ex b/lib/mix/tasks/docs/deps.ex index 90a1ed5dfd..827c8c2bd1 100644 --- a/lib/mix/tasks/docs/deps.ex +++ b/lib/mix/tasks/docs/deps.ex @@ -28,21 +28,33 @@ defmodule Mix.Tasks.Docs.Deps do excluded = Keyword.get_values(opts, :exclude) - deps = Mix.Dep.load_on_environment(deps_opts) - |> prepare_list(opts) - |> List.flatten() - |> Enum.reject(& Atom.to_string(dep_name(&1)) in excluded) - |> Enum.uniq_by(&dep_name(&1)) + deps = + Mix.Dep.load_on_environment(deps_opts) + |> prepare_list(opts) + |> List.flatten() + |> Enum.reject(&(Atom.to_string(dep_name(&1)) in excluded)) + |> Enum.uniq_by(&dep_name(&1)) config = Mix.Project.config() build_path = Mix.Project.build_path() docs_config = Keyword.get(config, :docs, []) - docs_config = docs_config - |> Keyword.put(:deps, Enum.map(deps, & {dep_name(&1), "./"})) - |> Keyword.put(:source_beam, Enum.map(deps, &Path.join([build_path, "lib", Atom.to_string(dep_name(&1)), "ebin"]))) - |> Keyword.put(:extras, Keyword.get(docs_config, :extras, []) ++ Enum.flat_map(deps, &readme_path/1)) + docs_config = + docs_config + |> Keyword.put(:deps, Enum.map(deps, &{dep_name(&1), "./"})) + |> Keyword.put( + :source_beam, + Enum.map( + deps, + &Path.join([build_path, "lib", Atom.to_string(dep_name(&1)), "ebin"]) + ) + ) + |> Keyword.put( + :extras, + Keyword.get(docs_config, :extras, []) ++ + Enum.flat_map(deps, &readme_path/1) + ) Mix.Tasks.Docs.run(args, Keyword.put(config, :docs, docs_config)) end @@ -57,22 +69,29 @@ defmodule Mix.Tasks.Docs.Deps do end) end - defp readme_path(dep) when not is_nil(dep), do: dep_paths(dep, "README.md") |> List.first |> readme_path(dep) - defp readme_path(path, dep) when not is_nil(path), do: [{path |> String.to_atom, [filename: "extension-#{dep_name(dep)}"]}] + defp readme_path(dep) when not is_nil(dep), + do: dep_paths(dep, "README.md") |> List.first() |> readme_path(dep) + + defp readme_path(path, dep) when not is_nil(path), + do: [{String.to_atom(path), [filename: "extension-#{dep_name(dep)}"]}] + defp readme_path(_, _), do: [] defp dep_path(dep) do - - path = if is_list(dep) && dep[:path], - do: dep[:path], - else: Mix.Project.deps_path() <> "/#{dep_name(dep)}" |> Path.expand(@root) + path = + if is_list(dep) && dep[:path], + do: dep[:path], + else: (Mix.Project.deps_path() <> "/#{dep_name(dep)}") |> Path.expand(@root) path_if_exists(path) end - defp dep_paths(dep, extra) when is_list(extra), do: Enum.flat_map(extra, &dep_paths(dep, &1)) + defp dep_paths(dep, extra) when is_list(extra), + do: Enum.flat_map(extra, &dep_paths(dep, &1)) + defp dep_paths(dep, extra) when is_binary(extra) do dep_path = dep_path(dep) + if dep_path do path = Path.join(dep_path, extra) |> path_if_exists() if path, do: [path], else: [] @@ -86,6 +105,5 @@ defmodule Mix.Tasks.Docs.Deps do defp dep_name(dep) when is_atom(dep), do: dep defp dep_name(dep) when is_binary(dep), do: dep - defp path_if_exists(path), do: if File.exists?(path), do: path - + defp path_if_exists(path), do: if(File.exists?(path), do: path) end diff --git a/lib/mix/tasks/localise/localise.extract.ex b/lib/mix/tasks/localise/localise.extract.ex index b15fe6953e..3fb8ece986 100755 --- a/lib/mix/tasks/localise/localise.extract.ex +++ b/lib/mix/tasks/localise/localise.extract.ex @@ -35,14 +35,18 @@ defmodule Mix.Tasks.Bonfire.Localise.Extract do _ = Mix.Project.get!() mix_config = Mix.Project.config() {opts, _} = OptionParser.parse!(args, switches: @switches) - gettext_config = mix_config[:gettext] || [] - |> debug("gettext config") - exts_to_localise = Bonfire.MixProject.deps_for(:localise) - |> debug("bonfire extensions to localise") + gettext_config = + (mix_config[:gettext] || []) + |> debug("gettext config") - deps_to_localise = Bonfire.MixProject.deps_for(:localise_self) - |> debug("other deps to localise") + exts_to_localise = + Bonfire.MixProject.deps_for(:localise) + |> debug("bonfire extensions to localise") + + deps_to_localise = + Bonfire.MixProject.deps_for(:localise_self) + |> debug("other deps to localise") touch_manifests() @@ -50,9 +54,10 @@ defmodule Mix.Tasks.Bonfire.Localise.Extract do pot_files = extract(:bonfire_common, gettext_config, exts_to_localise) # then those that have their own Gettext - pot_files = Enum.reduce(deps_to_localise, pot_files, fn dep, pot_files -> - pot_files ++ extract(String.to_atom(dep), gettext_config, dep) - end) + pot_files = + Enum.reduce(deps_to_localise, pot_files, fn dep, pot_files -> + pot_files ++ extract(String.to_atom(dep), gettext_config, dep) + end) # pot_files |> debug("extracted pot_files") @@ -72,6 +77,7 @@ defmodule Mix.Tasks.Bonfire.Localise.Extract do defp extract(app, gettext_config, deps_to_localise) do Gettext.Extractor.enable() force_compile(deps_to_localise) + Gettext.Extractor.pot_files( app, gettext_config @@ -81,8 +87,8 @@ defmodule Mix.Tasks.Bonfire.Localise.Extract do end defp force_compile(deps_to_localise) do - - Mix.Tasks.Bonfire.Dep.Compile.run(["--force"] ++ List.wrap(deps_to_localise)) # mark deps to be recompiled + # mark deps to be recompiled + Mix.Tasks.Bonfire.Dep.Compile.run(["--force"] ++ List.wrap(deps_to_localise)) # If "compile" was never called, the reenabling is a no-op and # "compile.elixir" is a no-op as well (because it wasn't reenabled after @@ -95,9 +101,8 @@ defmodule Mix.Tasks.Bonfire.Localise.Extract do end defp touch_manifests() do - Mix.Tasks.Compile.Elixir.manifests() # |> debug("manifests") - |> Enum.map(&make_old_if_exists/1) + Enum.map(Mix.Tasks.Compile.Elixir.manifests(), &make_old_if_exists/1) end defp make_old_if_exists(path) do @@ -108,7 +113,9 @@ defmodule Mix.Tasks.Bonfire.Localise.Extract do pot_files |> Enum.map(fn {path, _} -> Path.dirname(path) end) |> Enum.uniq() - |> Task.async_stream(&Mix.Tasks.Gettext.Merge.run([&1 | argv]), ordered: false) + |> Task.async_stream(&Mix.Tasks.Gettext.Merge.run([&1 | argv]), + ordered: false + ) |> Stream.run() end end diff --git a/lib/mix/tasks/release/lib/release.ex b/lib/mix/tasks/release/lib/release.ex index cdb5d582c0..7a7338ab56 100755 --- a/lib/mix/tasks/release/lib/release.ex +++ b/lib/mix/tasks/release/lib/release.ex @@ -21,33 +21,46 @@ defmodule Releaser.VersionUtils do def bump_pre(%Version{} = version, pre_label) do IO.inspect(old_pre: version.pre) - new_pre = if is_list(version.pre) and List.first(version.pre) == pre_label do - [pre_label, List.last(version.pre) + 1] - else - [pre_label, 1] - end + + new_pre = + if is_list(version.pre) and List.first(version.pre) == pre_label do + [pre_label, List.last(version.pre) + 1] + else + [pre_label, 1] + end + %{version | pre: new_pre} end - def version_to_string(%Version{major: major, minor: minor, patch: patch, pre: pre}) when is_list(pre) and length(pre)>0 do - "#{major}.#{minor}.#{patch}-"<>Enum.join(pre, ".") + def version_to_string(%Version{ + major: major, + minor: minor, + patch: patch, + pre: pre + }) + when is_list(pre) and length(pre) > 0 do + "#{major}.#{minor}.#{patch}-" <> Enum.join(pre, ".") end + def version_to_string(%Version{major: major, minor: minor, patch: patch}) do "#{major}.#{minor}.#{patch}" end def get_version(mix_path \\ ".") do - version = if Code.ensure_loaded?(Mix.Project) do - Mix.Project.config()[:version] - else - contents = File.read!(mix_path<>"/mix.exs") - Regex.run(@version_line_regex, contents) |> Enum.fetch!(2) - end |> IO.inspect + version = + if Code.ensure_loaded?(Mix.Project) do + Mix.Project.config()[:version] + else + contents = File.read!(mix_path <> "/mix.exs") + Regex.run(@version_line_regex, contents) |> Enum.fetch!(2) + end + |> IO.inspect() + Version.parse!(version) end def set_version(version, mix_path \\ ".") do - contents = File.read!(mix_path<>"/mix.exs") + contents = File.read!(mix_path <> "/mix.exs") version_string = version_to_string(version) replaced = @@ -55,17 +68,22 @@ defmodule Releaser.VersionUtils do "#{pre}#{version_string}#{post}" end) - File.write!(mix_path<>"/mix.exs", replaced) + File.write!(mix_path <> "/mix.exs", replaced) end def update_version(%Version{} = version, "major"), do: bump_major(version) def update_version(%Version{} = version, "minor"), do: bump_minor(version) def update_version(%Version{} = version, "patch"), do: bump_patch(version) - def update_version(%Version{} = version, "alpha"=pre_label), do: bump_pre(version, pre_label) - def update_version(%Version{} = version, "beta"=pre_label), do: bump_pre(version, pre_label) - def update_version(%Version{} = _version, type), do: raise("Invalid version type: #{type}") -end + def update_version(%Version{} = version, "alpha" = pre_label), + do: bump_pre(version, pre_label) + + def update_version(%Version{} = version, "beta" = pre_label), + do: bump_pre(version, pre_label) + + def update_version(%Version{} = _version, type), + do: raise("Invalid version type: #{type}") +end defmodule Releaser.Git do @doc """ @@ -77,6 +95,7 @@ defmodule Releaser.Git do version_string = VersionUtils.version_to_string(version) Mix.Shell.IO.cmd("git add .", []) Mix.Shell.IO.cmd(~s'git commit -m "Bumped version number"') + Mix.Shell.IO.cmd(~s'git tag -a v#{version_string} -m "Version #{version_string}"') end end @@ -108,15 +127,17 @@ end defmodule Mix.Tasks.Bonfire.Release do alias Releaser.VersionUtils - def main(args) do # for running as escript + # for running as escript + def main(args) do run(args) end - def run(args) do # when running as Mix task + # when running as Mix task + def run(args) do + mix_path = if is_list(args) and length(args) > 0, do: List.first(args), else: "." - mix_path = if is_list(args) and length(args)>0, do: List.first(args), else: "." - - release_type = if is_list(args) and length(args)>1, do: List.last(args), else: "alpha" # TODO make the default configurable + # TODO make the default configurable + release_type = if is_list(args) and length(args) > 1, do: List.last(args), else: "alpha" IO.inspect(release_type: release_type) @@ -129,7 +150,7 @@ defmodule Mix.Tasks.Bonfire.Release do IO.inspect(old_version: old_version) new_version = VersionUtils.update_version(old_version, release_type) - IO.inspect(new_version: new_version |> VersionUtils.version_to_string()) + IO.inspect(new_version: VersionUtils.version_to_string(new_version)) # Set a new version on the mix.exs file VersionUtils.set_version(new_version, mix_path) diff --git a/lib/mix/tasks/release/mix.exs b/lib/mix/tasks/release/mix.exs index e53345c5ac..67b1eacf8e 100755 --- a/lib/mix/tasks/release/mix.exs +++ b/lib/mix/tasks/release/mix.exs @@ -9,5 +9,4 @@ defmodule Bonfire.Release do escript: [main_module: Mix.Tasks.Bonfire.Release] ] end - end diff --git a/lib/mix/tasks/secrets/lib/secrets.ex b/lib/mix/tasks/secrets/lib/secrets.ex index 416c9f2995..c233d17257 100755 --- a/lib/mix/tasks/secrets/lib/secrets.ex +++ b/lib/mix/tasks/secrets/lib/secrets.ex @@ -9,14 +9,18 @@ defmodule Mix.Tasks.Bonfire.Secrets do """ use Mix.Task - def main(args) do # for running as escript + # for running as escript + def main(args) do run(args) end @doc false - def run([]), do: run(["64"]) - def run([int]), do: int |> parse!() |> random_string() |> Kernel.<>("\r\n") |> IO.puts() - def run([int, iterate]), do: for _ <- 1..parse!(iterate), do: run([int]) + def run([]), do: run(["64"]) + + def run([int]), + do: int |> parse!() |> random_string() |> Kernel.<>("\r\n") |> IO.puts() + + def run([int, iterate]), do: for(_ <- 1..parse!(iterate), do: run([int])) def run(args), do: invalid_args!(args) defp parse!(int) do @@ -27,11 +31,15 @@ defmodule Mix.Tasks.Bonfire.Secrets do end defp random_string(length) when length > 31 do - :crypto.strong_rand_bytes(length) |> Base.encode64 |> binary_part(0, length) + :crypto.strong_rand_bytes(length) + |> Base.encode64() + |> binary_part(0, length) end - defp random_string(_), do: raise "Secrets should be at least 32 characters long" + + defp random_string(_), + do: raise("Secrets should be at least 32 characters long") defp invalid_args!(args) do - raise "Expected a length as integer or no argument at all, got #{inspect args}" + raise "Expected a length as integer or no argument at all, got #{inspect(args)}" end end diff --git a/lib/mix/tasks/secrets/mix.exs b/lib/mix/tasks/secrets/mix.exs index 3df84cd9eb..01b2e9c52f 100755 --- a/lib/mix/tasks/secrets/mix.exs +++ b/lib/mix/tasks/secrets/mix.exs @@ -9,5 +9,4 @@ defmodule Bonfire.Secrets do escript: [main_module: Mix.Tasks.Bonfire.Secrets] ] end - end diff --git a/lib/mix/tasks/users/user.admin.promote.ex b/lib/mix/tasks/users/user.admin.promote.ex index caaf706a72..fa9a58a8c3 100644 --- a/lib/mix/tasks/users/user.admin.promote.ex +++ b/lib/mix/tasks/users/user.admin.promote.ex @@ -17,17 +17,19 @@ defmodule Mix.Tasks.Bonfire.User.Admin.Promote do alias Bonfire.Me.Users - @spec run(OptionParser.argv) :: :ok + @spec run(OptionParser.argv()) :: :ok def run(args) do options = options(args, %{}) Mix.Task.run("app.start") + case Users.by_username!(options.username) do - nil -> raise RuntimeError, message: "User not found" + nil -> + raise RuntimeError, message: "User not found" + user -> Users.make_admin(user) end end defp options([username], opts), do: Map.put(opts, :username, username) - end diff --git a/lib/oban_logger.ex b/lib/oban_logger.ex index df700640a9..64971ec9f6 100755 --- a/lib/oban_logger.ex +++ b/lib/oban_logger.ex @@ -2,8 +2,12 @@ defmodule Bonfire.ObanLogger do require Logger def setup do - - :telemetry.attach("bonfire-oban-errors", [:oban, :job, :exception], &Bonfire.ObanLogger.handle_event/4, []) + :telemetry.attach( + "bonfire-oban-errors", + [:oban, :job, :exception], + &Bonfire.ObanLogger.handle_event/4, + [] + ) end def handle_event([:oban, :job, :exception], measure, meta, _) do diff --git a/lib/repo/postgres_types.ex b/lib/repo/postgres_types.ex index 3d07f62543..2b8e596703 100755 --- a/lib/repo/postgres_types.ex +++ b/lib/repo/postgres_types.ex @@ -7,6 +7,10 @@ Postgrex.Types.define( Postgrex.Types.define( Bonfire.Geolocate.PostgresTypes, - Ecto.Adapters.Postgres.extensions() ++ (if Code.ensure_loaded?(Geo.PostGIS.Extension), do: [Geo.PostGIS.Extension], else: []), + Ecto.Adapters.Postgres.extensions() ++ + if(Code.ensure_loaded?(Geo.PostGIS.Extension), + do: [Geo.PostGIS.Extension], + else: [] + ), json: Jason ) diff --git a/lib/web/endpoint.ex b/lib/web/endpoint.ex index 8c634f7e9f..fbc8a9cf6a 100755 --- a/lib/web/endpoint.ex +++ b/lib/web/endpoint.ex @@ -8,7 +8,6 @@ defmodule Bonfire.Web.Endpoint do end def include_assets(conn, :top) do - # unused? # # @@ -16,12 +15,13 @@ defmodule Bonfire.Web.Endpoint do # imported into main CSS already # - font_family = Bonfire.Me.Settings.get([:ui, :font_family], "Inter", conn) - |> Utils.maybe_to_string() - |> String.trim_trailing(" Languages)") - |> String.replace([" ", "-", "(", ")"], "-") - |> String.replace("--", "-") - |> String.downcase() + font_family = + Bonfire.Me.Settings.get([:ui, :font_family], "Inter (Latin Languages)", conn) + |> Utils.maybe_to_string() + |> String.trim_trailing(" Languages)") + |> String.replace([" ", "-", "(", ")"], "-") + |> String.replace("--", "-") + |> String.downcase() """ @@ -32,18 +32,18 @@ defmodule Bonfire.Web.Endpoint do """ end - def include_assets(conn, :bottom) do - js = if Utils.e(conn, :assigns, :current_account, nil) || Utils.e(conn, :assigns, :current_user, nil) do - static_path("/assets/bonfire_live.js") - else - static_path("/assets/bonfire_basic.js") - end + js = + if Utils.e(conn, :assigns, :current_account, nil) || + Utils.e(conn, :assigns, :current_user, nil) do + static_path("/assets/bonfire_live.js") + else + static_path("/assets/bonfire_basic.js") + end - (PhoenixGon.View.render_gon_script(conn) |> Phoenix.HTML.safe_to_string) <> - """ - - """ + (PhoenixGon.View.render_gon_script(conn) |> Phoenix.HTML.safe_to_string()) <> + """ + + """ end - end diff --git a/lib/web/endpoint_template.ex b/lib/web/endpoint_template.ex index 7e4fab5936..b1c41c43dc 100644 --- a/lib/web/endpoint_template.ex +++ b/lib/web/endpoint_template.ex @@ -11,29 +11,38 @@ defmodule Bonfire.Web.EndpointTemplate do key: "_bonfire_key", signing_salt: Config.get!(:signing_salt), encryption_salt: Config.get!(:encryption_salt), - max_age: Config.get(:session_time_to_remember, 60*60*24*60) # 60 days by default + # 60 days by default + max_age: Config.get(:session_time_to_remember, 60 * 60 * 24 * 60) ] end defmacro __using__(_) do quote do - use Bonfire.ErrorReporting # make sure this comes before the Phoenix endpoint + # make sure this comes before the Phoenix endpoint + use Bonfire.ErrorReporting use Phoenix.Endpoint, otp_app: :bonfire import Bonfire.Common.Extend - use_if_enabled Absinthe.Phoenix.Endpoint + use_if_enabled(Absinthe.Phoenix.Endpoint) if Application.compile_env(:bonfire, :sql_sandbox) do plug(Phoenix.Ecto.SQL.Sandbox) end - socket "/live", Phoenix.LiveView.Socket, - websocket: [connect_info: [:user_agent, session: Bonfire.Web.EndpointTemplate.session_options()]] + socket("/live", Phoenix.LiveView.Socket, + websocket: [ + connect_info: [ + :user_agent, + session: Bonfire.Web.EndpointTemplate.session_options() + ] + ] + ) if module_enabled?(Bonfire.API.GraphQL.UserSocket) do - socket "/api/socket", Bonfire.API.GraphQL.UserSocket, + socket("/api/socket", Bonfire.API.GraphQL.UserSocket, websocket: true, longpoll: false + ) end # Serve at "/" the static files from "priv/static" directory. @@ -41,28 +50,33 @@ defmodule Bonfire.Web.EndpointTemplate do # You should set gzip to true if you are running phx.digest # when deploying your static files in production. - plug Plug.Static, + plug(Plug.Static, at: "/", from: :bonfire, gzip: true, - only: ~w(public assets css fonts images js favicon.ico robots.txt cache_manifest.json favicon.ico source.tar.gz index.html) + only: + ~w(public assets css fonts images js favicon.ico robots.txt cache_manifest.json favicon.ico source.tar.gz index.html) + ) - plug Plug.Static, + plug(Plug.Static, at: "/data/uploads/", from: "data/uploads", gzip: true + ) - plug Plug.Static, + plug(Plug.Static, at: "/", from: :livebook, gzip: true, only: ~w(images js) + ) - plug Plug.Static, + plug(Plug.Static, at: "/livebook/", from: :livebook, gzip: true, only: ~w(css images js favicon.ico robots.txt cache_manifest.json) + ) # Code reloading can be explicitly enabled under the # :code_reloader configuration of your endpoint. @@ -74,26 +88,27 @@ defmodule Bonfire.Web.EndpointTemplate do # plug Phoenix.Ecto.CheckRepoStatus, otp_app: :bonfire # end - plug Phoenix.LiveDashboard.RequestLogger, + plug(Phoenix.LiveDashboard.RequestLogger, param_key: "request_logger", cookie_key: "request_logger" + ) - plug Plug.RequestId - plug Plug.Telemetry, event_prefix: [:phoenix, :endpoint] + plug(Plug.RequestId) + plug(Plug.Telemetry, event_prefix: [:phoenix, :endpoint]) - plug Plug.Parsers, + plug(Plug.Parsers, parsers: [:urlencoded, :multipart, :json], pass: ["*/*"], json_decoder: Phoenix.json_library() + ) - plug Bonfire.ErrorReporting + plug(Bonfire.ErrorReporting) - plug Plug.MethodOverride - plug Plug.Head - plug Plug.Session, Bonfire.Web.EndpointTemplate.session_options() - - plug Bonfire.Web.Router + plug(Plug.MethodOverride) + plug(Plug.Head) + plug(Plug.Session, Bonfire.Web.EndpointTemplate.session_options()) + plug(Bonfire.Web.Router) end end end diff --git a/lib/web/graphql_schema.ex b/lib/web/graphql_schema.ex index c7f087cbc1..ff81753eae 100644 --- a/lib/web/graphql_schema.ex +++ b/lib/web/graphql_schema.ex @@ -1,235 +1,243 @@ # SPDX-License-Identifier: AGPL-3.0-only -if Bonfire.Common.Extend.module_enabled?(Bonfire.API.GraphQL) and Bonfire.Common.Extend.module_enabled?(Bonfire.ValueFlows.API.Schema) and Bonfire.Common.Extend.module_enabled?(Absinthe.Schema.Notation) do +if Bonfire.Common.Extend.module_enabled?(Bonfire.API.GraphQL) and + Bonfire.Common.Extend.module_enabled?(Bonfire.ValueFlows.API.Schema) and + Bonfire.Common.Extend.module_enabled?(Absinthe.Schema.Notation) do + defmodule Bonfire.API.GraphQL.Schema do + @moduledoc """ + Root GraphQL Schema. + Only active if the `Bonfire.API.GraphQL` extension is present. + """ -defmodule Bonfire.API.GraphQL.Schema do - @moduledoc """ - Root GraphQL Schema. - Only active if the `Bonfire.API.GraphQL` extension is present. - """ + use Absinthe.Schema + @schema_provider Absinthe.Schema.PersistentTerm - use Absinthe.Schema - @schema_provider Absinthe.Schema.PersistentTerm - # @pipeline_modifier Bonfire.API.GraphQL.SchemaPipelines + # @pipeline_modifier Bonfire.API.GraphQL.SchemaPipelines - require Logger + require Logger - alias Bonfire.API.GraphQL.SchemaUtils - alias Bonfire.API.GraphQL.Middleware.CollapseErrors - alias Absinthe.Resolution.Helpers + alias Bonfire.API.GraphQL.SchemaUtils + alias Bonfire.API.GraphQL.Middleware.CollapseErrors + alias Absinthe.Resolution.Helpers + + @doc """ + Define dataloaders + see https://hexdocs.pm/absinthe/1.4.6/ecto.html#dataloader + """ + def context(ctx) do + # IO.inspect(ctx: ctx) + loader = + Dataloader.add_source( + Dataloader.new(), + Pointers.Pointer, + Bonfire.Common.Pointers.dataloader(ctx) + ) - @doc """ - Define dataloaders - see https://hexdocs.pm/absinthe/1.4.6/ecto.html#dataloader - """ - def context(ctx) do - # IO.inspect(ctx: ctx) - loader = - Dataloader.new - |> Dataloader.add_source(Pointers.Pointer, Bonfire.Common.Pointers.dataloader(ctx)) # |> Dataloader.add_source(Bonfire.Data.Social.Posts, Bonfire.Common.Pointers.dataloader(ctx) ) - Map.put(ctx, :loader, loader) - end + Map.put(ctx, :loader, loader) + end - def plugins do - [ - Absinthe.Middleware.Async, - Absinthe.Middleware.Batch, - Absinthe.Middleware.Dataloader - ] - ++ Absinthe.Plugin.defaults() - end + def plugins do + [ + Absinthe.Middleware.Async, + Absinthe.Middleware.Batch, + Absinthe.Middleware.Dataloader + ] ++ + Absinthe.Plugin.defaults() + end - def middleware(middleware, _field, _object) do - # [{Bonfire.API.GraphQL.Middleware.Debug, :start}] ++ - middleware ++ [CollapseErrors] - end + def middleware(middleware, _field, _object) do + # [{Bonfire.API.GraphQL.Middleware.Debug, :start}] ++ + middleware ++ [CollapseErrors] + end - import_types(Bonfire.API.GraphQL.JSON) - import_types(Bonfire.API.GraphQL.Cursor) + import_types(Bonfire.API.GraphQL.JSON) + import_types(Bonfire.API.GraphQL.Cursor) - import_types(Bonfire.API.GraphQL.CommonSchema) - - - - # Extension Modules - import_types(Bonfire.Me.API.GraphQL) - import_types(Bonfire.Social.API.GraphQL) - - # import_types(CommonsPub.Locales.GraphQL.Schema) - - import_types(Bonfire.Tag.GraphQL.TagSchema) - import_types(Bonfire.Classify.GraphQL.ClassifySchema) - - import_types(Bonfire.Quantify.Units.GraphQL) - import_types(Bonfire.Geolocate.GraphQL) - - import_types(Bonfire.ValueFlows.API.Schema) - import_types(Bonfire.ValueFlows.API.Schema.Subscriptions) - - import_types(Bonfire.ValueFlows.API.Schema.Observe) - - - query do - import_fields(:common_queries) + import_types(Bonfire.API.GraphQL.CommonSchema) # Extension Modules - import_fields(:me_queries) - import_fields(:social_queries) - # import_fields(:profile_queries) - # import_fields(:character_queries) + import_types(Bonfire.Me.API.GraphQL) + import_types(Bonfire.Social.API.GraphQL) - # import_fields(:organisations_queries) + # import_types(CommonsPub.Locales.GraphQL.Schema) - import_fields(:tag_queries) - import_fields(:classify_queries) + import_types(Bonfire.Tag.GraphQL.TagSchema) + import_types(Bonfire.Classify.GraphQL.ClassifySchema) - # import_fields(:locales_queries) + import_types(Bonfire.Quantify.Units.GraphQL) + import_types(Bonfire.Geolocate.GraphQL) - import_fields(:measurement_query) + import_types(Bonfire.ValueFlows.API.Schema) + import_types(Bonfire.ValueFlows.API.Schema.Subscriptions) - import_fields(:geolocation_query) + import_types(Bonfire.ValueFlows.API.Schema.Observe) - # ValueFlows - import_fields(:value_flows_query) - # import_fields(:value_flows_extra_queries) + query do + import_fields(:common_queries) - import_fields(:valueflows_observe_queries) - end + # Extension Modules + import_fields(:me_queries) + import_fields(:social_queries) - mutation do - import_fields(:common_mutations) + # import_fields(:profile_queries) + # import_fields(:character_queries) + # import_fields(:organisations_queries) - # Extension Modules - import_fields(:me_mutations) - import_fields(:social_mutations) + import_fields(:tag_queries) + import_fields(:classify_queries) - import_fields(:tag_mutations) - import_fields(:classify_mutations) + # import_fields(:locales_queries) - import_fields(:geolocation_mutation) - import_fields(:measurement_mutation) + import_fields(:measurement_query) - # ValueFlows + import_fields(:geolocation_query) - import_fields(:value_flows_mutation) + # ValueFlows + import_fields(:value_flows_query) + # import_fields(:value_flows_extra_queries) - import_fields(:valueflows_observe_mutations) + import_fields(:valueflows_observe_queries) + end - end + mutation do + import_fields(:common_mutations) - subscription do + # Extension Modules + import_fields(:me_mutations) + import_fields(:social_mutations) - import_fields(:valueflows_subscriptions) + import_fields(:tag_mutations) + import_fields(:classify_mutations) - end + import_fields(:geolocation_mutation) + import_fields(:measurement_mutation) + # ValueFlows - @doc """ - hydrate SDL schema with resolvers - """ - def hydrate(%Absinthe.Blueprint{}, _) do - SchemaUtils.hydrations_merge([ - Bonfire.Geolocate.GraphQL.Hydration, - Bonfire.Quantify.Hydration, - ValueFlows.Hydration, - ValueFlows.Observe.Hydration - ]) - end + import_fields(:value_flows_mutation) - # hydrations fallback - def hydrate(_node, _ancestors) do - [] - end + import_fields(:valueflows_observe_mutations) + end - union :any_character do - description("Any type of character (eg. Category, Thread, Geolocation, etc), actor (eg. User/Person), or agent (eg. Organisation)") + subscription do + import_fields(:valueflows_subscriptions) + end - # TODO: autogenerate from extensions - # types(SchemaUtils.context_types) + @doc """ + hydrate SDL schema with resolvers + """ + def hydrate(%Absinthe.Blueprint{}, _) do + SchemaUtils.hydrations_merge([ + Bonfire.Geolocate.GraphQL.Hydration, + Bonfire.Quantify.Hydration, + ValueFlows.Hydration, + ValueFlows.Observe.Hydration + ]) + end - types([ - # :community, - # :collection, - :user, - # :organisation, - :category, - :spatial_thing - ]) + # hydrations fallback + def hydrate(_node, _ancestors) do + [] + end - resolve_type(&schema_to_api_type/2) - end + union :any_character do + description( + "Any type of character (eg. Category, Thread, Geolocation, etc), actor (eg. User/Person), or agent (eg. Organisation)" + ) - union :any_context do - description("Any type of known object") + # TODO: autogenerate from extensions + # types(SchemaUtils.context_types) - # TODO: autogenerate from extensions or pointers - # types(SchemaUtils.context_types) + types([ + # :community, + # :collection, + :user, + # :organisation, + :category, + :spatial_thing + ]) - types([ - # :community, - # :collection, - # :comment, - # :flag, - # :follow, - :activity, - :post, - :user, - # :organisation, - :category, - :tag, - :spatial_thing, - :intent, - :process, - :economic_event - ]) + resolve_type(&schema_to_api_type/2) + end - resolve_type(&schema_to_api_type/2) - end + union :any_context do + description("Any type of known object") - def schema_to_api_type(object, recursing) do - case object do - %Bonfire.Data.Identity.User{} -> :user + # TODO: autogenerate from extensions or pointers + # types(SchemaUtils.context_types) - %Bonfire.Data.Social.Post{} -> :post + types([ + # :community, + # :collection, + # :comment, + # :flag, + # :follow, + :activity, + :post, + :user, + # :organisation, + :category, + :tag, + :spatial_thing, + :intent, + :process, + :economic_event + ]) - %Bonfire.Data.Social.Activity{} -> :activity + resolve_type(&schema_to_api_type/2) + end - %Bonfire.Data.Social.Follow{} -> :follow + def schema_to_api_type(object, recursing) do + case object do + %Bonfire.Data.Identity.User{} -> + :user - # %Bonfire.Data.SharedUser{} -> + %Bonfire.Data.Social.Post{} -> + :post + + %Bonfire.Data.Social.Activity{} -> + :activity + + %Bonfire.Data.Social.Follow{} -> + :follow + + # %Bonfire.Data.SharedUser{} -> # :organisation - %Bonfire.Geolocate.Geolocation{} -> :spatial_thing + %Bonfire.Geolocate.Geolocation{} -> + :spatial_thing - %Bonfire.Classify.Category{} -> :category + %Bonfire.Classify.Category{} -> + :category - # %Bonfire.Tag{} -> :tag + # %Bonfire.Tag{} -> :tag + # %ValueFlows.Planning.Intent{} -> :intent + # %ValueFlows.Process{} -> :process + # %ValueFlows.EconomicEvent{} -> :economic_event - # %ValueFlows.Planning.Intent{} -> :intent + object -> + case Bonfire.Common.Types.object_type(object) do + type when is_atom(type) and not is_nil(type) -> + Logger.debug("API any_context: object_type recognised: #{type}") - # %ValueFlows.Process{} -> :process + if recursing != true do + schema_to_api_type(struct(type), true) + else + Logger.error("API any_context: no API type is defined for schema #{type}") - # %ValueFlows.EconomicEvent{} -> :economic_event + IO.inspect(object, label: "API any_context object") + nil + end - object -> + _ -> + Logger.warn( + "API any_context: resolved to an unknown type: #{inspect(object, pretty: true)}" + ) - case Bonfire.Common.Types.object_type(object) do - type when is_atom(type) and not is_nil(type) -> - Logger.debug("API any_context: object_type recognised: #{type}") - if recursing != true do - schema_to_api_type(struct(type), true) - else - Logger.error("API any_context: no API type is defined for schema #{type}") - IO.inspect(object, label: "API any_context object") nil - end - - _ -> - Logger.warn("API any_context: resolved to an unknown type: #{inspect(object, pretty: true)}") - nil - end + end + end end end end -end diff --git a/lib/web/home/home_live.ex b/lib/web/home/home_live.ex index bb5beb24e5..895c12816c 100755 --- a/lib/web/home/home_live.ex +++ b/lib/web/home/home_live.ex @@ -8,53 +8,56 @@ defmodule Bonfire.Web.HomeLive do @changelog File.read!("docs/CHANGELOG.md") def mount(params, session, socket) do - live_plug params, session, socket, [ + live_plug(params, session, socket, [ LivePlugs.LoadCurrentAccount, LivePlugs.LoadCurrentUser, Bonfire.UI.Common.LivePlugs.StaticChanged, Bonfire.UI.Common.LivePlugs.Csrf, Bonfire.UI.Common.LivePlugs.Locale, - &mounted/3, - ] + &mounted/3 + ]) end defp mounted(_params, _session, socket) do instance_name = Config.get([:ui, :theme, :instance_name], Bonfire.Application.name()) - links = Config.get([:ui, :theme, :instance_welcome, :links], %{ - l("About Bonfire") => "https://bonfirenetworks.org/", - l("Contribute") => "https://bonfirenetworks.org/contribute/" - }) - {:ok, socket - |> assign( - page: "home", - selected_tab: "home", - page_title: instance_name, - links: links, - changelog: @changelog, - without_sidebar: true, - sidebar_widgets: [ - users: [ - secondary: [ - {Bonfire.UI.Common.WidgetInstanceInfoLive, [display_banner: false]}, - {Bonfire.UI.Common.WidgetLinksLive, [links: links]}, - {Bonfire.UI.Me.WidgetAdminsLive, []}, - {Bonfire.UI.Social.WidgetTagsLive, [links: links]} - ] - ], - guests: [ - main: [ - {Bonfire.UI.Social.WidgetTimelinesLive, [page: "home"]}, - ], - secondary: [ - {Bonfire.UI.Common.WidgetInstanceInfoLive, [display_banner: false]}, - {Bonfire.UI.Common.WidgetLinksLive, [links: links]}, - {Bonfire.UI.Me.WidgetAdminsLive, []}, - {Bonfire.UI.Social.WidgetTagsLive, [links: links]} - ] - ], - ] - )} + links = + Config.get([:ui, :theme, :instance_welcome, :links], %{ + l("About Bonfire") => "https://bonfirenetworks.org/", + l("Contribute") => "https://bonfirenetworks.org/contribute/" + }) + + {:ok, + assign( + socket, + page: "home", + selected_tab: "home", + page_title: instance_name, + links: links, + changelog: @changelog, + without_sidebar: true, + sidebar_widgets: [ + users: [ + secondary: [ + {Bonfire.UI.Common.WidgetInstanceInfoLive, [display_banner: false]}, + {Bonfire.UI.Common.WidgetLinksLive, [links: links]}, + {Bonfire.UI.Me.WidgetAdminsLive, []}, + {Bonfire.UI.Social.WidgetTagsLive, [links: links]} + ] + ], + guests: [ + main: [ + {Bonfire.UI.Social.WidgetTimelinesLive, [page: "home"]} + ], + secondary: [ + {Bonfire.UI.Common.WidgetInstanceInfoLive, [display_banner: false]}, + {Bonfire.UI.Common.WidgetLinksLive, [links: links]}, + {Bonfire.UI.Me.WidgetAdminsLive, []}, + {Bonfire.UI.Social.WidgetTagsLive, [links: links]} + ] + ] + ] + )} end def do_handle_params(%{"tab" => tab} = _params, _url, socket) do @@ -68,18 +71,26 @@ defmodule Bonfire.Web.HomeLive do {:noreply, socket} end - # defdelegate handle_params(params, attrs, socket), to: Bonfire.UI.Common.LiveHandlers def handle_params(params, uri, socket) do # poor man's hook I guess - with {_, socket} <- Bonfire.UI.Common.LiveHandlers.handle_params(params, uri, socket) do + with {_, socket} <- + Bonfire.UI.Common.LiveHandlers.handle_params(params, uri, socket) do undead_params(socket, fn -> do_handle_params(params, uri, socket) end) end end - def handle_event(action, attrs, socket), do: Bonfire.UI.Common.LiveHandlers.handle_event(action, attrs, socket, __MODULE__) - def handle_info(info, socket), do: Bonfire.UI.Common.LiveHandlers.handle_info(info, socket, __MODULE__) + def handle_event(action, attrs, socket), + do: + Bonfire.UI.Common.LiveHandlers.handle_event( + action, + attrs, + socket, + __MODULE__ + ) + def handle_info(info, socket), + do: Bonfire.UI.Common.LiveHandlers.handle_info(info, socket, __MODULE__) end diff --git a/lib/web/home/home_live.sface b/lib/web/home/home_live.sface index 2bd64b7379..0c991f3bda 100644 --- a/lib/web/home/home_live.sface +++ b/lib/web/home/home_live.sface @@ -1,11 +1,11 @@ +
+
+
-
-
-
- -