MastoAPI: Use string ids everywhere.
This commit is contained in:
parent
f1d27a5fbb
commit
6e9c22c0af
|
@ -18,7 +18,7 @@ def render("account.json", %{user: user}) do
|
||||||
header = image_url(user.info["banner"]) || "https://placehold.it/700x335"
|
header = image_url(user.info["banner"]) || "https://placehold.it/700x335"
|
||||||
|
|
||||||
%{
|
%{
|
||||||
id: user.id,
|
id: to_string(user.id),
|
||||||
username: hd(String.split(user.nickname, "@")),
|
username: hd(String.split(user.nickname, "@")),
|
||||||
acct: user.nickname,
|
acct: user.nickname,
|
||||||
display_name: user.name,
|
display_name: user.name,
|
||||||
|
@ -43,7 +43,7 @@ def render("account.json", %{user: user}) do
|
||||||
|
|
||||||
def render("mention.json", %{user: user}) do
|
def render("mention.json", %{user: user}) do
|
||||||
%{
|
%{
|
||||||
id: user.id,
|
id: to_string(user.id),
|
||||||
acct: user.nickname,
|
acct: user.nickname,
|
||||||
username: hd(String.split(user.nickname, "@")),
|
username: hd(String.split(user.nickname, "@")),
|
||||||
url: user.ap_id
|
url: user.ap_id
|
||||||
|
@ -52,7 +52,7 @@ def render("mention.json", %{user: user}) do
|
||||||
|
|
||||||
def render("relationship.json", %{user: user, target: target}) do
|
def render("relationship.json", %{user: user, target: target}) do
|
||||||
%{
|
%{
|
||||||
id: target.id,
|
id: to_string(target.id),
|
||||||
following: User.following?(user, target),
|
following: User.following?(user, target),
|
||||||
followed_by: User.following?(target, user),
|
followed_by: User.following?(target, user),
|
||||||
blocking: User.blocks?(user, target),
|
blocking: User.blocks?(user, target),
|
||||||
|
|
|
@ -45,7 +45,8 @@ def render("status.json", %{activity: %{data: %{"type" => "Announce", "object" =
|
||||||
name: "Web",
|
name: "Web",
|
||||||
website: nil
|
website: nil
|
||||||
},
|
},
|
||||||
language: nil
|
language: nil,
|
||||||
|
emoji: []
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ test "Represent a user account" do
|
||||||
user = insert(:user, %{info: %{"note_count" => 5, "follower_count" => 3}, nickname: "shp@shitposter.club", inserted_at: ~N[2017-08-15 15:47:06.597036]})
|
user = insert(:user, %{info: %{"note_count" => 5, "follower_count" => 3}, nickname: "shp@shitposter.club", inserted_at: ~N[2017-08-15 15:47:06.597036]})
|
||||||
|
|
||||||
expected = %{
|
expected = %{
|
||||||
id: user.id,
|
id: to_string(user.id),
|
||||||
username: "shp",
|
username: "shp",
|
||||||
acct: user.nickname,
|
acct: user.nickname,
|
||||||
display_name: user.name,
|
display_name: user.name,
|
||||||
|
@ -37,7 +37,7 @@ test "Represent a smaller mention" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
expected = %{
|
expected = %{
|
||||||
id: user.id,
|
id: to_string(user.id),
|
||||||
acct: user.nickname,
|
acct: user.nickname,
|
||||||
username: user.nickname,
|
username: user.nickname,
|
||||||
url: user.ap_id
|
url: user.ap_id
|
||||||
|
@ -54,7 +54,7 @@ test "represent a relationship" do
|
||||||
{:ok, user} = User.block(user, other_user)
|
{:ok, user} = User.block(user, other_user)
|
||||||
|
|
||||||
expected = %{
|
expected = %{
|
||||||
id: other_user.id,
|
id: to_string(other_user.id),
|
||||||
following: true,
|
following: true,
|
||||||
followed_by: false,
|
followed_by: false,
|
||||||
blocking: true,
|
blocking: true,
|
||||||
|
|
|
@ -81,7 +81,7 @@ test "verify_credentials", %{conn: conn} do
|
||||||
|> get("/api/v1/accounts/verify_credentials")
|
|> get("/api/v1/accounts/verify_credentials")
|
||||||
|
|
||||||
assert %{"id" => id} = json_response(conn, 200)
|
assert %{"id" => id} = json_response(conn, 200)
|
||||||
assert id == user.id
|
assert id == to_string(user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "get a status", %{conn: conn} do
|
test "get a status", %{conn: conn} do
|
||||||
|
@ -194,7 +194,7 @@ test "returns the relationships for the current user", %{conn: conn} do
|
||||||
|
|
||||||
assert [relationship] = json_response(conn, 200)
|
assert [relationship] = json_response(conn, 200)
|
||||||
|
|
||||||
assert other_user.id == relationship["id"]
|
assert to_string(other_user.id) == relationship["id"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ test "account fetching", %{conn: conn} do
|
||||||
|> get("/api/v1/accounts/#{user.id}")
|
|> get("/api/v1/accounts/#{user.id}")
|
||||||
|
|
||||||
assert %{"id" => id} = json_response(conn, 200)
|
assert %{"id" => id} = json_response(conn, 200)
|
||||||
assert id == user.id
|
assert id == to_string(user.id)
|
||||||
|
|
||||||
conn = build_conn()
|
conn = build_conn()
|
||||||
|> get("/api/v1/accounts/-1")
|
|> get("/api/v1/accounts/-1")
|
||||||
|
@ -250,7 +250,7 @@ test "getting followers", %{conn: conn} do
|
||||||
|> get("/api/v1/accounts/#{other_user.id}/followers")
|
|> get("/api/v1/accounts/#{other_user.id}/followers")
|
||||||
|
|
||||||
assert [%{"id" => id}] = json_response(conn, 200)
|
assert [%{"id" => id}] = json_response(conn, 200)
|
||||||
assert id = user.id
|
assert id == to_string(user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "getting following", %{conn: conn} do
|
test "getting following", %{conn: conn} do
|
||||||
|
@ -262,7 +262,7 @@ test "getting following", %{conn: conn} do
|
||||||
|> get("/api/v1/accounts/#{user.id}/following")
|
|> get("/api/v1/accounts/#{user.id}/following")
|
||||||
|
|
||||||
assert [%{"id" => id}] = json_response(conn, 200)
|
assert [%{"id" => id}] = json_response(conn, 200)
|
||||||
assert id = other_user.id
|
assert id == to_string(other_user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "following / unfollowing a user", %{conn: conn} do
|
test "following / unfollowing a user", %{conn: conn} do
|
||||||
|
@ -288,7 +288,7 @@ test "following / unfollowing a user", %{conn: conn} do
|
||||||
|> post("/api/v1/follows", %{"uri" => other_user.nickname})
|
|> post("/api/v1/follows", %{"uri" => other_user.nickname})
|
||||||
|
|
||||||
assert %{"id" => id} = json_response(conn, 200)
|
assert %{"id" => id} = json_response(conn, 200)
|
||||||
assert id == other_user.id
|
assert id == to_string(other_user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "blocking / unblocking a user", %{conn: conn} do
|
test "blocking / unblocking a user", %{conn: conn} do
|
||||||
|
@ -319,7 +319,7 @@ test "getting a list of blocks", %{conn: conn} do
|
||||||
|> assign(:user, user)
|
|> assign(:user, user)
|
||||||
|> get("/api/v1/blocks")
|
|> get("/api/v1/blocks")
|
||||||
|
|
||||||
other_user_id = other_user.id
|
other_user_id = to_string(other_user.id)
|
||||||
assert [%{"id" => ^other_user_id}] = json_response(conn, 200)
|
assert [%{"id" => ^other_user_id}] = json_response(conn, 200)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ test "unimplemented mute endpoints" do
|
||||||
|> post("/api/v1/accounts/#{other_user.id}/#{endpoint}")
|
|> post("/api/v1/accounts/#{other_user.id}/#{endpoint}")
|
||||||
|
|
||||||
assert %{"id" => id} = json_response(conn, 200)
|
assert %{"id" => id} = json_response(conn, 200)
|
||||||
assert id == other_user.id
|
assert id == to_string(other_user.id)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ test "account search", %{conn: conn} do
|
||||||
|> get("/api/v1/accounts/search", %{"q" => "2hu"})
|
|> get("/api/v1/accounts/search", %{"q" => "2hu"})
|
||||||
|
|
||||||
assert [account] = json_response(conn, 200)
|
assert [account] = json_response(conn, 200)
|
||||||
assert account["id"] == user_three.id
|
assert account["id"] == to_string(user_three.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "search", %{conn: conn} do
|
test "search", %{conn: conn} do
|
||||||
|
@ -378,7 +378,7 @@ test "search", %{conn: conn} do
|
||||||
assert results = json_response(conn, 200)
|
assert results = json_response(conn, 200)
|
||||||
|
|
||||||
[account] = results["accounts"]
|
[account] = results["accounts"]
|
||||||
assert account["id"] == user_three.id
|
assert account["id"] == to_string(user_three.id)
|
||||||
|
|
||||||
assert results["hashtags"] == []
|
assert results["hashtags"] == []
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue