rename post to status

This commit is contained in:
Egor Kislitsyn 2019-01-08 15:25:50 +07:00
parent f24087f96e
commit 63dbd87568
4 changed files with 22 additions and 22 deletions

View file

@ -202,14 +202,14 @@ defmodule Pleroma.User.Info do
def add_pinnned_activity(info, %Pleroma.Activity{id: id}) do def add_pinnned_activity(info, %Pleroma.Activity{id: id}) do
if id not in info.pinned_activities do if id not in info.pinned_activities do
max_pinned_posts = Pleroma.Config.get([:instance, :max_pinned_posts], 0) max_pinned_statuses = Pleroma.Config.get([:instance, :max_pinned_statuses], 0)
params = %{pinned_activities: info.pinned_activities ++ [id]} params = %{pinned_activities: info.pinned_activities ++ [id]}
info info
|> cast(params, [:pinned_activities]) |> cast(params, [:pinned_activities])
|> validate_length(:pinned_activities, |> validate_length(:pinned_activities,
max: max_pinned_posts, max: max_pinned_statuses,
message: "You have already pinned the maximum number of toots" message: "You have already pinned the maximum number of statuses"
) )
else else
change(info) change(info)

View file

@ -601,8 +601,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
assert object assert object
end end
test "returned pinned posts" do test "returned pinned statuses" do
Pleroma.Config.put([:instance, :max_pinned_posts], 3) Pleroma.Config.put([:instance, :max_pinned_statuses], 3)
user = insert(:user) user = insert(:user)
{:ok, activity_one} = CommonAPI.post(user, %{"status" => "HI!!!"}) {:ok, activity_one} = CommonAPI.post(user, %{"status" => "HI!!!"})

View file

@ -97,9 +97,9 @@ defmodule Pleroma.Web.CommonAPI.Test do
end end
end end
describe "pinned posts" do describe "pinned statuses" do
test "pin post" do test "pin status" do
Pleroma.Config.put([:instance, :max_pinned_posts], 1) Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
user = insert(:user) user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"}) {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
@ -107,8 +107,8 @@ defmodule Pleroma.Web.CommonAPI.Test do
assert {:ok, ^activity} = CommonAPI.pin(activity.id, user) assert {:ok, ^activity} = CommonAPI.pin(activity.id, user)
end end
test "max pinned posts" do test "max pinned statuses" do
Pleroma.Config.put([:instance, :max_pinned_posts], 1) Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
user = insert(:user) user = insert(:user)
{:ok, activity_one} = CommonAPI.post(user, %{"status" => "HI!!!"}) {:ok, activity_one} = CommonAPI.post(user, %{"status" => "HI!!!"})
@ -122,8 +122,8 @@ defmodule Pleroma.Web.CommonAPI.Test do
CommonAPI.pin(activity_two.id, user) CommonAPI.pin(activity_two.id, user)
end end
test "unpin post" do test "unpin status" do
Pleroma.Config.put([:instance, :max_pinned_posts], 1) Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
user = insert(:user) user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"}) {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})

View file

@ -1472,9 +1472,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert user.info.settings == %{"programming" => "socks"} assert user.info.settings == %{"programming" => "socks"}
end end
describe "pinned posts" do describe "pinned statuses" do
test "returns pinned posts", %{conn: conn} do test "returns pinned statuses", %{conn: conn} do
Pleroma.Config.put([:instance, :max_pinned_posts], 1) Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
user = insert(:user) user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"}) {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
@ -1492,8 +1492,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
assert [%{"id" => ^id_str}] = result assert [%{"id" => ^id_str}] = result
end end
test "pin post", %{conn: conn} do test "pin status", %{conn: conn} do
Pleroma.Config.put([:instance, :max_pinned_posts], 1) Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
user = insert(:user) user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"}) {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
@ -1514,8 +1514,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|> Jason.decode!() |> Jason.decode!()
end end
test "unpin post", %{conn: conn} do test "unpin status", %{conn: conn} do
Pleroma.Config.put([:instance, :max_pinned_posts], 1) Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
user = insert(:user) user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"}) {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!"})
@ -1539,8 +1539,8 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|> Jason.decode!() |> Jason.decode!()
end end
test "max pinned posts", %{conn: conn} do test "max pinned statuses", %{conn: conn} do
Pleroma.Config.put([:instance, :max_pinned_posts], 1) Pleroma.Config.put([:instance, :max_pinned_statuses], 1)
user = insert(:user) user = insert(:user)
@ -1558,7 +1558,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
user = User.get_by_ap_id(user.ap_id) user = User.get_by_ap_id(user.ap_id)
assert %{"error" => "You have already pinned the maximum number of toots"} = assert %{"error" => "You have already pinned the maximum number of statuses"} =
conn conn
|> assign(:user, user) |> assign(:user, user)
|> post("/api/v1/statuses/#{activity_two.id}/pin") |> post("/api/v1/statuses/#{activity_two.id}/pin")