Merge branch 'feature/1530-removing-with_move' into 'develop'

Feature/1530 removing with move

Closes #1530

See merge request pleroma/pleroma!2306
This commit is contained in:
rinpatch 2020-03-18 10:12:50 +00:00
commit 69341cbcba
8 changed files with 16 additions and 34 deletions

View File

@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed ### Changed
- **Breaking:** BBCode and Markdown formatters will no longer return any `\n` and only use `<br/>` for newlines - **Breaking:** BBCode and Markdown formatters will no longer return any `\n` and only use `<br/>` for newlines
### Removed
- **Breaking:** removed `with_move` parameter from notifications timeline.
## [2.0.0] - 2019-03-08 ## [2.0.0] - 2019-03-08
### Security ### Security
- Mastodon API: Fix being able to request enourmous amount of statuses in timelines leading to DoS. Now limited to 40 per request. - Mastodon API: Fix being able to request enourmous amount of statuses in timelines leading to DoS. Now limited to 40 per request.

View File

@ -117,7 +117,6 @@ The `type` value is `pleroma:emoji_reaction`. Has these fields:
Accepts additional parameters: Accepts additional parameters:
- `exclude_visibilities`: will exclude the notifications for activities with the given visibilities. The parameter accepts an array of visibility types (`public`, `unlisted`, `private`, `direct`). Usage example: `GET /api/v1/notifications?exclude_visibilities[]=direct&exclude_visibilities[]=private`. - `exclude_visibilities`: will exclude the notifications for activities with the given visibilities. The parameter accepts an array of visibility types (`public`, `unlisted`, `private`, `direct`). Usage example: `GET /api/v1/notifications?exclude_visibilities[]=direct&exclude_visibilities[]=private`.
- `with_move`: boolean, when set to `true` will include Move notifications. `false` by default.
## POST `/api/v1/statuses` ## POST `/api/v1/statuses`

View File

@ -77,7 +77,6 @@ def for_user_query(user, opts \\ %{}) do
|> exclude_notification_muted(user, exclude_notification_muted_opts) |> exclude_notification_muted(user, exclude_notification_muted_opts)
|> exclude_blocked(user, exclude_blocked_opts) |> exclude_blocked(user, exclude_blocked_opts)
|> exclude_visibility(opts) |> exclude_visibility(opts)
|> exclude_move(opts)
end end
defp exclude_blocked(query, user, opts) do defp exclude_blocked(query, user, opts) do
@ -107,14 +106,6 @@ defp exclude_notification_muted(query, user, opts) do
|> where([n, a, o, tm], is_nil(tm.user_id)) |> where([n, a, o, tm], is_nil(tm.user_id))
end end
defp exclude_move(query, %{with_move: true}) do
query
end
defp exclude_move(query, _opts) do
where(query, [n, a], fragment("?->>'type' != 'Move'", a.data))
end
@valid_visibilities ~w[direct unlisted public private] @valid_visibilities ~w[direct unlisted public private]
defp exclude_visibility(query, %{exclude_visibilities: visibility}) defp exclude_visibility(query, %{exclude_visibilities: visibility})

View File

@ -72,7 +72,6 @@ defp cast_params(params) do
exclude_visibilities: {:array, :string}, exclude_visibilities: {:array, :string},
reblogs: :boolean, reblogs: :boolean,
with_muted: :boolean, with_muted: :boolean,
with_move: :boolean,
account_ap_id: :string account_ap_id: :string
} }

View File

@ -667,7 +667,13 @@ test "move activity generates a notification" do
Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user) Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
ObanHelpers.perform_all() ObanHelpers.perform_all()
assert [] = Notification.for_user(follower) assert [
%{
activity: %{
data: %{"type" => "Move", "actor" => ^old_ap_id, "target" => ^new_ap_id}
}
}
] = Notification.for_user(follower)
assert [ assert [
%{ %{
@ -675,17 +681,7 @@ test "move activity generates a notification" do
data: %{"type" => "Move", "actor" => ^old_ap_id, "target" => ^new_ap_id} data: %{"type" => "Move", "actor" => ^old_ap_id, "target" => ^new_ap_id}
} }
} }
] = Notification.for_user(follower, %{with_move: true}) ] = Notification.for_user(other_follower)
assert [] = Notification.for_user(other_follower)
assert [
%{
activity: %{
data: %{"type" => "Move", "actor" => ^old_ap_id, "target" => ^new_ap_id}
}
}
] = Notification.for_user(other_follower, %{with_move: true})
end end
end end

View File

@ -1955,11 +1955,9 @@ test "create" do
activity = %Activity{activity | object: nil} activity = %Activity{activity | object: nil}
assert [%Notification{activity: ^activity}] = assert [%Notification{activity: ^activity}] = Notification.for_user(follower)
Notification.for_user(follower, %{with_move: true})
assert [%Notification{activity: ^activity}] = assert [%Notification{activity: ^activity}] = Notification.for_user(follower_move_opted_out)
Notification.for_user(follower_move_opted_out, %{with_move: true})
end end
test "old user must be in the new user's `also_known_as` list" do test "old user must be in the new user's `also_known_as` list" do

View File

@ -407,7 +407,7 @@ test "see notifications after muting user with notifications and with_muted para
assert length(json_response(conn, 200)) == 1 assert length(json_response(conn, 200)) == 1
end end
test "see move notifications with `with_move` parameter" do test "see move notifications" do
old_user = insert(:user) old_user = insert(:user)
new_user = insert(:user, also_known_as: [old_user.ap_id]) new_user = insert(:user, also_known_as: [old_user.ap_id])
%{user: follower, conn: conn} = oauth_access(["read:notifications"]) %{user: follower, conn: conn} = oauth_access(["read:notifications"])
@ -416,11 +416,7 @@ test "see move notifications with `with_move` parameter" do
Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user) Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
Pleroma.Tests.ObanHelpers.perform_all() Pleroma.Tests.ObanHelpers.perform_all()
ret_conn = get(conn, "/api/v1/notifications") conn = get(conn, "/api/v1/notifications")
assert json_response(ret_conn, 200) == []
conn = get(conn, "/api/v1/notifications", %{"with_move" => "true"})
assert length(json_response(conn, 200)) == 1 assert length(json_response(conn, 200)) == 1
end end

View File

@ -120,7 +120,7 @@ test "Move notification" do
old_user = refresh_record(old_user) old_user = refresh_record(old_user)
new_user = refresh_record(new_user) new_user = refresh_record(new_user)
[notification] = Notification.for_user(follower, %{with_move: true}) [notification] = Notification.for_user(follower)
expected = %{ expected = %{
id: to_string(notification.id), id: to_string(notification.id),