This commit is contained in:
Mayel de Borniol 2022-01-25 18:05:42 +13:00 committed by jjl
parent 34db1af5e5
commit 4a42d19ea8
5 changed files with 32 additions and 17 deletions

View file

@ -246,7 +246,7 @@ endif
#### CONTRIBUTION RELATED COMMANDS ####
contrib.forks: contrib.forks.publish contrib.app.up ## Push all changes to the app and extensions in ./forks
contrib.forks: contrib.forks.publish git.publish ## Push all changes to the app and extensions in ./forks
contrib.release: contrib.forks.publish contrib.app.release ## Push all changes to the app and extensions in ./forks, increment the app version number, and push a new version/release

View file

@ -77,6 +77,16 @@ alias Bonfire.{Tag, Tag.Tagged}
## Note: This does not apply to configuration for
## `Pointers.Changesets`, which is read at runtime, not compile time
edge = quote do
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
has_many :activities, unquote(Activity), foreign_key: :object_id, references: :id
end
edges = quote do
unquote(edge)
# has_one :edge, unquote(Edge), foreign_key: :id
has_one :activity, unquote(Activity), foreign_key: :object_id, references: :id # requires an ON clause
end
# first up, pointers could have all the mixins we're using. TODO
config :pointers, Pointer,
@ -95,6 +105,7 @@ config :pointers, Pointer,
has_one :stereotype, unquote(Stereotype), foreign_key: :id
has_one :named, unquote(Named), foreign_key: :id
has_one :caretaker, unquote(Caretaker), foreign_key: :id
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
has_one :created, unquote(Created), foreign_key: :id
has_one :peered, unquote(Peered), foreign_key: :id, references: :id
has_one :activity, unquote(Activity), foreign_key: :object_id, references: :id
@ -104,14 +115,16 @@ config :pointers, Pointer,
has_one :character, unquote(Character), foreign_key: :id
has_one :actor, unquote(Actor), foreign_key: :id
has_one :edge, unquote(Edge), foreign_key: :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]
has_one :follow_count, unquote(EdgeTotal),
foreign_key: :id, references: :id, where: [table_id: @follow_ulid]
has_many :direct_replies, unquote(Replied), foreign_key: :reply_to_id
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
# add references of tags to any tagged Pointer
has_many :tagged, unquote(Tagged), foreign_key: :id, references: :id
many_to_many :tags, unquote(Pointer),
@ -278,7 +291,8 @@ config :bonfire_data_social, Activity,
config :bonfire_data_social, Edge,
[code: quote do
# TODO: requires composite foreign keys
unquote(edge)
# TODO: requires composite foreign keys:
# has_one :activity, unquote(Activity),
# foreign_key: [:table_id, :object_id], references: [:table_id, :object_id]
end]
@ -293,6 +307,7 @@ config :bonfire_data_social, FeedPublish, []
config :bonfire_data_social, Follow,
[code: quote do
unquote(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}],
@ -301,31 +316,30 @@ config :bonfire_data_social, Follow,
config :bonfire_data_social, Block,
[code: quote do
has_one :edge, unquote(Edge), foreign_key: :id
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
unquote(edges)
end]
config :bonfire_data_social, Boost,
[code: quote do
has_one :edge, unquote(Edge), foreign_key: :id
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
unquote(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
has_one :edge, unquote(Edge), foreign_key: :id
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
unquote(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
has_one :edge, unquote(Edge), foreign_key: :id
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
unquote(edges)
end]
config :bonfire_data_social, Bookmark, []
config :bonfire_data_social, Bookmark,
[code: quote do
unquote(edges)
end]
config :bonfire_data_social, Message,
[code: quote do
@ -344,6 +358,7 @@ config :bonfire_data_social, Message,
references: :id, where: [table_id: @boost_ulid]
has_many :direct_replies, unquote(Replied), foreign_key: :reply_to_id
has_many :controlled, unquote(Controlled), foreign_key: :id, references: :id
has_one :caretaker, unquote(Caretaker), foreign_key: :id
end]
config :bonfire_data_social, Mention, []

View file

@ -2,7 +2,6 @@ defmodule Bonfire.Web.HomeLive do
use Bonfire.Web, {:surface_view, [layout: {Bonfire.UI.Social.Web.LayoutView, "without_sidebar.html"}]}
alias Bonfire.Web.LivePlugs
import Bonfire.Web.Gettext
def mount(params, session, socket) do
LivePlugs.live_plug params, session, socket, [

View file

@ -85,21 +85,21 @@ defmodule Bonfire.Web.Router do
## Below you can define routes specific to your flavour of Bonfire (which aren't handled by extensions)
# pages anyone can view
scope "/", Bonfire do
scope "/" do
pipe_through :browser
live "/", Web.HomeLive, as: :home
live "/", Bonfire.Web.HomeLive, as: :home
# a default homepage which you can customise (at path "/")
# can be replaced with something else (eg. bonfire_website extension or similar), in which case you may want to rename the path (eg. to "/home")
# live "/", Website.HomeGuestLive, as: :landing
# live "/home", Web.HomeLive, as: :home
live "/error", Common.Web.ErrorLive
live "/error", Bonfire.Common.Web.ErrorLive
end
# pages only guests can view
scope "/", Bonfire.Me.Web do
scope "/", Bonfire do
pipe_through :browser
pipe_through :guest_only
end

View file

@ -27,6 +27,7 @@ defmodule Bonfire.DataCase do
import Bonfire.Test.FakeHelpers
import Bonfire.Me.Fake
alias Bonfire.Me.Fake
use Bonfire.Common.Utils
end
end