Add 'notifying' to relationship for compatibility with Mastodon
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
3892bd353b
commit
c96e52b88c
|
@ -159,6 +159,7 @@ See [Admin-API](admin_api.md)
|
||||||
"muting": false,
|
"muting": false,
|
||||||
"muting_notifications": false,
|
"muting_notifications": false,
|
||||||
"subscribing": true,
|
"subscribing": true,
|
||||||
|
"notifying": true,
|
||||||
"requested": false,
|
"requested": false,
|
||||||
"domain_blocking": false,
|
"domain_blocking": false,
|
||||||
"showing_reblogs": true,
|
"showing_reblogs": true,
|
||||||
|
@ -183,6 +184,7 @@ See [Admin-API](admin_api.md)
|
||||||
"muting": false,
|
"muting": false,
|
||||||
"muting_notifications": false,
|
"muting_notifications": false,
|
||||||
"subscribing": false,
|
"subscribing": false,
|
||||||
|
"notifying": false,
|
||||||
"requested": false,
|
"requested": false,
|
||||||
"domain_blocking": false,
|
"domain_blocking": false,
|
||||||
"showing_reblogs": true,
|
"showing_reblogs": true,
|
||||||
|
|
|
@ -694,6 +694,7 @@ defp array_of_relationships do
|
||||||
"requested" => false,
|
"requested" => false,
|
||||||
"domain_blocking" => false,
|
"domain_blocking" => false,
|
||||||
"subscribing" => false,
|
"subscribing" => false,
|
||||||
|
"notifying" => false,
|
||||||
"endorsed" => true
|
"endorsed" => true
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
|
@ -708,6 +709,7 @@ defp array_of_relationships do
|
||||||
"requested" => true,
|
"requested" => true,
|
||||||
"domain_blocking" => false,
|
"domain_blocking" => false,
|
||||||
"subscribing" => false,
|
"subscribing" => false,
|
||||||
|
"notifying" => false,
|
||||||
"endorsed" => false
|
"endorsed" => false
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
|
@ -722,6 +724,7 @@ defp array_of_relationships do
|
||||||
"requested" => false,
|
"requested" => false,
|
||||||
"domain_blocking" => true,
|
"domain_blocking" => true,
|
||||||
"subscribing" => true,
|
"subscribing" => true,
|
||||||
|
"notifying" => true,
|
||||||
"endorsed" => false
|
"endorsed" => false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -196,7 +196,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
|
||||||
"muting_notifications" => false,
|
"muting_notifications" => false,
|
||||||
"requested" => false,
|
"requested" => false,
|
||||||
"showing_reblogs" => true,
|
"showing_reblogs" => true,
|
||||||
"subscribing" => false
|
"subscribing" => false,
|
||||||
|
"notifying" => false
|
||||||
},
|
},
|
||||||
"settings_store" => %{
|
"settings_store" => %{
|
||||||
"pleroma-fe" => %{}
|
"pleroma-fe" => %{}
|
||||||
|
|
|
@ -24,7 +24,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.AccountRelationship do
|
||||||
muting_notifications: %Schema{type: :boolean},
|
muting_notifications: %Schema{type: :boolean},
|
||||||
requested: %Schema{type: :boolean},
|
requested: %Schema{type: :boolean},
|
||||||
showing_reblogs: %Schema{type: :boolean},
|
showing_reblogs: %Schema{type: :boolean},
|
||||||
subscribing: %Schema{type: :boolean}
|
subscribing: %Schema{type: :boolean},
|
||||||
|
notifying: %Schema{type: :boolean}
|
||||||
},
|
},
|
||||||
example: %{
|
example: %{
|
||||||
"blocked_by" => false,
|
"blocked_by" => false,
|
||||||
|
@ -38,7 +39,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.AccountRelationship do
|
||||||
"muting_notifications" => false,
|
"muting_notifications" => false,
|
||||||
"requested" => false,
|
"requested" => false,
|
||||||
"showing_reblogs" => true,
|
"showing_reblogs" => true,
|
||||||
"subscribing" => false
|
"subscribing" => false,
|
||||||
|
"notifying" => false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
@ -284,7 +284,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
|
||||||
"muting_notifications" => false,
|
"muting_notifications" => false,
|
||||||
"requested" => false,
|
"requested" => false,
|
||||||
"showing_reblogs" => true,
|
"showing_reblogs" => true,
|
||||||
"subscribing" => false
|
"subscribing" => false,
|
||||||
|
"notifying" => false
|
||||||
},
|
},
|
||||||
"skip_thread_containment" => false,
|
"skip_thread_containment" => false,
|
||||||
"tags" => []
|
"tags" => []
|
||||||
|
|
|
@ -41,10 +41,12 @@ defp set_subscription(true, {:ok, follower, followed, _}) do
|
||||||
User.subscribe(follower, followed)
|
User.subscribe(follower, followed)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp set_subscription(_, {:ok, follower, followed, _}) do
|
defp set_subscription(false, {:ok, follower, followed, _}) do
|
||||||
User.unsubscribe(follower, followed)
|
User.unsubscribe(follower, followed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp set_subscription(_, _), do: {:ok, nil}
|
||||||
|
|
||||||
@spec get_followers(User.t(), map()) :: list(User.t())
|
@spec get_followers(User.t(), map()) :: list(User.t())
|
||||||
def get_followers(user, params \\ %{}) do
|
def get_followers(user, params \\ %{}) do
|
||||||
user
|
user
|
||||||
|
|
|
@ -101,6 +101,15 @@ def render(
|
||||||
User.following?(target, reading_user)
|
User.following?(target, reading_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
subscribing =
|
||||||
|
UserRelationship.exists?(
|
||||||
|
user_relationships,
|
||||||
|
:inverse_subscription,
|
||||||
|
target,
|
||||||
|
reading_user,
|
||||||
|
&User.subscribed_to?(&2, &1)
|
||||||
|
)
|
||||||
|
|
||||||
# NOTE: adjust UserRelationship.view_relationships_option/2 on new relation-related flags
|
# NOTE: adjust UserRelationship.view_relationships_option/2 on new relation-related flags
|
||||||
%{
|
%{
|
||||||
id: to_string(target.id),
|
id: to_string(target.id),
|
||||||
|
@ -138,14 +147,8 @@ def render(
|
||||||
target,
|
target,
|
||||||
&User.muted_notifications?(&1, &2)
|
&User.muted_notifications?(&1, &2)
|
||||||
),
|
),
|
||||||
subscribing:
|
subscribing: subscribing,
|
||||||
UserRelationship.exists?(
|
notifying: subscribing,
|
||||||
user_relationships,
|
|
||||||
:inverse_subscription,
|
|
||||||
target,
|
|
||||||
reading_user,
|
|
||||||
&User.subscribed_to?(&2, &1)
|
|
||||||
),
|
|
||||||
requested: follow_state == :follow_pending,
|
requested: follow_state == :follow_pending,
|
||||||
domain_blocking: User.blocks_domain?(reading_user, target),
|
domain_blocking: User.blocks_domain?(reading_user, target),
|
||||||
showing_reblogs:
|
showing_reblogs:
|
||||||
|
|
|
@ -922,7 +922,7 @@ test "following with reblogs" do
|
||||||
|> json_response_and_validate_schema(200)
|
|> json_response_and_validate_schema(200)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "following with subscription and unsubscribing when notify is nil" do
|
test "following with subscription and unsubscribing" do
|
||||||
%{conn: conn} = oauth_access(["follow"])
|
%{conn: conn} = oauth_access(["follow"])
|
||||||
followed = insert(:user)
|
followed = insert(:user)
|
||||||
|
|
||||||
|
@ -937,7 +937,7 @@ test "following with subscription and unsubscribing when notify is nil" do
|
||||||
ret_conn =
|
ret_conn =
|
||||||
conn
|
conn
|
||||||
|> put_req_header("content-type", "application/json")
|
|> put_req_header("content-type", "application/json")
|
||||||
|> post("/api/v1/accounts/#{followed.id}/follow")
|
|> post("/api/v1/accounts/#{followed.id}/follow", %{notify: false})
|
||||||
|
|
||||||
assert %{"id" => _id, "subscribing" => false} =
|
assert %{"id" => _id, "subscribing" => false} =
|
||||||
json_response_and_validate_schema(ret_conn, 200)
|
json_response_and_validate_schema(ret_conn, 200)
|
||||||
|
|
|
@ -268,6 +268,7 @@ defp test_relationship_rendering(user, other_user, expected_result) do
|
||||||
muting: false,
|
muting: false,
|
||||||
muting_notifications: false,
|
muting_notifications: false,
|
||||||
subscribing: false,
|
subscribing: false,
|
||||||
|
notifying: false,
|
||||||
requested: false,
|
requested: false,
|
||||||
domain_blocking: false,
|
domain_blocking: false,
|
||||||
showing_reblogs: true,
|
showing_reblogs: true,
|
||||||
|
@ -293,6 +294,7 @@ test "represent a relationship for the following and followed user" do
|
||||||
muting: true,
|
muting: true,
|
||||||
muting_notifications: true,
|
muting_notifications: true,
|
||||||
subscribing: true,
|
subscribing: true,
|
||||||
|
notifying: true,
|
||||||
showing_reblogs: false,
|
showing_reblogs: false,
|
||||||
id: to_string(other_user.id)
|
id: to_string(other_user.id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue