summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--CHANGELOG.md2
-rw-r--r--config/test.exs2
-rw-r--r--docs/clients.md2
-rw-r--r--docs/development/API/differences_in_mastoapi_responses.md8
-rw-r--r--docs/installation/otp_en.md2
-rw-r--r--lib/mix/tasks/pleroma/ecto/rollback.ex5
-rw-r--r--lib/pleroma/application.ex4
-rw-r--r--lib/pleroma/constants.ex3
-rw-r--r--lib/pleroma/stats.ex6
-rw-r--r--lib/pleroma/user.ex4
-rw-r--r--lib/pleroma/web.ex15
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex34
-rw-r--r--lib/pleroma/web/api_spec/schemas/scheduled_status.ex6
-rw-r--r--lib/pleroma/web/api_spec/schemas/status.ex5
-rw-r--r--lib/pleroma/web/common_api/activity_draft.ex1
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/status_controller.ex20
-rw-r--r--lib/pleroma/web/mastodon_api/views/scheduled_activity_view.ex3
-rw-r--r--lib/pleroma/web/mastodon_api/views/status_view.ex14
-rw-r--r--lib/pleroma/web/plugs/frontend_static.ex9
-rw-r--r--priv/repo/migrations/20210218223811_add_disclose_client_to_users.exs9
-rw-r--r--test/fixtures/peertube/actor-person.json121
-rw-r--r--test/fixtures/peertube/video-object-mpegURL-only.json413
-rw-r--r--test/mix/tasks/pleroma/ecto/rollback_test.exs2
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier/video_handling_test.exs30
-rw-r--r--test/pleroma/web/activity_pub/transmogrifier_test.exs16
-rw-r--r--test/pleroma/web/mastodon_api/controllers/status_controller_test.exs69
-rw-r--r--test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs3
-rw-r--r--test/pleroma/web/mastodon_api/views/status_view_test.exs5
-rw-r--r--test/pleroma/web/plugs/frontend_static_plug_test.exs31
-rw-r--r--test/support/http_request_mock.ex9
31 files changed, 812 insertions, 45 deletions
diff --git a/.gitignore b/.gitignore
index 4dea75e93..f30f4cf5f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,3 +53,7 @@ pleroma.iml
# asdf
.tool-versions
+
+# Editor temp files
+/*~
+/*# \ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9a972770f..43927fe6e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -60,6 +60,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Ability to define custom HTTP headers per each frontend
- MRF (`NoEmptyPolicy`): New MRF Policy which will deny empty statuses or statuses of only mentions from being created by local users
- New users will receive a simple email confirming their registration if no other emails will be dispatched. (e.g., Welcome, Confirmation, or Approval Required)
+- The `application` metadata returned with statuses is no longer hardcoded. Apps that want to display these details will now have valid data for new posts after this change.
<details>
<summary>API Changes</summary>
@@ -75,6 +76,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Mastodon API: Home, public, hashtag & list timelines accept `only_media`, `remote` & `local` parameters for filtration.
- Mastodon API: `/api/v1/accounts/:id` & `/api/v1/mutes` endpoints accept `with_relationships` parameter and return filled `pleroma.relationship` field.
- Mastodon API: Endpoint to remove a conversation (`DELETE /api/v1/conversations/:id`).
+- Mastodon API: `expires_in` in the scheduled post `params` field on `/api/v1/statuses` and `/api/v1/scheduled_statuses/:id` endpoints.
</details>
### Fixed
diff --git a/config/test.exs b/config/test.exs
index 690c98e40..87396a88d 100644
--- a/config/test.exs
+++ b/config/test.exs
@@ -38,7 +38,7 @@ config :pleroma, :instance,
external_user_synchronization: false,
static_dir: "test/instance_static/"
-config :pleroma, :activitypub, sign_object_fetches: false
+config :pleroma, :activitypub, sign_object_fetches: false, follow_handshake_timeout: 0
# Configure your database
config :pleroma, Pleroma.Repo,
diff --git a/docs/clients.md b/docs/clients.md
index 3d81763e1..5650ea236 100644
--- a/docs/clients.md
+++ b/docs/clients.md
@@ -17,7 +17,7 @@ Feel free to contact us to be added to this list!
- Features: MastoAPI
### Whalebird
-- Homepage: <https://whalebird.org/>
+- Homepage: <https://whalebird.social/>
- Source Code: <https://github.com/h3poteto/whalebird-desktop>
- Contact: [@h3poteto@pleroma.io](https://pleroma.io/users/h3poteto)
- Platforms: Windows, Mac, Linux
diff --git a/docs/development/API/differences_in_mastoapi_responses.md b/docs/development/API/differences_in_mastoapi_responses.md
index 493cb4c16..a14fcb416 100644
--- a/docs/development/API/differences_in_mastoapi_responses.md
+++ b/docs/development/API/differences_in_mastoapi_responses.md
@@ -39,6 +39,12 @@ Has these additional fields under the `pleroma` object:
- `emoji_reactions`: A list with emoji / reaction maps. The format is `{name: "☕", count: 1, me: true}`. Contains no information about the reacting users, for that use the `/statuses/:id/reactions` endpoint.
- `parent_visible`: If the parent of this post is visible to the user or not.
+## Scheduled statuses
+
+Has these additional fields in `params`:
+
+- `expires_in`: the number of seconds the posted activity should expire in.
+
## Media Attachments
Has these additional fields under the `pleroma` object:
@@ -92,7 +98,7 @@ Has these additional fields under the `pleroma` object:
- `hide_followers_count`: boolean, true when the user has follower stat hiding enabled
- `hide_follows_count`: boolean, true when the user has follow stat hiding enabled
- `settings_store`: A generic map of settings for frontends. Opaque to the backend. Only returned in `/api/v1/accounts/verify_credentials` and `/api/v1/accounts/update_credentials`
-- `chat_token`: The token needed for Pleroma chat. Only returned in `/api/v1/accounts/verify_credentials`
+- `chat_token`: The token needed for Pleroma shoutbox. Only returned in `/api/v1/accounts/verify_credentials`
- `deactivated`: boolean, true when the user is deactivated
- `allow_following_move`: boolean, true when the user allows automatically follow moved following accounts
- `unread_conversation_count`: The count of unread conversations. Only returned to the account owner.
diff --git a/docs/installation/otp_en.md b/docs/installation/otp_en.md
index f36b33c32..42e264e65 100644
--- a/docs/installation/otp_en.md
+++ b/docs/installation/otp_en.md
@@ -150,7 +150,7 @@ su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
# su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
# Start the instance to verify that everything is working as expected
-su pleroma -s $SHELL -lc "export $(cat /opt/pleroma/config/pleroma.env); ./bin/pleroma daemon"
+su pleroma -s $SHELL -lc "./bin/pleroma daemon"
# Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly
sleep 20 && curl http://localhost:4000/api/v1/instance
diff --git a/lib/mix/tasks/pleroma/ecto/rollback.ex b/lib/mix/tasks/pleroma/ecto/rollback.ex
index 2b1d48048..025ebaf19 100644
--- a/lib/mix/tasks/pleroma/ecto/rollback.ex
+++ b/lib/mix/tasks/pleroma/ecto/rollback.ex
@@ -20,7 +20,8 @@ defmodule Mix.Tasks.Pleroma.Ecto.Rollback do
start: :boolean,
quiet: :boolean,
log_sql: :boolean,
- migrations_path: :string
+ migrations_path: :string,
+ env: :string
]
@moduledoc """
@@ -59,7 +60,7 @@ defmodule Mix.Tasks.Pleroma.Ecto.Rollback do
level = Logger.level()
Logger.configure(level: :info)
- if Pleroma.Config.get(:env) == :test do
+ if opts[:env] == "test" do
Logger.info("Rollback succesfully")
else
{:ok, _, _} =
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index 375507de1..c853a2bb4 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -97,13 +97,13 @@ defmodule Pleroma.Application do
Pleroma.Stats,
Pleroma.JobQueueMonitor,
{Majic.Pool, [name: Pleroma.MajicPool, pool_size: Config.get([:majic_pool, :size], 2)]},
- {Oban, Config.get(Oban)}
+ {Oban, Config.get(Oban)},
+ Pleroma.Web.Endpoint
] ++
task_children(@mix_env) ++
dont_run_in_test(@mix_env) ++
chat_child(chat_enabled?()) ++
[
- Pleroma.Web.Endpoint,
Pleroma.Gopher.Server
]
diff --git a/lib/pleroma/constants.ex b/lib/pleroma/constants.ex
index a40741ba6..9ee836d5d 100644
--- a/lib/pleroma/constants.ex
+++ b/lib/pleroma/constants.ex
@@ -18,7 +18,8 @@ defmodule Pleroma.Constants do
"emoji",
"context_id",
"deleted_activity_id",
- "pleroma_internal"
+ "pleroma_internal",
+ "application"
]
)
diff --git a/lib/pleroma/stats.ex b/lib/pleroma/stats.ex
index b096a9b1e..3e3f24c2c 100644
--- a/lib/pleroma/stats.ex
+++ b/lib/pleroma/stats.ex
@@ -23,7 +23,11 @@ defmodule Pleroma.Stats do
@impl true
def init(_args) do
- {:ok, nil, {:continue, :calculate_stats}}
+ if Pleroma.Config.get(:env) != :test do
+ {:ok, nil, {:continue, :calculate_stats}}
+ else
+ {:ok, calculate_stat_data()}
+ end
end
@doc "Performs update stats"
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index 51f5bc8ea..9942617d8 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -147,6 +147,7 @@ defmodule Pleroma.User do
field(:shared_inbox, :string)
field(:accepts_chat_messages, :boolean, default: nil)
field(:last_active_at, :naive_datetime)
+ field(:disclose_client, :boolean, default: true)
embeds_one(
:notification_settings,
@@ -513,7 +514,8 @@ defmodule Pleroma.User do
:pleroma_settings_store,
:is_discoverable,
:actor_type,
- :accepts_chat_messages
+ :accepts_chat_messages,
+ :disclose_client
]
)
|> unique_constraint(:nickname)
diff --git a/lib/pleroma/web.ex b/lib/pleroma/web.ex
index c3aa39492..8630f244b 100644
--- a/lib/pleroma/web.ex
+++ b/lib/pleroma/web.ex
@@ -63,7 +63,8 @@ defmodule Pleroma.Web do
# Executed just before actual controller action, invokes before-action hooks (callbacks)
defp action(conn, params) do
- with %{halted: false} = conn <- maybe_drop_authentication_if_oauth_check_ignored(conn),
+ with %{halted: false} = conn <-
+ maybe_drop_authentication_if_oauth_check_ignored(conn),
%{halted: false} = conn <- maybe_perform_public_or_authenticated_check(conn),
%{halted: false} = conn <- maybe_perform_authenticated_check(conn),
%{halted: false} = conn <- maybe_halt_on_missing_oauth_scopes_check(conn) do
@@ -232,4 +233,16 @@ defmodule Pleroma.Web do
def base_url do
Pleroma.Web.Endpoint.url()
end
+
+ # TODO: Change to Phoenix.Router.routes/1 for Phoenix 1.6.0+
+ def get_api_routes do
+ Pleroma.Web.Router.__routes__()
+ |> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
+ |> Enum.map(fn r ->
+ r.path
+ |> String.split("/", trim: true)
+ |> List.first()
+ end)
+ |> Enum.uniq()
+ end
end
diff --git a/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex b/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex
index b3e738d8d..4a96fef52 100644
--- a/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex
+++ b/lib/pleroma/web/activity_pub/object_validators/audio_video_validator.ex
@@ -70,19 +70,33 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AudioVideoValidator do
|> changeset(data)
end
- defp fix_url(%{"url" => url} = data) when is_list(url) do
- attachment =
- Enum.find(url, fn x ->
- mime_type = x["mimeType"] || x["mediaType"] || ""
-
- is_map(x) and String.starts_with?(mime_type, ["video/", "audio/"])
+ defp find_attachment(url) do
+ mpeg_url =
+ Enum.find(url, fn
+ %{"mediaType" => mime_type, "tag" => tags} when is_list(tags) ->
+ mime_type == "application/x-mpegURL"
+
+ _ ->
+ false
end)
- link_element =
- Enum.find(url, fn x ->
- mime_type = x["mimeType"] || x["mediaType"] || ""
+ url
+ |> Enum.concat(mpeg_url["tag"] || [])
+ |> Enum.find(fn
+ %{"mediaType" => mime_type} -> String.starts_with?(mime_type, ["video/", "audio/"])
+ %{"mimeType" => mime_type} -> String.starts_with?(mime_type, ["video/", "audio/"])
+ _ -> false
+ end)
+ end
- is_map(x) and mime_type == "text/html"
+ defp fix_url(%{"url" => url} = data) when is_list(url) do
+ attachment = find_attachment(url)
+
+ link_element =
+ Enum.find(url, fn
+ %{"mediaType" => "text/html"} -> true
+ %{"mimeType" => "text/html"} -> true
+ _ -> false
end)
data
diff --git a/lib/pleroma/web/api_spec/schemas/scheduled_status.ex b/lib/pleroma/web/api_spec/schemas/scheduled_status.ex
index cc051046a..607586e32 100644
--- a/lib/pleroma/web/api_spec/schemas/scheduled_status.ex
+++ b/lib/pleroma/web/api_spec/schemas/scheduled_status.ex
@@ -30,7 +30,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.ScheduledStatus do
visibility: %Schema{allOf: [VisibilityScope], nullable: true},
scheduled_at: %Schema{type: :string, format: :"date-time", nullable: true},
poll: StatusOperation.poll_params(),
- in_reply_to_id: %Schema{type: :string, nullable: true}
+ in_reply_to_id: %Schema{type: :string, nullable: true},
+ expires_in: %Schema{type: :integer, nullable: true}
}
}
},
@@ -46,7 +47,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.ScheduledStatus do
scheduled_at: nil,
poll: nil,
idempotency: nil,
- in_reply_to_id: nil
+ in_reply_to_id: nil,
+ expires_in: nil
},
media_attachments: [Attachment.schema().example]
}
diff --git a/lib/pleroma/web/api_spec/schemas/status.ex b/lib/pleroma/web/api_spec/schemas/status.ex
index 61ebd8089..42fa98718 100644
--- a/lib/pleroma/web/api_spec/schemas/status.ex
+++ b/lib/pleroma/web/api_spec/schemas/status.ex
@@ -23,9 +23,10 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
application: %Schema{
description: "The application used to post this status",
type: :object,
+ nullable: true,
properties: %{
name: %Schema{type: :string},
- website: %Schema{type: :string, nullable: true, format: :uri}
+ website: %Schema{type: :string, format: :uri}
}
},
bookmarked: %Schema{type: :boolean, description: "Have you bookmarked this status?"},
@@ -291,7 +292,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
"url" => "http://localhost:4001/users/nick6",
"username" => "nick6"
},
- "application" => %{"name" => "Web", "website" => nil},
+ "application" => nil,
"bookmarked" => false,
"card" => nil,
"content" => "foobar",
diff --git a/lib/pleroma/web/common_api/activity_draft.ex b/lib/pleroma/web/common_api/activity_draft.ex
index fb059c27c..d7dcdad90 100644
--- a/lib/pleroma/web/common_api/activity_draft.ex
+++ b/lib/pleroma/web/common_api/activity_draft.ex
@@ -190,6 +190,7 @@ defmodule Pleroma.Web.CommonAPI.ActivityDraft do
Utils.make_note_data(draft)
|> Map.put("emoji", emoji)
|> Map.put("source", draft.status)
+ |> Map.put("application", draft.params[:application])
%__MODULE__{draft | object: object}
end
diff --git a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex
index 4cf2ee35c..b8a7b2a0a 100644
--- a/lib/pleroma/web/mastodon_api/controllers/status_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/status_controller.ex
@@ -21,6 +21,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.MastodonAPI.AccountView
alias Pleroma.Web.MastodonAPI.ScheduledActivityView
+ alias Pleroma.Web.OAuth.Token
alias Pleroma.Web.Plugs.OAuthScopesPlug
alias Pleroma.Web.Plugs.RateLimiter
@@ -138,7 +139,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
_
)
when not is_nil(scheduled_at) do
- params = Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id])
+ params =
+ Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id])
+ |> put_application(conn)
attrs = %{
params: Map.new(params, fn {key, value} -> {to_string(key), value} end),
@@ -162,7 +165,9 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
# Creates a regular status
def create(%{assigns: %{user: user}, body_params: %{status: _} = params} = conn, _) do
- params = Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id])
+ params =
+ Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id])
+ |> put_application(conn)
with {:ok, activity} <- CommonAPI.post(user, params) do
try_render(conn, "show.json",
@@ -414,4 +419,15 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
as: :activity
)
end
+
+ defp put_application(params, %{assigns: %{token: %Token{user: %User{} = user} = token}} = _conn) do
+ if user.disclose_client do
+ %{client_name: client_name, website: website} = Repo.preload(token, :app).app
+ Map.put(params, :application, %{type: "Application", name: client_name, url: website})
+ else
+ Map.put(params, :application, nil)
+ end
+ end
+
+ defp put_application(params, _), do: Map.put(params, :application, nil)
end
diff --git a/lib/pleroma/web/mastodon_api/views/scheduled_activity_view.ex b/lib/pleroma/web/mastodon_api/views/scheduled_activity_view.ex
index 13774d237..453221f41 100644
--- a/lib/pleroma/web/mastodon_api/views/scheduled_activity_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/scheduled_activity_view.ex
@@ -37,7 +37,8 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityView do
visibility: params["visibility"],
scheduled_at: params["scheduled_at"],
poll: params["poll"],
- in_reply_to_id: params["in_reply_to_id"]
+ in_reply_to_id: params["in_reply_to_id"],
+ expires_in: params["expires_in"]
}
|> Pleroma.Maps.put_if_present(:media_ids, params["media_ids"])
end
diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex
index 2cd6732fe..792197a4a 100644
--- a/lib/pleroma/web/mastodon_api/views/status_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/status_view.ex
@@ -180,10 +180,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
media_attachments: reblogged[:media_attachments] || [],
mentions: mentions,
tags: reblogged[:tags] || [],
- application: %{
- name: "Web",
- website: nil
- },
+ application: build_application(activity_object.data["application"]),
language: nil,
emojis: [],
pleroma: %{
@@ -348,10 +345,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
poll: render(PollView, "show.json", object: object, for: opts[:for]),
mentions: mentions,
tags: build_tags(tags),
- application: %{
- name: "Web",
- website: nil
- },
+ application: build_application(object.data["application"]),
language: nil,
emojis: build_emojis(object.data["emoji"]),
pleroma: %{
@@ -540,4 +534,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
me: !!(current_user && current_user.ap_id in users)
}
end
+
+ @spec build_application(map() | nil) :: map() | nil
+ defp build_application(%{type: _type, name: name, url: url}), do: %{name: name, website: url}
+ defp build_application(_), do: nil
end
diff --git a/lib/pleroma/web/plugs/frontend_static.ex b/lib/pleroma/web/plugs/frontend_static.ex
index eecf16264..eb385e94d 100644
--- a/lib/pleroma/web/plugs/frontend_static.ex
+++ b/lib/pleroma/web/plugs/frontend_static.ex
@@ -10,6 +10,8 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
"""
@behaviour Plug
+ @api_routes Pleroma.Web.get_api_routes()
+
def file_path(path, frontend_type \\ :primary) do
if configuration = Pleroma.Config.get([:frontends, frontend_type]) do
instance_static_path = Pleroma.Config.get([:instance, :static_dir], "instance/static")
@@ -34,7 +36,8 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
end
def call(conn, opts) do
- with false <- invalid_path?(conn.path_info),
+ with false <- api_route?(conn.path_info),
+ false <- invalid_path?(conn.path_info),
frontend_type <- Map.get(opts, :frontend_type, :primary),
path when not is_nil(path) <- file_path("", frontend_type) do
call_static(conn, opts, path)
@@ -52,6 +55,10 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
defp invalid_path?([h | t], match), do: String.contains?(h, match) or invalid_path?(t)
defp invalid_path?([], _match), do: false
+ defp api_route?([h | _]) when h in @api_routes, do: true
+ defp api_route?([_ | t]), do: api_route?(t)
+ defp api_route?([]), do: false
+
defp call_static(conn, opts, from) do
opts = Map.put(opts, :from, from)
Plug.Static.call(conn, opts)
diff --git a/priv/repo/migrations/20210218223811_add_disclose_client_to_users.exs b/priv/repo/migrations/20210218223811_add_disclose_client_to_users.exs
new file mode 100644
index 000000000..37c5776ff
--- /dev/null
+++ b/priv/repo/migrations/20210218223811_add_disclose_client_to_users.exs
@@ -0,0 +1,9 @@
+defmodule Pleroma.Repo.Migrations.AddDiscloseClientToUsers do
+ use Ecto.Migration
+
+ def change do
+ alter table(:users) do
+ add(:disclose_client, :boolean, default: true)
+ end
+ end
+end
diff --git a/test/fixtures/peertube/actor-person.json b/test/fixtures/peertube/actor-person.json
new file mode 100644
index 000000000..8c387d455
--- /dev/null
+++ b/test/fixtures/peertube/actor-person.json
@@ -0,0 +1,121 @@
+{
+ "type": "Person",
+ "id": "https://peertube.stream/accounts/createurs",
+ "following": "https://peertube.stream/accounts/createurs/following",
+ "followers": "https://peertube.stream/accounts/createurs/followers",
+ "playlists": "https://peertube.stream/accounts/createurs/playlists",
+ "inbox": "https://peertube.stream/accounts/createurs/inbox",
+ "outbox": "https://peertube.stream/accounts/createurs/outbox",
+ "preferredUsername": "createurs",
+ "url": "https://peertube.stream/accounts/createurs",
+ "name": "Créateurs",
+ "endpoints": {
+ "sharedInbox": "https://peertube.stream/inbox"
+ },
+ "publicKey": {
+ "id": "https://peertube.stream/accounts/createurs#main-key",
+ "owner": "https://peertube.stream/accounts/createurs",
+ "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxqkQhbRYbA81+WTYjorR\n2lEMad3kYCnzDjGTLr4I92eanzFHxyELGnjzP6TpEvjOiB9NrCRrqU/iFPLdgrq2\nwIFcXPWdCq6Gcg7QLlaeMM0JoJmr0KTEhzg0XKCo96UsyTzaF4DISxqi8RyoyWeU\nEkgiOzlkdYTlouq3MlQH+p1PBAsNUQfIEUsU+l6k1vzbm8JRwlT+D1bNde4I/Lqs\n4uB5ru3zzInwZ2hz9+heiriNoGEBv74rZHYn966tZVX8iMGx2+m6okozEdEQbqCl\n0ekqDcd8P6CoFqqeeu8coh82OUtuFI/XsbetdWA55YQmSHyMiTsIwVbeoogIETbI\n4QIDAQAB\n-----END PUBLIC KEY-----"
+ },
+ "icon": {
+ "type": "Image",
+ "mediaType": "image/png",
+ "url": "https://peertube.stream/lazy-static/avatars/c27b672d-ad8f-498a-adbe-553af8da56f9.png"
+ },
+ "@context": [
+ "https://www.w3.org/ns/activitystreams",
+ "https://w3id.org/security/v1",
+ {
+ "RsaSignature2017": "https://w3id.org/security#RsaSignature2017"
+ },
+ {
+ "pt": "https://joinpeertube.org/ns#",
+ "sc": "http://schema.org#",
+ "Hashtag": "as:Hashtag",
+ "uuid": "sc:identifier",
+ "category": "sc:category",
+ "licence": "sc:license",
+ "subtitleLanguage": "sc:subtitleLanguage",
+ "sensitive": "as:sensitive",
+ "language": "sc:inLanguage",
+ "isLiveBroadcast": "sc:isLiveBroadcast",
+ "liveSaveReplay": {
+ "@type": "sc:Boolean",
+ "@id": "pt:liveSaveReplay"
+ },
+ "permanentLive": {
+ "@type": "sc:Boolean",
+ "@id": "pt:permanentLive"
+ },
+ "Infohash": "pt:Infohash",
+ "Playlist": "pt:Playlist",
+ "PlaylistElement": "pt:PlaylistElement",
+ "originallyPublishedAt": "sc:datePublished",
+ "views": {
+ "@type": "sc:Number",
+ "@id": "pt:views"
+ },
+ "state": {
+ "@type": "sc:Number",
+ "@id": "pt:state"
+ },
+ "size": {
+ "@type": "sc:Number",
+ "@id": "pt:size"
+ },
+ "fps": {
+ "@type": "sc:Number",
+ "@id": "pt:fps"
+ },
+ "startTimestamp": {
+ "@type": "sc:Number",
+ "@id": "pt:startTimestamp"
+ },
+ "stopTimestamp": {
+ "@type": "sc:Number",
+ "@id": "pt:stopTimestamp"
+ },
+ "position": {
+ "@type": "sc:Number",
+ "@id": "pt:position"
+ },
+ "commentsEnabled": {
+ "@type": "sc:Boolean",
+ "@id": "pt:commentsEnabled"
+ },
+ "downloadEnabled": {
+ "@type": "sc:Boolean",
+ "@id": "pt:downloadEnabled"
+ },
+ "waitTranscoding": {
+ "@type": "sc:Boolean",
+ "@id": "pt:waitTranscoding"
+ },
+ "support": {
+ "@type": "sc:Text",
+ "@id": "pt:support"
+ },
+ "likes": {
+ "@id": "as:likes",
+ "@type": "@id"
+ },
+ "dislikes": {
+ "@id": "as:dislikes",
+ "@type": "@id"
+ },
+ "playlists": {
+ "@id": "pt:playlists",
+ "@type": "@id"
+ },
+ "shares": {
+ "@id": "as:shares",
+ "@type": "@id"
+ },
+ "comments": {
+ "@id": "as:comments",
+ "@type": "@id"
+ }
+ }
+ ],
+ "summary": null
+}
diff --git a/test/fixtures/peertube/video-object-mpegURL-only.json b/test/fixtures/peertube/video-object-mpegURL-only.json
new file mode 100644
index 000000000..7f26e89bf
--- /dev/null
+++ b/test/fixtures/peertube/video-object-mpegURL-only.json
@@ -0,0 +1,413 @@
+{
+ "type": "Create",
+ "id": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6/activity",
+ "actor": "https://peertube.stream/accounts/createurs",
+ "object": {
+ "type": "Video",
+ "id": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6",
+ "name": "Vu du 20/02/21 : \"Planète Mars 2050\"",
+ "duration": "PT385S",
+ "uuid": "abece3c3-b9c6-47f4-8040-f3eed8c602e6",
+ "tag": [
+ {
+ "type": "Hashtag",
+ "name": "France3"
+ },
+ {
+ "type": "Hashtag",
+ "name": "lezapping"
+ }
+ ],
+ "category": {
+ "identifier": "11",
+ "name": "News & Politics"
+ },
+ "language": {
+ "identifier": "fr",
+ "name": "French"
+ },
+ "views": 5,
+ "sensitive": false,
+ "waitTranscoding": false,
+ "isLiveBroadcast": false,
+ "liveSaveReplay": null,
+ "permanentLive": null,
+ "state": 1,
+ "commentsEnabled": true,
+ "downloadEnabled": false,
+ "published": "2021-02-20T17:04:54.278Z",
+ "originallyPublishedAt": "2021-02-19T23:00:00.000Z",
+ "updated": "2021-02-21T20:01:11.189Z",
+ "mediaType": "text/markdown",
+ "content": "Un regard impertinent et libre, orchestré par Patrick Menais et son équipe, sur le monde de l’image.\r\n\r\nEn avant-première du lundi au samedi à 17h00 sur Facebook, Twitter et YouTube.\r\n\r\nDu lundi au samedi à 20h00 sur France 3.\r\n\r\nhttps://www.facebook.com/vufrancetv\r\nhttps://twitter.com/VuFrancetv",
+ "support": "Suivre VU :\r\n- Twitter : https://twitter.com/vufrancetv\r\n- Facebook :https://www.facebook.com/vufrancetv/\r\n- Site : https://www.france.tv/france-3/vu/",
+ "subtitleLanguage": [],
+ "icon": [
+ {
+ "type": "Image",
+ "url": "https://peertube.stream/static/thumbnails/abece3c3-b9c6-47f4-8040-f3eed8c602e6.jpg",
+ "mediaType": "image/jpeg",
+ "width": 223,
+ "height": 122
+ },
+ {
+ "type": "Image",
+ "url": "https://peertube.stream/lazy-static/previews/abece3c3-b9c6-47f4-8040-f3eed8c602e6.jpg",
+ "mediaType": "image/jpeg",
+ "width": 850,
+ "height": 480
+ }
+ ],
+ "url": [
+ {
+ "type": "Link",
+ "mediaType": "text/html",
+ "href": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6"
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-mpegURL",
+ "href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/master.m3u8",
+ "tag": [
+ {
+ "type": "Infohash",
+ "name": "00bfce9595e1655d8696b60e19ca25c34be5fa63"
+ },
+ {
+ "type": "Infohash",
+ "name": "256c21b65d5e0f944b4b79d8e0cbc55c9d906807"
+ },
+ {
+ "type": "Infohash",
+ "name": "fcd981098c484d0e328927c8fb21ecf986880b7e"
+ },
+ {
+ "type": "Infohash",
+ "name": "f7e01ac566e9fef91cd22514e6c3c256af7a9f5f"
+ },
+ {
+ "type": "Infohash",
+ "name": "42b421fc44d0dceb45ac3f6f6419b07fd570a232"
+ },
+ {
+ "type": "Infohash",
+ "name": "f876c6d6d49ce618a880ca223df54cb29f4b4bfd"
+ },
+ {
+ "type": "Link",
+ "name": "sha256",
+ "mediaType": "application/json",
+ "href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/segments-sha256.json"
+ },
+ {
+ "type": "Link",
+ "mediaType": "video/mp4",
+ "href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-1080-fragmented.mp4",
+ "height": 1080,
+ "size": 57888169,
+ "fps": 25
+ },
+ {
+ "type": "Link",
+ "rel": [
+ "metadata",
+ "video/mp4"
+ ],
+ "mediaType": "application/json",
+ "href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570040",
+ "height": 1080,
+ "fps": 25
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent",
+ "href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-1080-hls.torrent",
+ "height": 1080
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
+ "href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-1080-hls.torrent&xt=urn:btih:68af82ebcd9df8335e407b755f38f5fd39c8a6a4&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-1080-fragmented.mp4",
+ "height": 1080
+ },
+ {
+ "type": "Link",
+ "mediaType": "video/mp4",
+ "href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-720-fragmented.mp4",
+ "height": 720,
+ "size": 45165123,
+ "fps": 25
+ },
+ {
+ "type": "Link",
+ "rel": [
+ "metadata",
+ "video/mp4"
+ ],
+ "mediaType": "application/json",
+ "href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570056",
+ "height": 720,
+ "fps": 25
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent",
+ "href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-720-hls.torrent",
+ "height": 720
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
+ "href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-720-hls.torrent&xt=urn:btih:8450928a4ffb2a4c5f927a163487c48c05f6e700&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-720-fragmented.mp4",
+ "height": 720
+ },
+ {
+ "type": "Link",
+ "mediaType": "video/mp4",
+ "href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-480-fragmented.mp4",
+ "height": 480,
+ "size": 29618534,
+ "fps": 25
+ },
+ {
+ "type": "Link",
+ "rel": [
+ "metadata",
+ "video/mp4"
+ ],
+ "mediaType": "application/json",
+ "href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570042",
+ "height": 480,
+ "fps": 25
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent",
+ "href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-480-hls.torrent",
+ "height": 480
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
+ "href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-480-hls.torrent&xt=urn:btih:39e11181db5f376aa78c94bffcb9ccf2f4bca715&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-480-fragmented.mp4",
+ "height": 480
+ },
+ {
+ "type": "Link",
+ "mediaType": "video/mp4",
+ "href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-360-fragmented.mp4",
+ "height": 360,
+ "size": 21771466,
+ "fps": 25
+ },
+ {
+ "type": "Link",
+ "rel": [
+ "metadata",
+ "video/mp4"
+ ],
+ "mediaType": "application/json",
+ "href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570043",
+ "height": 360,
+ "fps": 25
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent",
+ "href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-360-hls.torrent",
+ "height": 360
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
+ "href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-360-hls.torrent&xt=urn:btih:c33aa52822528e29ffd1a615ebe40450e4c61452&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-360-fragmented.mp4",
+ "height": 360
+ },
+ {
+ "type": "Link",
+ "mediaType": "video/mp4",
+ "href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-240-fragmented.mp4",
+ "height": 240,
+ "size": 14856165,
+ "fps": 25
+ },
+ {
+ "type": "Link",
+ "rel": [
+ "metadata",
+ "video/mp4"
+ ],
+ "mediaType": "application/json",
+ "href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570057",
+ "height": 240,
+ "fps": 25
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent",
+ "href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-240-hls.torrent",
+ "height": 240
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
+ "href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-240-hls.torrent&xt=urn:btih:157e4cc3e9f15c06e995d6c3388539fdda312771&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-240-fragmented.mp4",
+ "height": 240
+ },
+ {
+ "type": "Link",
+ "mediaType": "video/mp4",
+ "href": "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-0-fragmented.mp4",
+ "height": 0,
+ "size": 6248765,
+ "fps": 0
+ },
+ {
+ "type": "Link",
+ "rel": [
+ "metadata",
+ "video/mp4"
+ ],
+ "mediaType": "application/json",
+ "href": "https://peertube.stream/api/v1/videos/abece3c3-b9c6-47f4-8040-f3eed8c602e6/metadata/570041",
+ "height": 0,
+ "fps": 0
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent",
+ "href": "https://peertube.stream/static/torrents/abece3c3-b9c6-47f4-8040-f3eed8c602e6-0-hls.torrent",
+ "height": 0
+ },
+ {
+ "type": "Link",
+ "mediaType": "application/x-bittorrent;x-scheme-handler/magnet",
+ "href": "magnet:?xs=https%3A%2F%2Fpeertube.stream%2Fstatic%2Ftorrents%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-0-hls.torrent&xt=urn:btih:abc8dc58903d18cf7ec0c0cef92cc5ffe5cb0b5c&dn=Vu+du+20%2F02%2F21+%3A+%22Plan%C3%A8te+Mars+2050%22&tr=wss%3A%2F%2Fpeertube.stream%3A443%2Ftracker%2Fsocket&tr=https%3A%2F%2Fpeertube.stream%2Ftracker%2Fannounce&ws=https%3A%2F%2Fpeertube.stream%2Fstatic%2Fstreaming-playlists%2Fhls%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6%2Fabece3c3-b9c6-47f4-8040-f3eed8c602e6-0-fragmented.mp4",
+ "height": 0
+ }
+ ]
+ }
+ ],
+ "likes": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6/likes",
+ "dislikes": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6/dislikes",
+ "shares": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6/announces",
+ "comments": "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6/comments",
+ "attributedTo": [
+ {
+ "type": "Person",
+ "id": "https://peertube.stream/accounts/createurs"
+ },
+ {
+ "type": "Group",
+ "id": "https://peertube.stream/video-channels/vu"
+ }
+ ],
+ "to": [
+ "https://www.w3.org/ns/activitystreams#Public"
+ ],
+ "cc": [
+ "https://peertube.stream/accounts/createurs/followers"
+ ]
+ },
+ "to": [
+ "https://www.w3.org/ns/activitystreams#Public"
+ ],
+ "cc": [
+ "https://peertube.stream/accounts/createurs/followers"
+ ],
+ "@context": [
+ "https://www.w3.org/ns/activitystreams",
+ "https://w3id.org/security/v1",
+ {
+ "RsaSignature2017": "https://w3id.org/security#RsaSignature2017"
+ },
+ {
+ "pt": "https://joinpeertube.org/ns#",
+ "sc": "http://schema.org#",
+ "Hashtag": "as:Hashtag",
+ "uuid": "sc:identifier",
+ "category": "sc:category",
+ "licence": "sc:license",
+ "subtitleLanguage": "sc:subtitleLanguage",
+ "sensitive": "as:sensitive",
+ "language": "sc:inLanguage",
+ "isLiveBroadcast": "sc:isLiveBroadcast",
+ "liveSaveReplay": {
+ "@type": "sc:Boolean",
+ "@id": "pt:liveSaveReplay"
+ },
+ "permanentLive": {
+ "@type": "sc:Boolean",
+ "@id": "pt:permanentLive"
+ },
+ "Infohash": "pt:Infohash",
+ "Playlist": "pt:Playlist",
+ "PlaylistElement": "pt:PlaylistElement",
+ "originallyPublishedAt": "sc:datePublished",
+ "views": {
+ "@type": "sc:Number",
+ "@id": "pt:views"
+ },
+ "state": {
+ "@type": "sc:Number",
+ "@id": "pt:state"
+ },
+ "size": {
+ "@type": "sc:Number",
+ "@id": "pt:size"
+ },
+ "fps": {
+ "@type": "sc:Number",
+ "@id": "pt:fps"
+ },
+ "startTimestamp": {
+ "@type": "sc:Number",
+ "@id": "pt:startTimestamp"
+ },
+ "stopTimestamp": {
+ "@type": "sc:Number",
+ "@id": "pt:stopTimestamp"
+ },
+ "position": {
+ "@type": "sc:Number",
+ "@id": "pt:position"
+ },
+ "commentsEnabled": {
+ "@type": "sc:Boolean",
+ "@id": "pt:commentsEnabled"
+ },
+ "downloadEnabled": {
+ "@type": "sc:Boolean",
+ "@id": "pt:downloadEnabled"
+ },
+ "waitTranscoding": {
+ "@type": "sc:Boolean",
+ "@id": "pt:waitTranscoding"
+ },
+ "support": {
+ "@type": "sc:Text",
+ "@id": "pt:support"
+ },
+ "likes": {
+ "@id": "as:likes",
+ "@type": "@id"
+ },
+ "dislikes": {
+ "@id": "as:dislikes",
+ "@type": "@id"
+ },
+ "playlists": {
+ "@id": "pt:playlists",
+ "@type": "@id"
+ },
+ "shares": {
+ "@id": "as:shares",
+ "@type": "@id"
+ },
+ "comments": {
+ "@id": "as:comments",
+ "@type": "@id"
+ }
+ }
+ ]
+}
diff --git a/test/mix/tasks/pleroma/ecto/rollback_test.exs b/test/mix/tasks/pleroma/ecto/rollback_test.exs
index a0751acb1..f8a37bd49 100644
--- a/test/mix/tasks/pleroma/ecto/rollback_test.exs
+++ b/test/mix/tasks/pleroma/ecto/rollback_test.exs
@@ -12,7 +12,7 @@ defmodule Mix.Tasks.Pleroma.Ecto.RollbackTest do
Logger.configure(level: :warn)
assert capture_log(fn ->
- Mix.Tasks.Pleroma.Ecto.Rollback.run()
+ Mix.Tasks.Pleroma.Ecto.Rollback.run(["--env", "test"])
end) =~ "[info] Rollback succesfully"
Logger.configure(level: level)
diff --git a/test/pleroma/web/activity_pub/transmogrifier/video_handling_test.exs b/test/pleroma/web/activity_pub/transmogrifier/video_handling_test.exs
index c00df6a04..6ddf7c172 100644
--- a/test/pleroma/web/activity_pub/transmogrifier/video_handling_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier/video_handling_test.exs
@@ -92,4 +92,34 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.VideoHandlingTest do
assert object.data["url"] ==
"https://framatube.org/videos/watch/6050732a-8a7a-43d4-a6cd-809525a1d206"
end
+
+ test "it works for peertube videos with only their mpegURL map" do
+ data =
+ File.read!("test/fixtures/peertube/video-object-mpegURL-only.json")
+ |> Jason.decode!()
+
+ {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
+
+ assert object = Object.normalize(activity, fetch: false)
+
+ assert object.data["attachment"] == [
+ %{
+ "type" => "Link",
+ "mediaType" => "video/mp4",
+ "name" => nil,
+ "blurhash" => nil,
+ "url" => [
+ %{
+ "href" =>
+ "https://peertube.stream/static/streaming-playlists/hls/abece3c3-b9c6-47f4-8040-f3eed8c602e6/abece3c3-b9c6-47f4-8040-f3eed8c602e6-1080-fragmented.mp4",
+ "mediaType" => "video/mp4",
+ "type" => "Link"
+ }
+ ]
+ }
+ ]
+
+ assert object.data["url"] ==
+ "https://peertube.stream/videos/watch/abece3c3-b9c6-47f4-8040-f3eed8c602e6"
+ end
end
diff --git a/test/pleroma/web/activity_pub/transmogrifier_test.exs b/test/pleroma/web/activity_pub/transmogrifier_test.exs
index 7c97fa8f8..f6a8cbb6f 100644
--- a/test/pleroma/web/activity_pub/transmogrifier_test.exs
+++ b/test/pleroma/web/activity_pub/transmogrifier_test.exs
@@ -202,7 +202,20 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
test "it strips internal fields" do
user = insert(:user)
- {:ok, activity} = CommonAPI.post(user, %{status: "#2hu :firefox:"})
+ {:ok, activity} =
+ CommonAPI.post(user, %{
+ status: "#2hu :firefox:",
+ application: %{type: "Application", name: "TestClient", url: "https://pleroma.social"}
+ })
+
+ # Ensure injected application data made it into the activity
+ # as we don't have a Token to derive it from, otherwise it will
+ # be nil and the test will pass
+ assert %{
+ type: "Application",
+ name: "TestClient",
+ url: "https://pleroma.social"
+ } == activity.object.data["application"]
{:ok, modified} = Transmogrifier.prepare_outgoing(activity.data)
@@ -213,6 +226,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
assert is_nil(modified["object"]["announcements"])
assert is_nil(modified["object"]["announcement_count"])
assert is_nil(modified["object"]["context_id"])
+ assert is_nil(modified["object"]["application"])
end
test "it strips internal fields of article" do
diff --git a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
index dcd1e6d5b..dd2f306b7 100644
--- a/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/status_controller_test.exs
@@ -357,6 +357,50 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
assert activity.data["to"] == [user2.ap_id]
assert activity.data["cc"] == []
end
+
+ test "discloses application metadata when enabled" do
+ user = insert(:user, disclose_client: true)
+ %{user: _user, token: token, conn: conn} = oauth_access(["write:statuses"], user: user)
+
+ %Pleroma.Web.OAuth.Token{
+ app: %Pleroma.Web.OAuth.App{
+ client_name: _app_name,
+ website: _app_website
+ }
+ } = token
+
+ result =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
+ "status" => "cofe is my copilot"
+ })
+
+ assert %{
+ "content" => "cofe is my copilot",
+ "application" => %{
+ "name" => app_name,
+ "website" => app_website
+ }
+ } = json_response_and_validate_schema(result, 200)
+ end
+
+ test "hides application metadata when disabled" do
+ user = insert(:user, disclose_client: false)
+ %{user: _user, token: _token, conn: conn} = oauth_access(["write:statuses"], user: user)
+
+ result =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
+ "status" => "club mate is my wingman"
+ })
+
+ assert %{
+ "content" => "club mate is my wingman",
+ "application" => nil
+ } = json_response_and_validate_schema(result, 200)
+ end
end
describe "posting scheduled statuses" do
@@ -383,6 +427,31 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
assert [] == Repo.all(Activity)
end
+ test "with expiration" do
+ %{conn: conn} = oauth_access(["write:statuses", "read:statuses"])
+
+ scheduled_at =
+ NaiveDateTime.add(NaiveDateTime.utc_now(), :timer.minutes(6), :millisecond)
+ |> NaiveDateTime.to_iso8601()
+ |> Kernel.<>("Z")
+
+ assert %{"id" => status_id, "params" => %{"expires_in" => 300}} =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/v1/statuses", %{
+ "status" => "scheduled",
+ "scheduled_at" => scheduled_at,
+ "expires_in" => 300
+ })
+ |> json_response_and_validate_schema(200)
+
+ assert %{"id" => ^status_id, "params" => %{"expires_in" => 300}} =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> get("/api/v1/scheduled_statuses/#{status_id}")
+ |> json_response_and_validate_schema(200)
+ end
+
test "ignores nil values", %{conn: conn} do
conn =
conn
diff --git a/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs b/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs
index c3b7f0f41..e323f3a1f 100644
--- a/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/scheduled_activity_view_test.exs
@@ -58,7 +58,8 @@ defmodule Pleroma.Web.MastodonAPI.ScheduledActivityViewTest do
sensitive: true,
spoiler_text: "spoiler",
text: "hi",
- visibility: "unlisted"
+ visibility: "unlisted",
+ expires_in: nil
},
scheduled_at: Utils.to_masto_date(scheduled_activity.scheduled_at)
}
diff --git a/test/pleroma/web/mastodon_api/views/status_view_test.exs b/test/pleroma/web/mastodon_api/views/status_view_test.exs
index ed59cf285..2de3afc4f 100644
--- a/test/pleroma/web/mastodon_api/views/status_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/status_view_test.exs
@@ -266,10 +266,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
url: "http://localhost:4001/tag/#{object_data["tag"]}"
}
],
- application: %{
- name: "Web",
- website: nil
- },
+ application: nil,
language: nil,
emojis: [
%{
diff --git a/test/pleroma/web/plugs/frontend_static_plug_test.exs b/test/pleroma/web/plugs/frontend_static_plug_test.exs
index c8cfc967c..100b83d6a 100644
--- a/test/pleroma/web/plugs/frontend_static_plug_test.exs
+++ b/test/pleroma/web/plugs/frontend_static_plug_test.exs
@@ -74,4 +74,35 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do
assert %Plug.Conn{status: :success} = get(conn, url)
end
end
+
+ test "api routes are detected correctly" do
+ # If this test fails we have probably added something
+ # new that should be in /api/ instead
+ expected_routes = [
+ "api",
+ "main",
+ "ostatus_subscribe",
+ "oauth",
+ "objects",
+ "activities",
+ "notice",
+ "users",
+ "tags",
+ "mailer",
+ "inbox",
+ "relay",
+ "internal",
+ ".well-known",
+ "nodeinfo",
+ "web",
+ "auth",
+ "embed",
+ "proxy",
+ "test",
+ "user_exists",
+ "check_password"
+ ]
+
+ assert expected_routes == Pleroma.Web.get_api_routes()
+ end
end
diff --git a/test/support/http_request_mock.ex b/test/support/http_request_mock.ex
index 7da0a8380..1328d6225 100644
--- a/test/support/http_request_mock.ex
+++ b/test/support/http_request_mock.ex
@@ -275,6 +275,15 @@ defmodule HttpRequestMock do
}}
end
+ def get("https://peertube.stream/accounts/createurs", _, _, _) do
+ {:ok,
+ %Tesla.Env{
+ status: 200,
+ body: File.read!("test/fixtures/peertube/actor-person.json"),
+ headers: activitypub_object_headers()
+ }}
+ end
+
def get("https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3", _, _, _) do
{:ok,
%Tesla.Env{