secret = KeyGenerator.generate(secret_key_base, token <> "_encrypt")
sign_secret = KeyGenerator.generate(secret_key_base, token <> "_sign")
- # If the time found is less than (current_time - seconds_valid), then the time has already passed.
+ # If the time found is less than (current_time-seconds_valid) then the time has already passed
# Later we check that the time found is more than the presumed invalidatation time, that means
# that the data is still valid and the captcha can be checked
seconds_valid = Pleroma.Config.get!([Pleroma.Captcha, :seconds_valid])
# surrond one/five line clippy with blank lines around to not fuck up the layout
#
- # yes this fix sucks but it's good enough, have you ever seen a release of windows wihtout some butched
- # features anyway?
+ # yes this fix sucks but it's good enough, have you ever seen a release of windows
+ # without some butched features anyway?
lines =
if length(lines) == 1 or length(lines) == 5 do
[""] ++ lines ++ [""]
@markdown_characters_regex ~r/(`|\*|_|{|}|[|]|\(|\)|#|\+|-|\.|!)/
@link_regex ~r{((?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~%:/?#[\]@!\$&'\(\)\*\+,;=.]+)|[0-9a-z+\-\.]+:[0-9a-z$-_.+!*'(),]+}ui
+ # credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
@auto_linker_config hashtag: true,
hashtag_handler: &Pleroma.Formatter.hashtag_handler/4,
preload: [user: user]
)
+ # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
with %Token{user: %{info: %{deactivated: false} = _} = user} = token_record <- Repo.one(query) do
{:ok, user, token_record}
end
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ReverseProxy do
- @keep_req_headers ~w(accept user-agent accept-encoding cache-control if-modified-since if-unmodified-since if-none-match if-range range)
+ @keep_req_headers ~w(accept user-agent accept-encoding cache-control if-modified-since) ++
+ ~w(if-unmodified-since if-none-match if-range range)
@resp_cache_headers ~w(etag date last-modified cache-control)
@keep_resp_headers @resp_cache_headers ++
- ~w(content-type content-disposition content-encoding content-range accept-ranges vary)
+ ~w(content-type content-disposition content-encoding content-range) ++
+ ~w(accept-ranges vary)
@default_cache_control_header "public, max-age=1209600"
@valid_resp_codes [200, 206, 304]
@max_read_duration :timer.seconds(30)
headers
has_cache? ->
- # There's caching header present but no cache-control -- we need to explicitely override it to public
- # as Plug defaults to "max-age=0, private, must-revalidate"
+ # There's caching header present but no cache-control -- we need to explicitely override it
+ # to public as Plug defaults to "max-age=0, private, must-revalidate"
List.keystore(headers, "cache-control", 0, {"cache-control", "public"})
true ->
@behaviour Pleroma.Uploaders.Uploader
require Logger
- # The file name is re-encoded with S3's constraints here to comply with previous links with less strict filenames
+ # The file name is re-encoded with S3's constraints here to comply with previous
+ # links with less strict filenames
def get_file(file) do
config = Pleroma.Config.get([__MODULE__])
bucket = Keyword.fetch!(config, :bucket)
@primary_key {:id, Pleroma.FlakeId, autogenerate: true}
+ # credo:disable-for-next-line Credo.Check.Readability.MaxLineLength
@email_regex ~r/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
@strict_local_nickname_regex ~r/^[a-zA-Z\d]+$/
Repo.get_by(User, ap_id: ap_id)
end
- # This is mostly an SPC migration fix. This guesses the user nickname (by taking the last part of the ap_id and the domain) and tries to get that user
+ # This is mostly an SPC migration fix. This guesses the user nickname by taking the last part
+ # of the ap_id and the domain and tries to get that user
def get_by_guessed_nickname(ap_id) do
domain = URI.parse(ap_id).host
name = List.last(String.split(ap_id, "/"))
additional
),
{:ok, activity} <- insert(create_data, local),
- # Changing note count prior to enqueuing federation task in order to avoid race conditions on updating user.info
+ # Changing note count prior to enqueuing federation task in order to avoid
+ # race conditions on updating user.info
{:ok, _actor} <- increase_note_count_if_public(actor, activity),
:ok <- maybe_federate(activity) do
{:ok, activity}
"deleted_activity_id" => activity && activity.id
},
{:ok, activity} <- insert(data, local),
- # Changing note count prior to enqueuing federation task in order to avoid race conditions on updating user.info
+ # Changing note count prior to enqueuing federation task in order to avoid
+ # race conditions on updating user.info
{:ok, _actor} <- decrease_note_count_if_public(user, object),
:ok <- maybe_federate(activity) do
{:ok, activity}
defp check_replace(%{"object" => %{"content" => content, "summary" => summary}} = message) do
{content, summary} =
- Enum.reduce(Pleroma.Config.get([:mrf_keyword, :replace]), {content, summary}, fn {pattern,
- replacement},
- {content_acc,
- summary_acc} ->
- {String.replace(content_acc, pattern, replacement),
- String.replace(summary_acc, pattern, replacement)}
- end)
+ Enum.reduce(
+ Pleroma.Config.get([:mrf_keyword, :replace]),
+ {content, summary},
+ fn {pattern, replacement}, {content_acc, summary_acc} ->
+ {String.replace(content_acc, pattern, replacement),
+ String.replace(summary_acc, pattern, replacement)}
+ end
+ )
{:ok,
message
use Pleroma.Web, :controller
def oauth_scopes(params, default) do
- # Note: `scopes` is used by Mastodon — supporting it but sticking to OAuth's standard `scope` wherever we control it
+ # Note: `scopes` is used by Mastodon — supporting it but sticking to
+ # OAuth's standard `scope` wherever we control it
Pleroma.Web.OAuth.parse_scopes(params["scope"] || params["scopes"], default)
end
from: :pleroma,
only:
~w(index.html static finmoji emoji packs sounds images instance sw.js sw-pleroma.js favicon.png schemas doc)
+ # credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
)
# Code reloading can be explicitly enabled under the
else
secret = Application.get_env(:pleroma, Pleroma.Web.Endpoint)[:secret_key_base]
- # Must preserve `%2F` for compatibility with S3 (https://git.pleroma.social/pleroma/pleroma/issues/580)
+ # Must preserve `%2F` for compatibility with S3
+ # https://git.pleroma.social/pleroma/pleroma/issues/580
replacement = get_replacement(url, ":2F:")
# The URL is url-decoded and encoded again to ensure it is correctly encoded and not twice.
# TODO: Add additional properties to objects when we have the data available.
# Also, Whatsapp only wants JPEG or PNGs. It seems that if we add a second og:image
- # object when a Video or GIF is attached it will display that in the Whatsapp Rich Preview.
+ # object when a Video or GIF is attached it will display that in Whatsapp Rich Preview.
case media_type do
"audio" ->
[
| acc
]
- # TODO: Need the true width and height values here or Twitter renders an iFrame with a bad aspect ratio
+ # TODO: Need the true width and height values here or Twitter renders an iFrame with
+ # a bad aspect ratio
"video" ->
[
{:meta, [property: "twitter:card", content: "player"], []},
end
# Some webpush clients (e.g. iOS Toot!) use an non urlsafe base64 as an encoding for the key.
- # However, the web push rfs specify to use base64 urlsafe, and the `web_push_encryption` library we use
- # requires the key to be properly encoded. So we just convert base64 to urlsafe base64.
+ # However, the web push rfs specify to use base64 urlsafe, and the `web_push_encryption` library
+ # we use requires the key to be properly encoded. So we just convert base64 to urlsafe base64.
defp ensure_base64_urlsafe(string) do
string
|> String.replace("+", "-")
end
end
- # Note: implementation-specific (e.g. Instance) details of set_unreachable/1 should be tested in implementation-specific tests
+ # Note: implementation-specific (e.g. Instance) details of set_unreachable/1
+ # should be tested in implementation-specific tests
describe "set_unreachable/1" do
test "returns error status on non-binary input" do
assert {:error, _} = Instances.set_unreachable(nil)
# Also fetches the feed.
# assert Activity.get_create_by_object_ap_id("tag:mastodon.social,2017-04-05:objectId=1641750:objectType=Status")
+ # credo:disable-for-previous-line Credo.Check.Readability.MaxLineLength
end
end
end