Commit graph

1677 commits

Author SHA1 Message Date
Mark Felder 17d04ccc8b RichMedia backfill processing through Oban 2024-06-19 23:20:22 -04:00
Lain Soykaf 41434ffcec Tests: Don't spawn processes in tests. 2024-06-12 15:20:04 -04:00
Haelwenn (lanodan) Monnier cb91dab75f Switch formatting checks to Elixir 1.15 2024-06-12 15:18:47 -04:00
Lain Soykaf 3b4be5daa2 Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into pleroma-secure-mode 2024-05-28 12:31:12 +04:00
Lain Soykaf f4c0a01f09 Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into image-description-summary 2024-05-27 20:03:14 +04:00
lain 7fca598268 Merge branch 'status-notification-type' into 'develop'
Add "status" notification type

See merge request pleroma/pleroma!3659
2024-05-21 05:01:45 +00:00
lain e8cd6662eb Merge branch 'familiar-followers' into 'develop'
Implement `/api/v1/accounts/familiar_followers`

See merge request pleroma/pleroma!4098
2024-05-19 12:05:55 +00:00
marcin mikołajczak 2e76ceb5b4 Merge remote-tracking branch 'origin/develop' into status-notification-type
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-05-18 11:30:25 +02:00
feld 53ef576739 Merge branch 'instance_rules' into 'develop'
Instance rules

See merge request pleroma/pleroma!3669
2024-05-15 20:29:04 +00:00
feld c954437cc0 Merge branch 'mastodon-instance-v2' into 'develop'
Add new values to /api/v2/instance

Closes #3250 and #3251

See merge request pleroma/pleroma!4106
2024-05-11 12:11:00 +00:00
marcin mikołajczak 818d9f7b63 Include image description in status media cards
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-05-08 13:40:26 -04:00
Mark Felder 19002fd6c1 Mastodon API: Remove deprecated GET /api/v1/statuses/:id/card endpoint
Removed back in 2019

https://github.com/mastodon/mastodon/pull/11213
2024-05-08 01:44:58 +00:00
Mark Felder ede414094f RichMedia refactor
Rich Media parsing was previously handled on-demand with a 2 second HTTP request timeout and retained only in Cachex. Every time a Pleroma instance is restarted it will have to request and parse the data for each status with a URL detected. When fetching a batch of statuses they were processed in parallel to attempt to keep the maximum latency at 2 seconds, but often resulted in a timeline appearing to hang during loading due to a URL that could not be successfully reached. URLs which had images links that expire (Amazon AWS) were parsed and inserted with a TTL to ensure the image link would not break.

Rich Media data is now cached in the database and fetched asynchronously. Cachex is used as a read-through cache. When the data becomes available we stream an update to the clients. If the result is returned quickly the experience is almost seamless. Activities were already processed for their Rich Media data during ingestion to warm the cache, so users should not normally encounter the asynchronous loading of the Rich Media data.

Implementation notes:

- The async worker is a Task with a globally unique process name to prevent duplicate processing of the same URL
- The Task will attempt to fetch the data 3 times with increasing sleep time between attempts
- The HTTP request obeys the default HTTP request timeout value instead of 2 seconds
- URLs that cannot be successfully parsed due to an unexpected error receives a negative cache entry for 15 minutes
- URLs that fail with an expected error will receive a negative cache with no TTL
- Activities that have no detected URLs insert a nil value in the Cachex :scrubber_cache so we do not repeat parsing the object content with Floki every time the activity is rendered
- Expiring image URLs are handled with an Oban job
- There is no automatic cleanup of the Rich Media data in the database, but it is safe to delete at any time
- The post draft/preview feature makes the URL processing synchronous so the rendered post preview will have an accurate rendering

