forked from AkkomaGang/akkoma
Merge branch 'bugfix/outbox-bomb-on-empty-activities' into 'develop'
Fix: Fixing an outbox related bug when local user activity is empty See merge request pleroma/pleroma!849
This commit is contained in:
commit
eeeb8124b9
2 changed files with 29 additions and 7 deletions
|
@ -188,14 +188,24 @@ def render("outbox.json", %{user: user, max_id: max_qid}) do
|
|||
end
|
||||
|
||||
activities = ActivityPub.fetch_user_activities(user, nil, params)
|
||||
min_id = Enum.at(Enum.reverse(activities), 0).id
|
||||
max_id = Enum.at(activities, 0).id
|
||||
|
||||
collection =
|
||||
Enum.map(activities, fn act ->
|
||||
{:ok, data} = Transmogrifier.prepare_outgoing(act.data)
|
||||
data
|
||||
end)
|
||||
{max_id, min_id, collection} =
|
||||
if length(activities) > 0 do
|
||||
{
|
||||
Enum.at(Enum.reverse(activities), 0).id,
|
||||
Enum.at(activities, 0).id,
|
||||
Enum.map(activities, fn act ->
|
||||
{:ok, data} = Transmogrifier.prepare_outgoing(act.data)
|
||||
data
|
||||
end)
|
||||
}
|
||||
else
|
||||
{
|
||||
0,
|
||||
0,
|
||||
[]
|
||||
}
|
||||
end
|
||||
|
||||
iri = "#{user.ap_id}/outbox"
|
||||
|
||||
|
|
|
@ -304,6 +304,18 @@ test "it clears `unreachable` federation status of the sender", %{conn: conn} do
|
|||
end
|
||||
|
||||
describe "/users/:nickname/outbox" do
|
||||
test "it will not bomb when there is no activity", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("accept", "application/activity+json")
|
||||
|> get("/users/#{user.nickname}/outbox")
|
||||
|
||||
result = json_response(conn, 200)
|
||||
assert user.ap_id <> "/outbox" == result["id"]
|
||||
end
|
||||
|
||||
test "it returns a note activity in a collection", %{conn: conn} do
|
||||
note_activity = insert(:note_activity)
|
||||
user = User.get_cached_by_ap_id(note_activity.data["actor"])
|
||||
|
|
Loading…
Reference in a new issue