Skip to content

Commit b331c67

Browse files
authored
fix issue with hidden offerings disappearing for studios (#781)
Fixes: #780
1 parent ce4e6c0 commit b331c67

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

lib/banchan/offerings/offerings.ex

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -751,19 +751,22 @@ defmodule Banchan.Offerings do
751751
{:ok, %User{} = current_user} ->
752752
q
753753
|> join(:inner, [], user in User, on: user.id == ^current_user.id, as: :current_user)
754+
|> join(:left, [studio: studio], artist in assoc(studio, :artists), as: :artist)
754755
|> where(
755756
[
756757
studio: s,
757758
offering: o,
758-
current_user: current_user
759+
current_user: current_user,
760+
artist: artist
759761
],
760-
o.mature != true or
762+
current_user == artist or
763+
o.mature != true or
761764
((s.mature == true or o.mature == true) and ^mature_content_enabled? == true and
762765
current_user.mature_ok == true)
763766
)
764767
|> where(
765-
[offering: o],
766-
o.hidden == false
768+
[offering: o, current_user: current_user, artist: artist],
769+
artist == current_user or o.hidden == false
767770
)
768771
|> join(:left, [offering: o, current_user: current_user], sub in OfferingSubscription,
769772
on:
@@ -772,14 +775,15 @@ defmodule Banchan.Offerings do
772775
as: :subscription
773776
)
774777
|> where(
775-
[o, current_user: current_user],
776-
is_nil(current_user.muted) or
778+
[o, current_user: current_user, artist: artist],
779+
artist == current_user or is_nil(current_user.muted) or
777780
not fragment("(?).muted_filter_query @@ (?).search_vector", current_user, o)
778781
)
779782
|> join(:left, [studio: s], block in assoc(s, :blocklist), as: :blocklist)
780783
|> where(
781-
[blocklist: block, current_user: u],
782-
:admin in u.roles or :mod in u.roles or is_nil(block) or block.user_id != u.id
784+
[blocklist: block, current_user: u, artist: artist],
785+
artist == u or :admin in u.roles or :mod in u.roles or is_nil(block) or
786+
block.user_id != u.id
783787
)
784788
|> select_merge([o, subscription: sub], %{
785789
user_subscribed?: not is_nil(sub.id)

0 commit comments

Comments
 (0)