Overall performance of timelines and creating new posts which contain URLs is greatly improved.
2024-05-07 19:54:56 -04:00
feld 750fb25f48 Revert "Merge branch 'pleroma-card-image-description' into 'develop'"
This reverts merge request !4101
2024-05-07 23:20:38 +00:00
Mark Felder b979389958 Add configuration[accounts][max_pinned_statuses] to /api/v2/instance
Also add the absent max_featured_tags to the api spec for /api/v2/instance
2024-05-07 17:45:02 -04:00
Mark Felder 3cad57bf48 Add configuration[statuses][characters_reserved_per_url] to /api/v2/instance
Fixes #3250
2024-05-07 17:25:30 -04:00
marcin mikołajczak 6f6bede900 Include image description in status media cards
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-04-19 10:20:31 +04:00
marcin mikołajczak ccc3ac241f Add hint to rules
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-04-06 11:45:19 +02:00
marcin mikołajczak 9e6cf45906 /api/v1/accounts/familiar_followers
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-04-06 11:43:56 +02:00
marcin mikołajczak 01a5f839c5 Merge remote-tracking branch 'origin/develop' into instance_rules 2024-04-06 10:42:23 +02:00
marcin mikołajczak 60c4cb21ea InstanceView: Update features
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-03-18 14:02:29 +01:00
marcin mikołajczak 918c406a91 Merge remote-tracking branch 'origin/develop' into instance_rules
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-03-18 13:50:25 +01:00
lain 2b71f4897f Merge branch 'develop' into 'bookmark-folders'
# Conflicts:
#   docs/development/API/differences_in_mastoapi_responses.md
2024-03-18 10:35:02 +00:00
lain cf0aa1238c Merge branch 'public-polls' into 'develop'
Expose nonAnonymous field from Smithereen polls

See merge request pleroma/pleroma!3962
2024-03-18 06:26:22 +00:00
marcin mikołajczak c0c4a9ed0d Merge remote-tracking branch 'origin/develop' into instance-contact-account
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-03-08 12:12:55 +01:00
marcin mikołajczak d415686bb9 Allow to group bookmarks in folders
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-03-01 11:04:01 +01:00
marcin mikołajczak acb9e46074 Add some missing fields to instanceV2
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-02-27 13:25:26 +01:00
marcin mikołajczak c592a0e58d Merge remote-tracking branch 'origin/develop' into HEAD
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-02-22 21:05:20 +01:00
Mark Felder 64ad451a7b Websocket refactor to use Phoenix.Socket.Transport
This will make us compatible with Cowboy and Bandit
2024-02-14 15:27:07 -05:00
marcin mikołajczak 226e53fdd7 Merge remote-tracking branch 'origin/develop' into status-notification-type
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-01-31 22:19:33 +01:00
Mark Felder ed2f8e45e9 Pleroma.Web.MastodonAPI.SearchController: fix dialyzer errors
Add a separate Pagination.paginate_list/2 function instead of overloading paginate/4 and complicating its matching and @spec
2024-01-31 11:12:41 -05:00
Mark Felder b8db67dafa Pleroma.Web.MastodonAPI.StatusController: fix dialzyer errors with replace_params: false 2024-01-31 10:13:02 -05:00
Mark Felder fdddba100e Pleroma.Web.MastodonAPI.SearchController: fix dialyzer errors with replace_params: false 2024-01-30 18:40:46 -05:00
Mark Felder 324fd08455 Pleroma.Web.MastodonAPI.ScheduledActivityController: fix dialyzer errors with replace_params: false 2024-01-30 18:33:23 -05:00
Mark Felder d3c6acd2f2 Pleroma.Web.MastodonAPI.PollController: fix dialyzer errors with replace_params: false 2024-01-30 18:31:13 -05:00
Mark Felder 0a6b2c9587 Pleroma.Web.MastodonAPI.NotificationController: fix dialyzer errors with replace_params: false 2024-01-30 18:27:31 -05:00
Mark Felder 90c9f38f40 Pleroma.Web.MastodonAPI.MediaController: fix dialyzer errors with replace_params: false 2024-01-30 18:09:11 -05:00
Mark Felder 9741f045e4 Pleroma.Web.MastodonAPI.ListController: fix dialyzer errors with replace_params: false 2024-01-30 18:05:28 -05:00
Mark Felder 14de8376ad Pleroma.Web.MastodonAPI.FollowRequestController: fix dialyzer errors with replace_params: false 2024-01-30 17:56:43 -05:00
Mark Felder 81c8592d69 Pleroma.Web.MastodonAPI.AccountController: fix dialyzer errors with replace_params: false 2024-01-30 16:50:00 -05:00
Mark Felder cfe7438b2f Pleroma.Web.MastodonAPI.DomainBlockController: dialyzer fixes via :replace_params 2024-01-30 14:52:15 -05:00
Mark Felder 1fa1a93cd6 Revert "Pleroma.Web.MastodonAPI.AccountController: dialyzer errors"
This reverts commit e53c20b03c.
2024-01-30 14:13:46 -05:00
Mark Felder 41493bd642 Revert "Pleroma.Web.MastodonAPI.DomainBlockController: dialyzer errors"
This reverts commit 378edeaf15.
2024-01-30 14:13:23 -05:00
Mark Felder a3426fcaf3 Revert "Pleroma.Web.MastodonAPI.MediaController: dialyzer errors"
This reverts commit 8cd5279857.
2024-01-30 14:13:13 -05:00
Mark Felder 8cd5279857 Pleroma.Web.MastodonAPI.MediaController: dialyzer errors
lib/pleroma/web/mastodon_api/controllers/media_controller.ex:32:call
The function call will not succeed.

Phoenix.Controller.render(
  _conn :: %{
    :assigns => %{:user => _, _ => _},
    :body_params => %{:file => _, _ => _},
    _ => _
  },
  <<97, 116, 116, 97, 99, 104, 109, 101, 110, 116, 46, 106, 115, 111, 110>>,
  %{:attachment => map()}
)

will never return since the success typing is:
(
  %Plug.Conn{
    :adapter => {atom(), _},
    :assigns => %{atom() => _},
    :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :halted => boolean(),
    :host => binary(),
    :method => binary(),
    :owner => pid(),
    :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :path_info => [binary()],
    :path_params => %{binary() => binary() | [any()] | map()},
    :port => char(),
    :private => %{atom() => _},
    :query_params => %Plug.Conn.Unfetched{
      :aspect => atom(),
      binary() => binary() | [any()] | map()
    },
    :query_string => binary(),
    :remote_ip =>
      {byte(), byte(), byte(), byte()}
      | {char(), char(), char(), char(), char(), char(), char(), char()},
    :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()},
    :req_headers => [{_, _}],
    :request_path => binary(),
    :resp_body =>
      nil
      | binary()
      | maybe_improper_list(
          binary() | maybe_improper_list(any(), binary() | []) | byte(),
          binary() | []
        ),
    :resp_cookies => %{binary() => map()},
    :resp_headers => [{_, _}],
    :scheme => :http | :https,
    :script_name => [binary()],
    :secret_key_base => nil | binary(),
    :state =>
      :chunked | :file | :sent | :set | :set_chunked | :set_file | :unset | :upgraded,
    :status => nil | non_neg_integer()
  },
  atom() | binary(),
  atom() | binary() | [{_, _}] | map()
) :: %Plug.Conn{
  :adapter => {atom(), _},
  :assigns => %{atom() => _},
  :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
  :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
  :halted => boolean(),
  :host => binary(),
  :method => binary(),
  :owner => pid(),
  :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
  :path_info => [binary()],
  :path_params => %{binary() => binary() | [any()] | map()},
  :port => char(),
  :private => %{atom() => _},
  :query_params => %Plug.Conn.Unfetched{
    :aspect => atom(),
    binary() => binary() | [any()] | map()
  },
  :query_string => binary(),
  :remote_ip =>
    {byte(), byte(), byte(), byte()}
    | {char(), char(), char(), char(), char(), char(), char(), char()},
  :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()},
  :req_headers => [{_, _}],
  :request_path => binary(),
  :resp_body =>
    nil
    | binary()
    | maybe_improper_list(
        binary() | maybe_improper_list(any(), binary() | []) | byte(),
        binary() | []
      ),
  :resp_cookies => %{binary() => map()},
  :resp_headers => [{_, _}],
  :scheme => :http | :https,
  :script_name => [binary()],
  :secret_key_base => nil | binary(),
  :state => :sent,
  :status => nil | non_neg_integer()
}

and the contract is
(Plug.Conn.t(), binary() | atom(), Keyword.t() | map()) :: Plug.Conn.t()

________________________________________________________________________________
lib/pleroma/web/mastodon_api/controllers/media_controller.ex:48:call
The function call will not succeed.

Plug.Conn.put_status(
  _conn :: %{
    :assigns => %{:user => _, _ => _},
    :body_params => %{:file => _, _ => _},
    _ => _
  },
  202
)

breaks the contract
(t(), status()) :: t()

________________________________________________________________________________
lib/pleroma/web/mastodon_api/controllers/media_controller.ex:63:call
The function call will not succeed.

Phoenix.Controller.render(
  _conn :: %{
    :assigns => %{:user => _, _ => _},
    :body_params => %{:description => _, _ => _},
    _ => _
  },
  <<97, 116, 116, 97, 99, 104, 109, 101, 110, 116, 46, 106, 115, 111, 110>>,
  %{:attachment => map()}
)

