mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-26 07:52:17 +00:00
Merge remote-tracking branch 'remotes/origin/develop' into feature/object-hashtags-rework
This commit is contained in:
commit
111bfdd3a0
1
.mailmap
1
.mailmap
|
@ -1,2 +1,3 @@
|
||||||
Ariadne Conill <ariadne@dereferenced.org> <nenolod@dereferenced.org>
|
Ariadne Conill <ariadne@dereferenced.org> <nenolod@dereferenced.org>
|
||||||
Ariadne Conill <ariadne@dereferenced.org> <nenolod@gmail.com>
|
Ariadne Conill <ariadne@dereferenced.org> <nenolod@gmail.com>
|
||||||
|
rinpatch <rin@patch.cx> <rinpatch@sdf.org>
|
||||||
|
|
|
@ -112,13 +112,6 @@ defmodule Pleroma.Notification do
|
||||||
|
|
||||||
Notification
|
Notification
|
||||||
|> where(user_id: ^user.id)
|
|> where(user_id: ^user.id)
|
||||||
|> where(
|
|
||||||
[n, a],
|
|
||||||
fragment(
|
|
||||||
"? not in (SELECT ap_id FROM users WHERE is_active = 'false')",
|
|
||||||
a.actor
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|> join(:inner, [n], activity in assoc(n, :activity))
|
|> join(:inner, [n], activity in assoc(n, :activity))
|
||||||
|> join(:left, [n, a], object in Object,
|
|> join(:left, [n, a], object in Object,
|
||||||
on:
|
on:
|
||||||
|
@ -129,7 +122,9 @@ defmodule Pleroma.Notification do
|
||||||
a.data
|
a.data
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|> join(:inner, [_n, a], u in User, on: u.ap_id == a.actor, as: :user_actor)
|
||||||
|> preload([n, a, o], activity: {a, object: o})
|
|> preload([n, a, o], activity: {a, object: o})
|
||||||
|
|> where([user_actor: user_actor], user_actor.is_active)
|
||||||
|> 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_filtered(user)
|
|> exclude_filtered(user)
|
||||||
|
@ -156,9 +151,10 @@ defmodule Pleroma.Notification do
|
||||||
query
|
query
|
||||||
|> where([n, a], a.actor not in ^notification_muted_ap_ids)
|
|> where([n, a], a.actor not in ^notification_muted_ap_ids)
|
||||||
|> join(:left, [n, a], tm in ThreadMute,
|
|> join(:left, [n, a], tm in ThreadMute,
|
||||||
on: tm.user_id == ^user.id and tm.context == fragment("?->>'context'", a.data)
|
on: tm.user_id == ^user.id and tm.context == fragment("?->>'context'", a.data),
|
||||||
|
as: :thread_mute
|
||||||
)
|
)
|
||||||
|> where([n, a, o, tm], is_nil(tm.user_id))
|
|> where([thread_mute: thread_mute], is_nil(thread_mute.user_id))
|
||||||
end
|
end
|
||||||
|
|
||||||
defp exclude_filtered(query, user) do
|
defp exclude_filtered(query, user) do
|
||||||
|
|
41
test/fixtures/users_mock/localhost.json
vendored
41
test/fixtures/users_mock/localhost.json
vendored
|
@ -1,41 +0,0 @@
|
||||||
{
|
|
||||||
"@context": [
|
|
||||||
"https://www.w3.org/ns/activitystreams",
|
|
||||||
"http://localhost:4001/schemas/litepub-0.1.jsonld",
|
|
||||||
{
|
|
||||||
"@language": "und"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"attachment": [],
|
|
||||||
"endpoints": {
|
|
||||||
"oauthAuthorizationEndpoint": "http://localhost:4001/oauth/authorize",
|
|
||||||
"oauthRegistrationEndpoint": "http://localhost:4001/api/v1/apps",
|
|
||||||
"oauthTokenEndpoint": "http://localhost:4001/oauth/token",
|
|
||||||
"sharedInbox": "http://localhost:4001/inbox"
|
|
||||||
},
|
|
||||||
"followers": "http://localhost:4001/users/{{nickname}}/followers",
|
|
||||||
"following": "http://localhost:4001/users/{{nickname}}/following",
|
|
||||||
"icon": {
|
|
||||||
"type": "Image",
|
|
||||||
"url": "http://localhost:4001/media/4e914f5b84e4a259a3f6c2d2edc9ab642f2ab05f3e3d9c52c81fc2d984b3d51e.jpg"
|
|
||||||
},
|
|
||||||
"id": "http://localhost:4001/users/{{nickname}}",
|
|
||||||
"image": {
|
|
||||||
"type": "Image",
|
|
||||||
"url": "http://localhost:4001/media/f739efddefeee49c6e67e947c4811fdc911785c16ae43da4c3684051fbf8da6a.jpg?name=f739efddefeee49c6e67e947c4811fdc911785c16ae43da4c3684051fbf8da6a.jpg"
|
|
||||||
},
|
|
||||||
"inbox": "http://localhost:4001/users/{{nickname}}/inbox",
|
|
||||||
"manuallyApprovesFollowers": false,
|
|
||||||
"name": "{{nickname}}",
|
|
||||||
"outbox": "http://localhost:4001/users/{{nickname}}/outbox",
|
|
||||||
"preferredUsername": "{{nickname}}",
|
|
||||||
"publicKey": {
|
|
||||||
"id": "http://localhost:4001/users/{{nickname}}#main-key",
|
|
||||||
"owner": "http://localhost:4001/users/{{nickname}}",
|
|
||||||
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5DLtwGXNZElJyxFGfcVc\nXANhaMadj/iYYQwZjOJTV9QsbtiNBeIK54PJrYuU0/0YIdrvS1iqheX5IwXRhcwa\nhm3ZyLz7XeN9st7FBni4BmZMBtMpxAuYuu5p/jbWy13qAiYOhPreCx0wrWgm/lBD\n9mkgaxIxPooBE0S4ZWEJIDIV1Vft3AWcRUyWW1vIBK0uZzs6GYshbQZB952S0yo4\nFzI1hABGHncH8UvuFauh4EZ8tY7/X5I0pGRnDOcRN1dAht5w5yTA+6r5kebiFQjP\nIzN/eCO/a9Flrj9YGW7HDNtjSOH0A31PLRGlJtJO3yK57dnf5ppyCZGfL4emShQo\ncQIDAQAB\n-----END PUBLIC KEY-----\n\n"
|
|
||||||
},
|
|
||||||
"summary": "your friendly neighborhood pleroma developer<br>I like cute things and distributed systems, and really hate delete and redrafts",
|
|
||||||
"tag": [],
|
|
||||||
"type": "Person",
|
|
||||||
"url": "http://localhost:4001/users/{{nickname}}"
|
|
||||||
}
|
|
|
@ -990,7 +990,6 @@ defmodule Pleroma.NotificationTest do
|
||||||
assert Enum.empty?(Notification.for_user(local_user))
|
assert Enum.empty?(Notification.for_user(local_user))
|
||||||
end
|
end
|
||||||
|
|
||||||
@tag capture_log: true
|
|
||||||
test "move activity generates a notification" do
|
test "move activity generates a notification" do
|
||||||
%{ap_id: old_ap_id} = old_user = insert(:user)
|
%{ap_id: old_ap_id} = old_user = insert(:user)
|
||||||
%{ap_id: new_ap_id} = new_user = insert(:user, also_known_as: [old_ap_id])
|
%{ap_id: new_ap_id} = new_user = insert(:user, also_known_as: [old_ap_id])
|
||||||
|
@ -1000,18 +999,6 @@ defmodule Pleroma.NotificationTest do
|
||||||
User.follow(follower, old_user)
|
User.follow(follower, old_user)
|
||||||
User.follow(other_follower, old_user)
|
User.follow(other_follower, old_user)
|
||||||
|
|
||||||
old_user_url = old_user.ap_id
|
|
||||||
|
|
||||||
body =
|
|
||||||
File.read!("test/fixtures/users_mock/localhost.json")
|
|
||||||
|> String.replace("{{nickname}}", old_user.nickname)
|
|
||||||
|> Jason.encode!()
|
|
||||||
|
|
||||||
Tesla.Mock.mock(fn
|
|
||||||
%{method: :get, url: ^old_user_url} ->
|
|
||||||
%Tesla.Env{status: 200, body: body}
|
|
||||||
end)
|
|
||||||
|
|
||||||
Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
|
Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
|
||||||
ObanHelpers.perform_all()
|
ObanHelpers.perform_all()
|
||||||
|
|
||||||
|
|
|
@ -1101,6 +1101,31 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
||||||
|
|
||||||
assert response(conn, 200) =~ announce_activity.data["object"]
|
assert response(conn, 200) =~ announce_activity.data["object"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "It returns poll Answers when authenticated", %{conn: conn} do
|
||||||
|
poller = insert(:user)
|
||||||
|
voter = insert(:user)
|
||||||
|
|
||||||
|
{:ok, activity} =
|
||||||
|
CommonAPI.post(poller, %{
|
||||||
|
status: "suya...",
|
||||||
|
poll: %{options: ["suya", "suya.", "suya.."], expires_in: 10}
|
||||||
|
})
|
||||||
|
|
||||||
|
assert question = Object.normalize(activity, fetch: false)
|
||||||
|
|
||||||
|
{:ok, [activity], _object} = CommonAPI.vote(voter, question, [1])
|
||||||
|
|
||||||
|
assert outbox_get =
|
||||||
|
conn
|
||||||
|
|> assign(:user, voter)
|
||||||
|
|> put_req_header("accept", "application/activity+json")
|
||||||
|
|> get(voter.ap_id <> "/outbox?page=true")
|
||||||
|
|> json_response(200)
|
||||||
|
|
||||||
|
assert [answer_outbox] = outbox_get["orderedItems"]
|
||||||
|
assert answer_outbox["id"] == activity.data["id"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "POST /users/:nickname/outbox (C2S)" do
|
describe "POST /users/:nickname/outbox (C2S)" do
|
||||||
|
|
|
@ -555,24 +555,11 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
||||||
assert length(json_response_and_validate_schema(conn, 200)) == 1
|
assert length(json_response_and_validate_schema(conn, 200)) == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@tag capture_log: true
|
|
||||||
test "see move notifications" 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"])
|
||||||
|
|
||||||
old_user_url = old_user.ap_id
|
|
||||||
|
|
||||||
body =
|
|
||||||
File.read!("test/fixtures/users_mock/localhost.json")
|
|
||||||
|> String.replace("{{nickname}}", old_user.nickname)
|
|
||||||
|> Jason.encode!()
|
|
||||||
|
|
||||||
Tesla.Mock.mock(fn
|
|
||||||
%{method: :get, url: ^old_user_url} ->
|
|
||||||
%Tesla.Env{status: 200, body: body}
|
|
||||||
end)
|
|
||||||
|
|
||||||
User.follow(follower, old_user)
|
User.follow(follower, old_user)
|
||||||
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()
|
||||||
|
|
|
@ -144,24 +144,11 @@ defmodule Pleroma.Web.MastodonAPI.NotificationViewTest do
|
||||||
refute Repo.one(Notification)
|
refute Repo.one(Notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
@tag capture_log: true
|
|
||||||
test "Move notification" do
|
test "Move notification" 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])
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
|
|
||||||
old_user_url = old_user.ap_id
|
|
||||||
|
|
||||||
body =
|
|
||||||
File.read!("test/fixtures/users_mock/localhost.json")
|
|
||||||
|> String.replace("{{nickname}}", old_user.nickname)
|
|
||||||
|> Jason.encode!()
|
|
||||||
|
|
||||||
Tesla.Mock.mock(fn
|
|
||||||
%{method: :get, url: ^old_user_url} ->
|
|
||||||
%Tesla.Env{status: 200, body: body}
|
|
||||||
end)
|
|
||||||
|
|
||||||
User.follow(follower, old_user)
|
User.follow(follower, old_user)
|
||||||
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()
|
||||||
|
|
|
@ -383,19 +383,8 @@ defmodule Pleroma.Web.StreamerTest do
|
||||||
user: user,
|
user: user,
|
||||||
token: oauth_token
|
token: oauth_token
|
||||||
} do
|
} do
|
||||||
user_url = user.ap_id
|
|
||||||
user2 = insert(:user)
|
user2 = insert(:user)
|
||||||
|
|
||||||
body =
|
|
||||||
File.read!("test/fixtures/users_mock/localhost.json")
|
|
||||||
|> String.replace("{{nickname}}", user.nickname)
|
|
||||||
|> Jason.encode!()
|
|
||||||
|
|
||||||
Tesla.Mock.mock_global(fn
|
|
||||||
%{method: :get, url: ^user_url} ->
|
|
||||||
%Tesla.Env{status: 200, body: body}
|
|
||||||
end)
|
|
||||||
|
|
||||||
Streamer.get_topic_and_add_socket("user:notification", user, oauth_token)
|
Streamer.get_topic_and_add_socket("user:notification", user, oauth_token)
|
||||||
{:ok, _follower, _followed, follow_activity} = CommonAPI.follow(user2, user)
|
{:ok, _follower, _followed, follow_activity} = CommonAPI.follow(user2, user)
|
||||||
|
|
||||||
|
@ -409,20 +398,9 @@ defmodule Pleroma.Web.StreamerTest do
|
||||||
token: oauth_token
|
token: oauth_token
|
||||||
} do
|
} do
|
||||||
user_id = user.id
|
user_id = user.id
|
||||||
user_url = user.ap_id
|
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
other_user_id = other_user.id
|
other_user_id = other_user.id
|
||||||
|
|
||||||
body =
|
|
||||||
File.read!("test/fixtures/users_mock/localhost.json")
|
|
||||||
|> String.replace("{{nickname}}", user.nickname)
|
|
||||||
|> Jason.encode!()
|
|
||||||
|
|
||||||
Tesla.Mock.mock_global(fn
|
|
||||||
%{method: :get, url: ^user_url} ->
|
|
||||||
%Tesla.Env{status: 200, body: body}
|
|
||||||
end)
|
|
||||||
|
|
||||||
Streamer.get_topic_and_add_socket("user", user, oauth_token)
|
Streamer.get_topic_and_add_socket("user", user, oauth_token)
|
||||||
{:ok, _follower, _followed, _follow_activity} = CommonAPI.follow(user, other_user)
|
{:ok, _follower, _followed, _follow_activity} = CommonAPI.follow(user, other_user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue