Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/hex/server/poison-5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
skanderm authored Mar 11, 2024
2 parents 1eba605 + 8f39562 commit 14f30cd
Show file tree
Hide file tree
Showing 4 changed files with 333 additions and 6 deletions.
18 changes: 18 additions & 0 deletions server/lib/orcasite/radio/detection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ defmodule Orcasite.Radio.Detection do
relationships do
belongs_to :candidate, Candidate
belongs_to :feed, Feed

belongs_to :user, Orcasite.Accounts.User do
api Orcasite.Accounts
end
end

policies do
Expand Down Expand Up @@ -181,6 +185,17 @@ defmodule Orcasite.Radio.Detection do

change manage_relationship(:feed_id, :feed, type: :append)

change fn changeset, %{actor: actor} ->
case actor do
%Orcasite.Accounts.User{} ->
changeset
|> Ash.Changeset.manage_relationship(:user, actor, type: :append)

_ ->
changeset
end
end

change fn changeset, _context ->
playlist_timestamp = changeset |> Ash.Changeset.get_argument(:playlist_timestamp)
player_offset = changeset |> Ash.Changeset.get_argument(:player_offset)
Expand Down Expand Up @@ -273,6 +288,9 @@ defmodule Orcasite.Radio.Detection do

graphql do
type :detection
# Remove user until we want to make use of this behind
# an authenticated/authorized call
hide_fields [:user]

queries do
get :detection, :read
Expand Down
Loading

0 comments on commit 14f30cd

Please sign in to comment.