will never return since the success typing is:
(
  %Plug.Conn{
    :adapter => {atom(), _},
    :assigns => %{atom() => _},
    :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :halted => boolean(),
    :host => binary(),
    :method => binary(),
    :owner => pid(),
    :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :path_info => [binary()],
    :path_params => %{binary() => binary() | [any()] | map()},
    :port => char(),
    :private => %{atom() => _},
    :query_params => %Plug.Conn.Unfetched{
      :aspect => atom(),
      binary() => binary() | [any()] | map()
    },
    :query_string => binary(),
    :remote_ip =>
      {byte(), byte(), byte(), byte()}
      | {char(), char(), char(), char(), char(), char(), char(), char()},
    :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()},
    :req_headers => [{_, _}],
    :request_path => binary(),
    :resp_body =>
      nil
      | binary()
      | maybe_improper_list(
          binary() | maybe_improper_list(any(), binary() | []) | byte(),
          binary() | []
        ),
    :resp_cookies => %{binary() => map()},
    :resp_headers => [{_, _}],
    :scheme => :http | :https,
    :script_name => [binary()],
    :secret_key_base => nil | binary(),
    :state =>
      :chunked | :file | :sent | :set | :set_chunked | :set_file | :unset | :upgraded,
    :status => nil | non_neg_integer()
  },
  atom() | binary(),
  atom() | binary() | [{_, _}] | map()
) :: %Plug.Conn{
  :adapter => {atom(), _},
  :assigns => %{atom() => _},
  :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
  :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
  :halted => boolean(),
  :host => binary(),
  :method => binary(),
  :owner => pid(),
  :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
  :path_info => [binary()],
  :path_params => %{binary() => binary() | [any()] | map()},
  :port => char(),
  :private => %{atom() => _},
  :query_params => %Plug.Conn.Unfetched{
    :aspect => atom(),
    binary() => binary() | [any()] | map()
  },
  :query_string => binary(),
  :remote_ip =>
    {byte(), byte(), byte(), byte()}
    | {char(), char(), char(), char(), char(), char(), char(), char()},
  :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()},
  :req_headers => [{_, _}],
  :request_path => binary(),
  :resp_body =>
    nil
    | binary()
    | maybe_improper_list(
        binary() | maybe_improper_list(any(), binary() | []) | byte(),
        binary() | []
      ),
  :resp_cookies => %{binary() => map()},
  :resp_headers => [{_, _}],
  :scheme => :http | :https,
  :script_name => [binary()],
  :secret_key_base => nil | binary(),
  :state => :sent,
  :status => nil | non_neg_integer()
}

and the contract is
(Plug.Conn.t(), binary() | atom(), Keyword.t() | map()) :: Plug.Conn.t()
2024-01-29 18:36:46 -05:00
Mark Felder 378edeaf15 Pleroma.Web.MastodonAPI.DomainBlockController: dialyzer errors
lib/pleroma/web/mastodon_api/controllers/domain_block_controller.ex:32:call
The function call will not succeed.

Phoenix.Controller.json(
  _conn :: %{
    :assigns => %{:user => _, _ => _},
    :body_params => %{:domain => _, _ => _},
    _ => _
  },
  %{}
)

breaks the contract
(Plug.Conn.t(), term()) :: Plug.Conn.t()

________________________________________________________________________________
lib/pleroma/web/mastodon_api/controllers/domain_block_controller.ex:43:call
The function call will not succeed.

Phoenix.Controller.json(
  _conn :: %{
    :assigns => %{:user => _, _ => _},
    :body_params => %{:domain => _, _ => _},
    _ => _
  },
  %{}
)

breaks the contract
(Plug.Conn.t(), term()) :: Plug.Conn.t()
2024-01-29 18:36:34 -05:00
Mark Felder 3cb2807244 Pleroma.Web.MastodonAPI.StatusView: dialyzer error
lib/pleroma/web/mastodon_api/views/status_view.ex:799:pattern_match_cov
The pattern
_, _

can never match, because previous clauses completely cover the type

  %URI{
    :authority => URI.authority(),
    :fragment => nil | binary(),
    :host => nil | binary(),
    :path => nil | binary(),
    :port => nil | char(),
    :query => nil | binary(),
    :scheme => nil | binary(),
    :userinfo => nil | binary()
  },
  %URI{
    :authority => URI.authority(),
    :fragment => nil | binary(),
    :host => nil | binary(),
    :path => nil | binary(),
    :port => nil | char(),
    :query => nil | binary(),
    :scheme => nil | binary(),
    :userinfo => nil | binary()
  }
.
2024-01-29 18:28:49 -05:00
Haelwenn 251c455b91 Merge branch 'deps-bump' into 'develop'
Bump dependencies

