Merge branch 'develop' into activation-meta

This commit is contained in:
Mark Felder 2020-07-02 13:01:22 -05:00
commit 8121e46f25
21 changed files with 882 additions and 113 deletions

View File

@ -17,7 +17,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
<summary>API Changes</summary>
- **Breaking:** Emoji API: changed methods and renamed routes.
- Added `pleroma.metadata.fields_limits` to /api/v1/instance
- Streaming: Repeats of a user's posts will no longer be pushed to the user's stream.
- Mastodon API: Added `pleroma.metadata.fields_limits` to /api/v1/instance
</details>
<details>

View File

@ -40,12 +40,13 @@ config :pleroma, :config_description, [
key: :link_name,
type: :boolean,
description:
"If enabled, a name parameter will be added to the url of the upload. For example `https://instance.tld/media/imagehash.png?name=realname.png`."
"If enabled, a name parameter will be added to the URL of the upload. For example `https://instance.tld/media/imagehash.png?name=realname.png`."
},
%{
key: :base_url,
label: "Base URL",
type: :string,
description: "Base url for the uploads, needed if you use CDN",
description: "Base URL for the uploads, needed if you use CDN",
suggestions: [
"https://cdn-host.com"
]
@ -58,6 +59,7 @@ config :pleroma, :config_description, [
},
%{
key: :proxy_opts,
label: "Proxy Options",
type: :keyword,
description: "Options for Pleroma.ReverseProxy",
suggestions: [
@ -85,6 +87,7 @@ config :pleroma, :config_description, [
},
%{
key: :http,
label: "HTTP",
type: :keyword,
description: "HTTP options",
children: [
@ -479,6 +482,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :uri_schemes,
label: "URI Schemes",
type: :group,
description: "URI schemes related settings",
children: [
@ -651,17 +655,17 @@ config :pleroma, :config_description, [
key: :invites_enabled,
type: :boolean,
description:
"Enable user invitations for admins (depends on `registrations_open` being disabled)."
"Enable user invitations for admins (depends on `registrations_open` being disabled)"
},
%{
key: :account_activation_required,
type: :boolean,
description: "Require users to confirm their emails before signing in."
description: "Require users to confirm their emails before signing in"
},
%{
key: :federating,
type: :boolean,
description: "Enable federation with other instances."
description: "Enable federation with other instances"
},
%{
key: :federation_incoming_replies_max_depth,
@ -679,7 +683,7 @@ config :pleroma, :config_description, [
label: "Fed. reachability timeout days",
type: :integer,
description:
"Timeout (in days) of each external federation target being unreachable prior to pausing federating to it.",
"Timeout (in days) of each external federation target being unreachable prior to pausing federating to it",
suggestions: [
7
]
@ -801,6 +805,7 @@ config :pleroma, :config_description, [
},
%{
key: :safe_dm_mentions,
label: "Safe DM mentions",
type: :boolean,
description:
"If enabled, only mentions at the beginning of a post will be used to address people in direct messages." <>
@ -840,7 +845,7 @@ config :pleroma, :config_description, [
%{
key: :skip_thread_containment,
type: :boolean,
description: "Skip filtering out broken threads. Default: enabled"
description: "Skip filtering out broken threads. Default: enabled."
},
%{
key: :limit_to_local_content,
@ -904,6 +909,7 @@ config :pleroma, :config_description, [
children: [
%{
key: :totp,
label: "TOTP settings",
type: :keyword,
description: "TOTP settings",
suggestions: [digits: 6, period: 30],
@ -920,7 +926,7 @@ config :pleroma, :config_description, [
type: :integer,
suggestions: [30],
description:
"a period for which the TOTP code will be valid, in seconds. Defaults to 30 seconds."
"A period for which the TOTP code will be valid, in seconds. Defaults to 30 seconds."
}
]
},
@ -934,7 +940,7 @@ config :pleroma, :config_description, [
key: :number,
type: :integer,
suggestions: [5],
description: "number of backup codes to generate."
description: "Number of backup codes to generate."
},
%{
key: :length,
@ -974,6 +980,7 @@ config :pleroma, :config_description, [
group: :logger,
type: :group,
key: :ex_syslogger,
label: "ExSyslogger",
description: "ExSyslogger-related settings",
children: [
%{
@ -992,7 +999,7 @@ config :pleroma, :config_description, [
%{
key: :format,
type: :string,
description: "Default: \"$date $time [$level] $levelpad$node $metadata $message\".",
description: "Default: \"$date $time [$level] $levelpad$node $metadata $message\"",
suggestions: ["$metadata[$level] $message"]
},
%{
@ -1006,6 +1013,7 @@ config :pleroma, :config_description, [
group: :logger,
type: :group,
key: :console,
label: "Console Logger",
description: "Console logger settings",
children: [
%{
@ -1017,7 +1025,7 @@ config :pleroma, :config_description, [
%{
key: :format,
type: :string,
description: "Default: \"$date $time [$level] $levelpad$node $metadata $message\".",
description: "Default: \"$date $time [$level] $levelpad$node $metadata $message\"",
suggestions: ["$metadata[$level] $message"]
},
%{
@ -1030,6 +1038,7 @@ config :pleroma, :config_description, [
%{
group: :quack,
type: :group,
label: "Quack Logger",
description: "Quack-related settings",
children: [
%{
@ -1140,19 +1149,19 @@ config :pleroma, :config_description, [
key: :greentext,
label: "Greentext",
type: :boolean,
description: "Enables green text on lines prefixed with the > character."
description: "Enables green text on lines prefixed with the > character"
},
%{
key: :hideFilteredStatuses,
label: "Hide Filtered Statuses",
type: :boolean,
description: "Hides filtered statuses from timelines."
description: "Hides filtered statuses from timelines"
},
%{
key: :hideMutedPosts,
label: "Hide Muted Posts",
type: :boolean,
description: "Hides muted statuses from timelines."
description: "Hides muted statuses from timelines"
},
%{
key: :hidePostStats,
@ -1164,7 +1173,7 @@ config :pleroma, :config_description, [
key: :hideSitename,
label: "Hide Sitename",
type: :boolean,
description: "Hides instance name from PleromaFE banner."
description: "Hides instance name from PleromaFE banner"
},
%{
key: :hideUserStats,
@ -1209,14 +1218,14 @@ config :pleroma, :config_description, [
label: "NSFW Censor Image",
type: :string,
description:
"URL of the image to use for hiding NSFW media attachments in the timeline.",
"URL of the image to use for hiding NSFW media attachments in the timeline",
suggestions: ["/static/img/nsfw.74818f9.png"]
},
%{
key: :postContentType,
label: "Post Content Type",
type: {:dropdown, :atom},
description: "Default post formatting option.",
description: "Default post formatting option",
suggestions: ["text/plain", "text/html", "text/markdown", "text/bbcode"]
},
%{
@ -1245,14 +1254,14 @@ config :pleroma, :config_description, [
key: :sidebarRight,
label: "Sidebar on Right",
type: :boolean,
description: "Change alignment of sidebar and panels to the right."
description: "Change alignment of sidebar and panels to the right"
},
%{
key: :showFeaturesPanel,
label: "Show instance features panel",
type: :boolean,
description:
"Enables panel displaying functionality of the instance on the About page."
"Enables panel displaying functionality of the instance on the About page"
},
%{
key: :showInstanceSpecificPanel,
@ -1310,7 +1319,7 @@ config :pleroma, :config_description, [
key: :mascots,
type: {:keyword, :map},
description:
"Keyword of mascots, each element must contain both an url and a mime_type key",
"Keyword of mascots, each element must contain both an URL and a mime_type key",
suggestions: [
pleroma_fox_tan: %{
url: "/images/pleroma-fox-tan-smol.png",
@ -1334,7 +1343,7 @@ config :pleroma, :config_description, [
%{
key: :default_user_avatar,
type: :string,
description: "URL of the default user avatar.",
description: "URL of the default user avatar",
suggestions: ["/images/avi.png"]
}
]
@ -1344,7 +1353,7 @@ config :pleroma, :config_description, [
key: :manifest,
type: :group,
description:
"This section describe PWA manifest instance-specific values. Currently this option relate only for MastoFE",
"This section describe PWA manifest instance-specific values. Currently this option relate only for MastoFE.",
children: [
%{
key: :icons,
@ -1381,7 +1390,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :mrf_simple,
label: "MRF simple",
label: "MRF Simple",
type: :group,
description: "Message Rewrite Facility",
children: [
@ -1461,7 +1470,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :mrf_subchain,
label: "MRF subchain",
label: "MRF Subchain",
type: :group,
description:
"This policy processes messages through an alternate pipeline when a given message matches certain criteria." <>
@ -1484,7 +1493,7 @@ config :pleroma, :config_description, [
key: :mrf_rejectnonpublic,
description:
"MRF RejectNonPublic settings. RejectNonPublic drops posts with non-public visibility settings.",
label: "MRF reject non public",
label: "MRF Reject Non Public",
type: :group,
children: [
%{
@ -1503,7 +1512,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :mrf_hellthread,
label: "MRF hellthread",
label: "MRF Hellthread",
type: :group,
description: "Block messages with too much mentions",
children: [
@ -1527,7 +1536,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :mrf_keyword,
label: "MRF keyword",
label: "MRF Keyword",
type: :group,
description: "Reject or Word-Replace messages with a keyword or regex",
children: [
@ -1557,14 +1566,14 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :mrf_mention,
label: "MRF mention",
label: "MRF Mention",
type: :group,
description: "Block messages which mention a user",
children: [
%{
key: :actors,
type: {:list, :string},
description: "A list of actors for which any post mentioning them will be dropped.",
description: "A list of actors for which any post mentioning them will be dropped",
suggestions: ["actor1", "actor2"]
}
]
@ -1572,7 +1581,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :mrf_vocabulary,
label: "MRF vocabulary",
label: "MRF Vocabulary",
type: :group,
description: "Filter messages which belong to certain activity vocabularies",
children: [
@ -1580,14 +1589,14 @@ config :pleroma, :config_description, [
key: :accept,
type: {:list, :string},
description:
"A list of ActivityStreams terms to accept. If empty, all supported messages are accepted",
"A list of ActivityStreams terms to accept. If empty, all supported messages are accepted.",
suggestions: ["Create", "Follow", "Mention", "Announce", "Like"]
},
%{
key: :reject,
type: {:list, :string},
description:
"A list of ActivityStreams terms to reject. If empty, no messages are rejected",
"A list of ActivityStreams terms to reject. If empty, no messages are rejected.",
suggestions: ["Create", "Follow", "Mention", "Announce", "Like"]
}
]
@ -1617,6 +1626,7 @@ config :pleroma, :config_description, [
},
%{
key: :base_url,
label: "Base URL",
type: :string,
description:
"The base URL to access a user-uploaded file. Useful when you want to proxy the media files via another host/CDN fronts.",
@ -1649,6 +1659,7 @@ config :pleroma, :config_description, [
},
%{
key: :proxy_opts,
label: "Proxy Options",
type: :keyword,
description: "Options for Pleroma.ReverseProxy",
suggestions: [
@ -1676,6 +1687,7 @@ config :pleroma, :config_description, [
},
%{
key: :http,
label: "HTTP",
type: :keyword,
description: "HTTP options",
children: [
@ -1771,6 +1783,7 @@ config :pleroma, :config_description, [
},
%{
key: :ip,
label: "IP",
type: :tuple,
description: "IP address to bind to",
suggestions: [{0, 0, 0, 0}]
@ -1784,7 +1797,7 @@ config :pleroma, :config_description, [
%{
key: :dstport,
type: :integer,
description: "Port advertised in urls (optional, defaults to port)",
description: "Port advertised in URLs (optional, defaults to port)",
suggestions: [9999]
}
]
@ -1792,6 +1805,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :activitypub,
label: "ActivityPub",
type: :group,
description: "ActivityPub-related settings",
children: [
@ -1814,7 +1828,7 @@ config :pleroma, :config_description, [
key: :note_replies_output_limit,
type: :integer,
description:
"The number of Note replies' URIs to be included with outgoing federation (`5` to match Mastodon hardcoded value, `0` to disable the output)."
"The number of Note replies' URIs to be included with outgoing federation (`5` to match Mastodon hardcoded value, `0` to disable the output)"
},
%{
key: :follow_handshake_timeout,
@ -1827,6 +1841,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :http_security,
label: "HTTP security",
type: :group,
description: "HTTP security settings",
children: [
@ -1865,7 +1880,7 @@ config :pleroma, :config_description, [
key: :report_uri,
label: "Report URI",
type: :string,
description: "Adds the specified url to report-uri and report-to group in CSP header",
description: "Adds the specified URL to report-uri and report-to group in CSP header",
suggestions: ["https://example.com/report-uri"]
}
]
@ -1873,9 +1888,10 @@ config :pleroma, :config_description, [
%{
group: :web_push_encryption,
key: :vapid_details,
label: "Vapid Details",
type: :group,
description:
"Web Push Notifications configuration. You can use the mix task mix web_push.gen.keypair to generate it",
"Web Push Notifications configuration. You can use the mix task mix web_push.gen.keypair to generate it.",
children: [
%{
key: :subject,
@ -1942,6 +1958,7 @@ config :pleroma, :config_description, [
},
%{
group: :pleroma,
label: "Pleroma Admin Token",
type: :group,
description:
"Allows to set a token that can be used to authenticate with the admin api without using an actual user by giving it as the `admin_token` parameter",
@ -1949,7 +1966,7 @@ config :pleroma, :config_description, [
%{
key: :admin_token,
type: :string,
description: "Token",
description: "Admin token",
suggestions: ["We recommend a secure random string or UUID"]
}
]
@ -2114,24 +2131,24 @@ config :pleroma, :config_description, [
key: :rich_media,
type: :group,
description:
"If enabled the instance will parse metadata from attached links to generate link previews.",
"If enabled the instance will parse metadata from attached links to generate link previews",
children: [
%{
key: :enabled,
type: :boolean,
description: "Enables RichMedia parsing of URLs."
description: "Enables RichMedia parsing of URLs"
},
%{
key: :ignore_hosts,
type: {:list, :string},
description: "List of hosts which will be ignored by the metadata parser.",
description: "List of hosts which will be ignored by the metadata parser",
suggestions: ["accounts.google.com", "xss.website"]
},
%{
key: :ignore_tld,
label: "Ignore TLD",
type: {:list, :string},
description: "List TLDs (top-level domains) which will ignore for parse metadata.",
description: "List TLDs (top-level domains) which will ignore for parse metadata",
suggestions: ["local", "localdomain", "lan"]
},
%{
@ -2159,31 +2176,32 @@ config :pleroma, :config_description, [
%{
group: :auto_linker,
key: :opts,
label: "Auto Linker",
type: :group,
description: "Configuration for the auto_linker library",
children: [
%{
key: :class,
type: [:string, false],
description: "Specify the class to be added to the generated link. Disable to clear",
description: "Specify the class to be added to the generated link. Disable to clear.",
suggestions: ["auto-linker", false]
},
%{
key: :rel,
type: [:string, false],
description: "Override the rel attribute. Disable to clear",
description: "Override the rel attribute. Disable to clear.",
suggestions: ["ugc", "noopener noreferrer", false]
},
%{
key: :new_window,
type: :boolean,
description: "Link urls will open in new window/tab"
description: "Link URLs will open in new window/tab"
},
%{
key: :truncate,
type: [:integer, false],
description:
"Set to a number to truncate urls longer then the number. Truncated urls will end in `..`",
"Set to a number to truncate URLs longer then the number. Truncated URLs will end in `..`",
suggestions: [15, false]
},
%{
@ -2194,7 +2212,7 @@ config :pleroma, :config_description, [
%{
key: :extra,
type: :boolean,
description: "Link urls with rarely used schemes (magnet, ipfs, irc, etc.)"
description: "Link URLs with rarely used schemes (magnet, ipfs, irc, etc.)"
}
]
},
@ -2240,6 +2258,7 @@ config :pleroma, :config_description, [
},
%{
group: :pleroma,
label: "Pleroma Authenticator",
type: :group,
description: "Authenticator",
children: [
@ -2253,6 +2272,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :ldap,
label: "LDAP",
type: :group,
description:
"Use LDAP for user authentication. When a user logs in to the Pleroma instance, the name and password" <>
@ -2339,6 +2359,7 @@ config :pleroma, :config_description, [
},
%{
key: :uid,
label: "UID",
type: :string,
description:
"LDAP attribute name to authenticate the user, e.g. when \"cn\", the filter will be \"cn=username,base\"",
@ -2354,11 +2375,12 @@ config :pleroma, :config_description, [
children: [
%{
key: :enforce_oauth_admin_scope_usage,
label: "Enforce OAuth admin scope usage",
type: :boolean,
description:
"OAuth admin scope requirement toggle. " <>
"If enabled, admin actions explicitly demand admin OAuth scope(s) presence in OAuth token " <>
"(client app must support admin scopes). If disabled and token doesn't have admin scope(s)," <>
"(client app must support admin scopes). If disabled and token doesn't have admin scope(s), " <>
"`is_admin` user flag grants access to admin-specific actions."
},
%{
@ -2370,6 +2392,7 @@ config :pleroma, :config_description, [
},
%{
key: :oauth_consumer_template,
label: "OAuth consumer template",
type: :string,
description:
"OAuth consumer mode authentication form template. By default it's `consumer.html` which corresponds to" <>
@ -2378,6 +2401,7 @@ config :pleroma, :config_description, [
},
%{
key: :oauth_consumer_strategies,
label: "OAuth consumer strategies",
type: {:list, :string},
description:
"The list of enabled OAuth consumer strategies. By default it's set by OAUTH_CONSUMER_STRATEGIES environment variable." <>
@ -2506,7 +2530,7 @@ config :pleroma, :config_description, [
%{
key: :enabled,
type: :boolean,
description: "enables new users admin digest email when `true`",
description: "Enables new users admin digest email when `true`",
suggestions: [false]
}
]
@ -2514,6 +2538,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :oauth2,
label: "OAuth2",
type: :group,
description: "Configure OAuth 2 provider capabilities",
children: [
@ -2532,7 +2557,7 @@ config :pleroma, :config_description, [
%{
key: :clean_expired_tokens,
type: :boolean,
description: "Enable a background job to clean expired oauth tokens. Default: disabled."
description: "Enable a background job to clean expired OAuth tokens. Default: disabled."
}
]
},
@ -2616,6 +2641,7 @@ config :pleroma, :config_description, [
},
%{
key: :relation_id_action,
label: "Relation ID action",
type: [:tuple, {:list, :tuple}],
description: "For actions on relation with a specific user (follow, unfollow)",
suggestions: [{1000, 10}, [{10_000, 10}, {10_000, 50}]]
@ -2629,6 +2655,7 @@ config :pleroma, :config_description, [
},
%{
key: :status_id_action,
label: "Status ID action",
type: [:tuple, {:list, :tuple}],
description:
"For fav / unfav or reblog / unreblog actions on the same status by the same user",
@ -2644,6 +2671,7 @@ config :pleroma, :config_description, [
},
%{
group: :esshd,
label: "ESSHD",
type: :group,
description:
"Before enabling this you must add :esshd to mix.exs as one of the extra_applications " <>
@ -2682,8 +2710,9 @@ config :pleroma, :config_description, [
},
%{
group: :mime,
label: "Mime Types",
type: :group,
description: "Mime types",
description: "Mime Types settings",
children: [
%{
key: :types,
@ -2742,6 +2771,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :http,
label: "HTTP",
type: :group,
description: "HTTP settings",
children: [
@ -2790,6 +2820,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :markup,
label: "Markup Settings",
type: :group,
children: [
%{
@ -2831,7 +2862,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :mrf_normalize_markup,
label: "MRF normalize markup",
label: "MRF Normalize Markup",
description: "MRF NormalizeMarkup settings. Scrub configured hypertext markup.",
type: :group,
children: [
@ -2887,6 +2918,7 @@ config :pleroma, :config_description, [
},
%{
group: :cors_plug,
label: "CORS plug config",
type: :group,
children: [
%{
@ -2959,6 +2991,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :web_cache_ttl,
label: "Web cache TTL",
type: :group,
description:
"The expiration time for the web responses cache. Values should be in milliseconds or `nil` to disable expiration.",
@ -2981,9 +3014,10 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :static_fe,
label: "Static FE",
type: :group,
description:
"Render profiles and posts using server-generated HTML that is viewable without using JavaScript.",
"Render profiles and posts using server-generated HTML that is viewable without using JavaScript",
children: [
%{
key: :enabled,
@ -3001,18 +3035,18 @@ config :pleroma, :config_description, [
%{
key: :post_title,
type: :map,
description: "Configure title rendering.",
description: "Configure title rendering",
children: [
%{
key: :max_length,
type: :integer,
description: "Maximum number of characters before truncating title.",
description: "Maximum number of characters before truncating title",
suggestions: [100]
},
%{
key: :omission,
type: :string,
description: "Replacement which will be used after truncating string.",
description: "Replacement which will be used after truncating string",
suggestions: ["..."]
}
]
@ -3022,6 +3056,7 @@ config :pleroma, :config_description, [
%{
group: :pleroma,
key: :mrf_object_age,
label: "MRF Object Age",
type: :group,
description: "Rejects or delists posts based on their age when received.",
children: [
@ -3064,13 +3099,13 @@ config :pleroma, :config_description, [
%{
key: :workers,
type: :integer,
description: "Number of workers to send notifications.",
description: "Number of workers to send notifications",
suggestions: [3]
},
%{
key: :overflow_workers,
type: :integer,
description: "Maximum number of workers created if pool is empty.",
description: "Maximum number of workers created if pool is empty",
suggestions: [2]
}
]

View File

@ -115,7 +115,7 @@ defmodule Pleroma.User do
field(:is_moderator, :boolean, default: false)
field(:is_admin, :boolean, default: false)
field(:show_role, :boolean, default: true)
field(:settings, :map, default: nil)
field(:mastofe_settings, :map, default: nil)
field(:uri, ObjectValidators.Uri, default: nil)
field(:hide_followers_count, :boolean, default: false)
field(:hide_follows_count, :boolean, default: false)
@ -2118,8 +2118,8 @@ defmodule Pleroma.User do
def mastodon_settings_update(user, settings) do
user
|> cast(%{settings: settings}, [:settings])
|> validate_required([:settings])
|> cast(%{mastofe_settings: settings}, [:mastofe_settings])
|> validate_required([:mastofe_settings])
|> update_and_set_cache()
end

View File

@ -1371,6 +1371,16 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
end
end
def maybe_handle_clashing_nickname(nickname) do
with %User{} = old_user <- User.get_by_nickname(nickname) do
Logger.info("Found an old user for #{nickname}, ap id is #{old_user.ap_id}, renaming.")
old_user
|> User.remote_user_changeset(%{nickname: "#{old_user.id}.#{old_user.nickname}"})
|> User.update_and_set_cache()
end
end
def make_user_from_ap_id(ap_id) do
user = User.get_cached_by_ap_id(ap_id)
@ -1383,6 +1393,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|> User.remote_user_changeset(data)
|> User.update_and_set_cache()
else
maybe_handle_clashing_nickname(data[:nickname])
data
|> User.remote_user_changeset()
|> Repo.insert()

View File

@ -6,6 +6,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
collection, and so on.
"""
alias Pleroma.Activity
alias Pleroma.Activity.Ir.Topics
alias Pleroma.Chat
alias Pleroma.Chat.MessageReference
alias Pleroma.Notification
@ -97,7 +98,10 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
if !User.is_internal_user?(user) do
Notification.create_notifications(object)
ActivityPub.stream_out(object)
object
|> Topics.get_activity_topics()
|> Streamer.stream(object)
end
{:ok, object, meta}

View File

@ -446,12 +446,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
when objtype in ["Article", "Event", "Note", "Video", "Page", "Question", "Answer", "Audio"] do
actor = Containment.get_actor(data)
data =
Map.put(data, "actor", actor)
|> fix_addressing
with nil <- Activity.get_create_by_object_ap_id(object["id"]),
{:ok, %User{} = user} <- User.get_or_fetch_by_ap_id(data["actor"]) do
{:ok, %User{} = user} <- User.get_or_fetch_by_ap_id(actor),
data <- Map.put(data, "actor", actor) |> fix_addressing() do
object = fix_object(object, options)
params = %{

View File

@ -116,6 +116,7 @@ defmodule Pleroma.Web.Streamer do
true <-
Enum.all?([blocked_ap_ids, muted_ap_ids], &(item.actor not in &1)),
true <- item.data["type"] != "Announce" || item.actor not in reblog_muted_ap_ids,
true <- !(item.data["type"] == "Announce" && parent.data["actor"] == user.ap_id),
true <- Enum.all?([blocked_ap_ids, muted_ap_ids], &(parent.data["actor"] not in &1)),
true <- MapSet.disjoint?(recipients, recipient_blocks),
%{host: item_host} <- URI.parse(item.actor),

View File

@ -86,7 +86,7 @@ defmodule Pleroma.Web.MastoFEView do
"video\/mp4"
]
},
settings: user.settings || @default_settings,
settings: user.mastofe_settings || @default_settings,
push_subscription: nil,
accounts: %{user.id => render(AccountView, "show.json", user: user, for: user)},
custom_emojis: render(CustomEmojiView, "index.json", custom_emojis: custom_emojis),

View File

@ -0,0 +1,11 @@
defmodule Pleroma.Repo.Migrations.RenameUserSettingsCol do
use Ecto.Migration
def up do
rename(table(:users), :settings, to: :mastofe_settings)
end
def down do
rename(table(:users), :mastofe_settings, to: :settings)
end
end

View File

@ -0,0 +1,72 @@
{
"@context" : [
"https://www.w3.org/ns/activitystreams",
{
"atomUri" : "ostatus:atomUri",
"conversation" : "ostatus:conversation",
"inReplyToAtomUri" : "ostatus:inReplyToAtomUri",
"ostatus" : "http://ostatus.org#",
"sensitive" : "as:sensitive",
"toot" : "http://joinmastodon.org/ns#",
"votersCount" : "toot:votersCount"
}
],
"atomUri" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069",
"attachment" : [],
"attributedTo" : "https://busshi.moe/users/tuxcrafting",
"cc" : [
"https://busshi.moe/users/tuxcrafting/followers",
"https://stereophonic.space/users/fixpoint",
"https://blob.cat/users/blobyoumu",
"https://cawfee.club/users/grips",
"https://jaeger.website/users/igel"
],
"content" : "<p><span class=\"h-card\"><a href=\"https://stereophonic.space/users/fixpoint\" class=\"u-url mention\">@<span>fixpoint</span></a></span> <span class=\"h-card\"><a href=\"https://blob.cat/users/blobyoumu\" class=\"u-url mention\">@<span>blobyoumu</span></a></span> <span class=\"h-card\"><a href=\"https://cawfee.club/users/grips\" class=\"u-url mention\">@<span>grips</span></a></span> <span class=\"h-card\"><a href=\"https://jaeger.website/users/igel\" class=\"u-url mention\">@<span>igel</span></a></span> there&apos;s a difference between not liking nukes and not liking nuclear power<br />nukes are pretty bad as are all WMDs in general but disliking nuclear power just indicates you are unable of thought</p>",
"contentMap" : {
"en" : "<p><span class=\"h-card\"><a href=\"https://stereophonic.space/users/fixpoint\" class=\"u-url mention\">@<span>fixpoint</span></a></span> <span class=\"h-card\"><a href=\"https://blob.cat/users/blobyoumu\" class=\"u-url mention\">@<span>blobyoumu</span></a></span> <span class=\"h-card\"><a href=\"https://cawfee.club/users/grips\" class=\"u-url mention\">@<span>grips</span></a></span> <span class=\"h-card\"><a href=\"https://jaeger.website/users/igel\" class=\"u-url mention\">@<span>igel</span></a></span> there&apos;s a difference between not liking nukes and not liking nuclear power<br />nukes are pretty bad as are all WMDs in general but disliking nuclear power just indicates you are unable of thought</p>"
},
"conversation" : "https://cawfee.club/contexts/ad6c73d8-efc2-4e74-84ea-2dacf1a27a5e",
"id" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069",
"inReplyTo" : "https://stereophonic.space/objects/02997b83-3ea7-4b63-94af-ef3aa2d4ed17",
"inReplyToAtomUri" : "https://stereophonic.space/objects/02997b83-3ea7-4b63-94af-ef3aa2d4ed17",
"published" : "2020-06-26T15:10:19Z",
"replies" : {
"first" : {
"items" : [],
"next" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069/replies?only_other_accounts=true&page=true",
"partOf" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069/replies",
"type" : "CollectionPage"
},
"id" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069/replies",
"type" : "Collection"
},
"sensitive" : false,
"summary" : null,
"tag" : [
{
"href" : "https://stereophonic.space/users/fixpoint",
"name" : "@fixpoint@stereophonic.space",
"type" : "Mention"
},
{
"href" : "https://blob.cat/users/blobyoumu",
"name" : "@blobyoumu@blob.cat",
"type" : "Mention"
},
{
"href" : "https://cawfee.club/users/grips",
"name" : "@grips@cawfee.club",
"type" : "Mention"
},
{
"href" : "https://jaeger.website/users/igel",
"name" : "@igel@jaeger.website",
"type" : "Mention"
}
],
"to" : [
"https://www.w3.org/ns/activitystreams#Public"
],
"type" : "Note",
"url" : "https://busshi.moe/@tuxcrafting/104410921027210069"
}

View File

@ -0,0 +1,59 @@
{
"@context" : [
"https://www.w3.org/ns/activitystreams",
"https://social.sakamoto.gq/schemas/litepub-0.1.jsonld",
{
"@language" : "und"
}
],
"actor" : "https://social.sakamoto.gq/users/eal",
"attachment" : [],
"attributedTo" : "https://social.sakamoto.gq/users/eal",
"cc" : [
"https://social.sakamoto.gq/users/eal/followers"
],
"content" : "<span class=\"h-card\"><a data-user=\"9uw2wH0iTYAMV7XnLU\" class=\"u-url mention\" href=\"https://busshi.moe/@tuxcrafting\" rel=\"ugc\">@<span>tuxcrafting</span></a></span> <span class=\"h-card\"><a data-user=\"9r5l8j8x23NI9KUFu4\" class=\"u-url mention\" href=\"https://stereophonic.space/users/fixpoint\" rel=\"ugc\">@<span>fixpoint</span></a></span> <span class=\"h-card\"><a data-user=\"9orDK545JwjY4Lxjge\" class=\"u-url mention\" href=\"https://blob.cat/users/blobyoumu\" rel=\"ugc\">@<span>blobyoumu</span></a></span> <span class=\"h-card\"><a data-user=\"68184\" class=\"u-url mention\" href=\"https://cawfee.club/users/grips\" rel=\"ugc\">@<span>grips</span></a></span> <span class=\"h-card\"><a data-user=\"9sAmMgHVKjTXKpgx84\" class=\"u-url mention\" href=\"https://jaeger.website/users/igel\" rel=\"ugc\">@<span>igel</span></a></span> What&#39;s bad about nukes?",
"context" : "https://cawfee.club/contexts/ad6c73d8-efc2-4e74-84ea-2dacf1a27a5e",
"conversation" : "https://cawfee.club/contexts/ad6c73d8-efc2-4e74-84ea-2dacf1a27a5e",
"id" : "https://social.sakamoto.gq/objects/f20f2497-66d9-4a52-a2e1-1be2a39c32c1",
"inReplyTo" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069",
"published" : "2020-06-26T15:20:15.975737Z",
"sensitive" : false,
"summary" : "",
"tag" : [
{
"href" : "https://blob.cat/users/blobyoumu",
"name" : "@blobyoumu@blob.cat",
"type" : "Mention"
},
{
"href" : "https://busshi.moe/users/tuxcrafting",
"name" : "@tuxcrafting@busshi.moe",
"type" : "Mention"
},
{
"href" : "https://cawfee.club/users/grips",
"name" : "@grips@cawfee.club",
"type" : "Mention"
},
{
"href" : "https://jaeger.website/users/igel",
"name" : "@igel@jaeger.website",
"type" : "Mention"
},
{
"href" : "https://stereophonic.space/users/fixpoint",
"name" : "@fixpoint@stereophonic.space",
"type" : "Mention"
}
],
"to" : [
"https://busshi.moe/users/tuxcrafting",
"https://www.w3.org/ns/activitystreams#Public",
"https://blob.cat/users/blobyoumu",
"https://stereophonic.space/users/fixpoint",
"https://cawfee.club/users/grips",
"https://jaeger.website/users/igel"
],
"type" : "Note"
}

43
test/fixtures/fetch_mocks/eal.json vendored Normal file
View File

@ -0,0 +1,43 @@
{
"@context" : [
"https://www.w3.org/ns/activitystreams",
"https://social.sakamoto.gq/schemas/litepub-0.1.jsonld",
{
"@language" : "und"
}
],
"attachment" : [],
"discoverable" : true,
"endpoints" : {
"oauthAuthorizationEndpoint" : "https://social.sakamoto.gq/oauth/authorize",
"oauthRegistrationEndpoint" : "https://social.sakamoto.gq/api/v1/apps",
"oauthTokenEndpoint" : "https://social.sakamoto.gq/oauth/token",
"sharedInbox" : "https://social.sakamoto.gq/inbox",
"uploadMedia" : "https://social.sakamoto.gq/api/ap/upload_media"
},
"followers" : "https://social.sakamoto.gq/users/eal/followers",
"following" : "https://social.sakamoto.gq/users/eal/following",
"icon" : {
"type" : "Image",
"url" : "https://social.sakamoto.gq/media/f1cb6f79bf6839f3223ca240441f766056b74ddd23c69bcaf8bb1ba1ecff6eec.jpg"
},
"id" : "https://social.sakamoto.gq/users/eal",
"image" : {
"type" : "Image",
"url" : "https://social.sakamoto.gq/media/e5cccf26421e8366f4e34be3c9d5042b8bc8dcceccc7c8e89785fa312dd9632c.jpg"
},
"inbox" : "https://social.sakamoto.gq/users/eal/inbox",
"manuallyApprovesFollowers" : false,
"name" : "에알",
"outbox" : "https://social.sakamoto.gq/users/eal/outbox",
"preferredUsername" : "eal",
"publicKey" : {
"id" : "https://social.sakamoto.gq/users/eal#main-key",
"owner" : "https://social.sakamoto.gq/users/eal",
"publicKeyPem" : "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz3pF85YOhhv2Zaxv9YQ7\nrCe1aEhetCMVHtrK63tUVGoGdsblyKnVeJNbFcr6k3y35OpHS3HXIi6GzgihYcTu\nONLP4eQMHTnLUNAQZi03mjJA4iIq8v/tm8ZkL2mXsQSAbWj6Iq518mHNN7OvCoNt\n3Xjepl/0kgkc2gsund7m8r+Wu0Fusx6UlUyyAk3PexdDRdSSlVLeskqtP8jtdQDo\nL70pMyL+VD+Qb9RKFdtgJ+M4OqYP+7FVzCqXN0QIPhFf/kvHSLr+c4Y3Wm0nAKHU\n9CwXWXz5Xqscpv41KlgnUCOkTXb5eBSt23lNulae5srVzWBiFb6guiCpNzBGa+Sq\nrwIDAQAB\n-----END PUBLIC KEY-----\n\n"
},
"summary" : "Pizza napoletana supremacist.<br><br>Any artworks posted here that are good are not mine.",
"tag" : [],
"type" : "Person",
"url" : "https://social.sakamoto.gq/users/eal"
}

View File

@ -0,0 +1,59 @@
{
"@context" : [
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
{
"IdentityProof" : "toot:IdentityProof",
"PropertyValue" : "schema:PropertyValue",
"alsoKnownAs" : {
"@id" : "as:alsoKnownAs",
"@type" : "@id"
},
"discoverable" : "toot:discoverable",
"featured" : {
"@id" : "toot:featured",
"@type" : "@id"
},
"focalPoint" : {
"@container" : "@list",
"@id" : "toot:focalPoint"
},
"manuallyApprovesFollowers" : "as:manuallyApprovesFollowers",
"movedTo" : {
"@id" : "as:movedTo",
"@type" : "@id"
},
"schema" : "http://schema.org#",
"toot" : "http://joinmastodon.org/ns#",
"value" : "schema:value"
}
],
"attachment" : [],
"discoverable" : true,
"endpoints" : {
"sharedInbox" : "https://busshi.moe/inbox"
},
"featured" : "https://busshi.moe/users/tuxcrafting/collections/featured",
"followers" : "https://busshi.moe/users/tuxcrafting/followers",
"following" : "https://busshi.moe/users/tuxcrafting/following",
"icon" : {
"mediaType" : "image/jpeg",
"type" : "Image",
"url" : "https://blobcdn.busshi.moe/busshifiles/accounts/avatars/000/046/872/original/054f0806ccb303d0.jpg"
},
"id" : "https://busshi.moe/users/tuxcrafting",
"inbox" : "https://busshi.moe/users/tuxcrafting/inbox",
"manuallyApprovesFollowers" : true,
"name" : "@tuxcrafting@localhost:8080",
"outbox" : "https://busshi.moe/users/tuxcrafting/outbox",
"preferredUsername" : "tuxcrafting",
"publicKey" : {
"id" : "https://busshi.moe/users/tuxcrafting#main-key",
"owner" : "https://busshi.moe/users/tuxcrafting",
"publicKeyPem" : "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWWTBf9OizsBiBhGS/M\nQTT6fB1VvQP6vvxouGZ5cGg1a97V67ouhjJ+nGMuWr++DNYjJYkk2TOynfykk0H/\n8rRSujSe3BNRKYGNzdnRJu/4XxgIE847Fqx5SijSP23JGYcn8TjeSUsN2u2YYVXK\n+Eb3Bu7DjGiqwNon6YB0h5qkGjkMSMVIFn0hZx6Z21bkfYWgra96Ok5OWf7Ck3je\nCuErlCMZcbQcHtFpBueJAxYchjNvm6fqwZxLX/NtaHdr7Fm2kin89mqzliapBlFH\nCXk7Jln6xV5I6ryggPAMzm3fuHzeo0RWlu8lrxLfARBVwaQQZS99bwqp6N9O2aUp\nYwIDAQAB\n-----END PUBLIC KEY-----\n"
},
"summary" : "<p>expert procrastinator</p><p>trans(humanist|gender|istorized)</p><p>web: <a href=\"https://tuxcrafting.port0.org\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">tuxcrafting.port0.org</span><span class=\"invisible\"></span></a><br />pronouns: she/they<br />languages: french (native)/english (fluent)/hebrew (ok-ish)/esperanto (barely)</p>",
"tag" : [],
"type" : "Person",
"url" : "https://busshi.moe/@tuxcrafting"
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,46 @@ defmodule Pleroma.Object.FetcherTest do
:ok
end
describe "error cases" do
setup do
mock(fn
%{method: :get, url: "https://social.sakamoto.gq/notice/9wTkLEnuq47B25EehM"} ->
%Tesla.Env{
status: 200,
body: File.read!("test/fixtures/fetch_mocks/9wTkLEnuq47B25EehM.json")
}
%{method: :get, url: "https://social.sakamoto.gq/users/eal"} ->
%Tesla.Env{
status: 200,
body: File.read!("test/fixtures/fetch_mocks/eal.json")
}
%{method: :get, url: "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069"} ->
%Tesla.Env{
status: 200,
body: File.read!("test/fixtures/fetch_mocks/104410921027210069.json")
}
%{method: :get, url: "https://busshi.moe/users/tuxcrafting"} ->
%Tesla.Env{
status: 500
}
end)
:ok
end
@tag capture_log: true
test "it works when fetching the OP actor errors out" do
# Here we simulate a case where the author of the OP can't be read
assert {:ok, _} =
Fetcher.fetch_object_from_id(
"https://social.sakamoto.gq/notice/9wTkLEnuq47B25EehM"
)
end
end
describe "max thread distance restriction" do
@ap_id "http://mastodon.example.org/@admin/99541947525187367"
setup do: clear_config([:instance, :federation_incoming_replies_max_depth])

View File

@ -597,6 +597,31 @@ defmodule Pleroma.UserTest do
refute user.last_refreshed_at == orig_user.last_refreshed_at
end
test "if nicknames clash, the old user gets a prefix with the old id to the nickname" do
a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800)
orig_user =
insert(
:user,
local: false,
nickname: "admin@mastodon.example.org",
ap_id: "http://mastodon.example.org/users/harinezumigari",
last_refreshed_at: a_week_ago
)
assert orig_user.last_refreshed_at == a_week_ago
{:ok, user} = User.get_or_fetch_by_ap_id("http://mastodon.example.org/users/admin")
assert user.inbox
refute user.id == orig_user.id
orig_user = User.get_by_id(orig_user.id)
assert orig_user.nickname == "#{orig_user.id}.admin@mastodon.example.org"
end
@tag capture_log: true
test "it returns the old user if stale, but unfetchable" do
a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800)

View File

@ -589,10 +589,29 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
end
test "it streams out the announce", %{announce: announce} do
with_mock Pleroma.Web.ActivityPub.ActivityPub, [:passthrough], stream_out: fn _ -> nil end do
with_mocks([
{
Pleroma.Web.Streamer,
[],
[
stream: fn _, _ -> nil end
]
},
{
Pleroma.Web.Push,
[],
[
send: fn _ -> nil end
]
}
]) do
{:ok, announce, _} = SideEffects.handle(announce)
assert called(Pleroma.Web.ActivityPub.ActivityPub.stream_out(announce))
assert called(
Pleroma.Web.Streamer.stream(["user", "list", "public", "public:local"], announce)
)
assert called(Pleroma.Web.Push.send(:_))
end
end
end

View File

@ -24,7 +24,7 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEController do
assert _result = json_response(conn, 200)
user = User.get_cached_by_ap_id(user.ap_id)
assert user.settings == %{"programming" => "socks"}
assert user.mastofe_settings == %{"programming" => "socks"}
end
describe "index/2 redirections" do

View File

@ -216,20 +216,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
filename: "an_image.jpg"
}
res =
conn
|> patch("/api/v1/accounts/update_credentials", %{"avatar" => new_avatar})
conn = patch(conn, "/api/v1/accounts/update_credentials", %{"avatar" => new_avatar})
assert user_response = json_response_and_validate_schema(res, 200)
assert user_response = json_response_and_validate_schema(conn, 200)
assert user_response["avatar"] != User.avatar_url(user)
# Also removes it
res =
conn
|> patch("/api/v1/accounts/update_credentials", %{"avatar" => nil})
assert user_response = json_response_and_validate_schema(res, 200)
assert user_response["avatar"] == User.avatar_url(user)
end
test "updates the user's banner", %{user: user, conn: conn} do
@ -239,21 +229,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
filename: "an_image.jpg"
}
res =
conn
|> patch("/api/v1/accounts/update_credentials", %{"header" => new_header})
conn = patch(conn, "/api/v1/accounts/update_credentials", %{"header" => new_header})
assert user_response = json_response_and_validate_schema(res, 200)
assert user_response = json_response_and_validate_schema(conn, 200)
assert user_response["header"] != User.banner_url(user)
# Also removes it
res =
conn
|> patch("/api/v1/accounts/update_credentials", %{"header" => nil})
assert user_response = json_response_and_validate_schema(res, 200)
assert user_response["header"] == User.banner_url(user)
end
test "updates the user's background", %{conn: conn} do
@ -263,25 +242,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
filename: "an_image.jpg"
}
res =
conn
|> patch("/api/v1/accounts/update_credentials", %{
conn =
patch(conn, "/api/v1/accounts/update_credentials", %{
"pleroma_background_image" => new_header
})
assert user_response = json_response_and_validate_schema(res, 200)
assert user_response = json_response_and_validate_schema(conn, 200)
assert user_response["pleroma"]["background_image"]
# Also removes it
res =
conn
|> patch("/api/v1/accounts/update_credentials", %{
"pleroma_background_image" => nil
})
assert user_response = json_response_and_validate_schema(res, 200)
refute user_response["pleroma"]["background_image"]
end
test "requires 'write:accounts' permission" do

View File

@ -116,6 +116,18 @@ defmodule Pleroma.Web.StreamerTest do
refute Streamer.filtered_by_user?(user, announce)
end
test "it does not stream announces of the user's own posts in the 'user' stream", %{
user: user
} do
Streamer.get_topic_and_add_socket("user", user)
other_user = insert(:user)
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
{:ok, announce} = CommonAPI.repeat(activity.id, other_user)
assert Streamer.filtered_by_user?(user, announce)
end
test "it streams boosts of mastodon user in the 'user' stream", %{user: user} do
Streamer.get_topic_and_add_socket("user", user)