See merge request pleroma/pleroma!4044
2024-01-29 17:43:00 +00:00
Mark Felder 6a22a80f9f Pleroma.Web.MastodonAPI.DirectoryController: dialyzer errors
lib/pleroma/web/mastodon_api/controllers/directory_controller.ex:6:unused_fun
Function skip_auth/2 will never be called.
________________________________________________________________________________
lib/pleroma/web/mastodon_api/controllers/directory_controller.ex:6:unused_fun
Function skip_plug/2 will never be called.
________________________________________________________________________________
lib/pleroma/web/mastodon_api/controllers/directory_controller.ex:18:guard_fail
The guard clause:

when _action :: atom() == <<105, 110, 100, 101, 120>>

can never succeed.
2024-01-28 17:41:07 -05:00
Mark Felder e53c20b03c Pleroma.Web.MastodonAPI.AccountController: dialyzer errors
lib/pleroma/web/mastodon_api/controllers/account_controller.ex:479:call
The function call will not succeed.

Phoenix.Controller.render(
  _conn :: %{
    :assigns => %{:account => _, :user => _, _ => _},
    :body_params => %{:comment => _, _ => _},
    _ => _
  },
  <<114, 101, 108, 97, 116, 105, 111, 110, 115, 104, 105, 112, 46, 106, 115, 111, 110>>,
  [
    {:target, %Pleroma.User{:id => _, _ => _}} | {:user, %Pleroma.User{:id => _, _ => _}},
    ...
  ]
)

will never return since the success typing is:
(
  %Plug.Conn{
    :adapter => {atom(), _},
    :assigns => %{atom() => _},
    :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :halted => boolean(),
    :host => binary(),
    :method => binary(),
    :owner => pid(),
    :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
    :path_info => [binary()],
    :path_params => %{binary() => binary() | [any()] | map()},
    :port => char(),
    :private => %{atom() => _},
    :query_params => %Plug.Conn.Unfetched{
      :aspect => atom(),
      binary() => binary() | [any()] | map()
    },
    :query_string => binary(),
    :remote_ip =>
      {byte(), byte(), byte(), byte()}
      | {char(), char(), char(), char(), char(), char(), char(), char()},
    :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()},
    :req_headers => [{_, _}],
    :request_path => binary(),
    :resp_body =>
      nil
      | binary()
      | maybe_improper_list(
          binary() | maybe_improper_list(any(), binary() | []) | byte(),
          binary() | []
        ),
    :resp_cookies => %{binary() => map()},
    :resp_headers => [{_, _}],
    :scheme => :http | :https,
    :script_name => [binary()],
    :secret_key_base => nil | binary(),
    :state =>
      :chunked | :file | :sent | :set | :set_chunked | :set_file | :unset | :upgraded,
    :status => nil | non_neg_integer()
  },
  atom() | binary(),
  atom() | binary() | [{_, _}] | map()
) :: %Plug.Conn{
  :adapter => {atom(), _},
  :assigns => %{atom() => _},
  :body_params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
  :cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
  :halted => boolean(),
  :host => binary(),
  :method => binary(),
  :owner => pid(),
  :params => %Plug.Conn.Unfetched{:aspect => atom(), binary() => _},
  :path_info => [binary()],
  :path_params => %{binary() => binary() | [any()] | map()},
  :port => char(),
  :private => %{atom() => _},
  :query_params => %Plug.Conn.Unfetched{
    :aspect => atom(),
    binary() => binary() | [any()] | map()
  },
  :query_string => binary(),
  :remote_ip =>
    {byte(), byte(), byte(), byte()}
    | {char(), char(), char(), char(), char(), char(), char(), char()},
  :req_cookies => %Plug.Conn.Unfetched{:aspect => atom(), binary() => binary()},
  :req_headers => [{_, _}],
  :request_path => binary(),
  :resp_body =>
    nil
    | binary()
    | maybe_improper_list(
        binary() | maybe_improper_list(any(), binary() | []) | byte(),
        binary() | []
      ),
  :resp_cookies => %{binary() => map()},
  :resp_headers => [{_, _}],
  :scheme => :http | :https,
  :script_name => [binary()],
  :secret_key_base => nil | binary(),
  :state => :sent,
  :status => nil | non_neg_integer()
}

and the contract is
(Plug.Conn.t(), binary() | atom(), Keyword.t() | map()) :: Plug.Conn.t()

________________________________________________________________________________
lib/pleroma/web/mastodon_api/controllers/account_controller.ex:519:call
The function call will not succeed.

Plug.Conn.assign(
  _conn :: %{:body_params => %{:uri => _, _ => _}, _ => _},
  :account,
  _user :: %Pleroma.User{_ => _}
)

breaks the contract
(t(), atom(), term()) :: t()
2024-01-28 17:41:07 -05:00