Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into frontend-bundles-downloads
This commit is contained in:
commit
c1d51944c7
|
@ -27,8 +27,6 @@ erl_crash.dump
|
||||||
# variables.
|
# variables.
|
||||||
/config/*.secret.exs
|
/config/*.secret.exs
|
||||||
/config/generated_config.exs
|
/config/generated_config.exs
|
||||||
/config/*.env
|
|
||||||
|
|
||||||
|
|
||||||
# Database setup file, some may forget to delete it
|
# Database setup file, some may forget to delete it
|
||||||
/config/setup_db.psql
|
/config/setup_db.psql
|
||||||
|
|
|
@ -22,6 +22,7 @@ stages:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
- apt-get update && apt-get install -y cmake
|
||||||
- mix local.hex --force
|
- mix local.hex --force
|
||||||
- mix local.rebar --force
|
- mix local.rebar --force
|
||||||
|
|
||||||
|
@ -193,6 +194,7 @@ amd64:
|
||||||
variables: &release-variables
|
variables: &release-variables
|
||||||
MIX_ENV: prod
|
MIX_ENV: prod
|
||||||
before_script: &before-release
|
before_script: &before-release
|
||||||
|
- apt-get update && apt-get install -y cmake
|
||||||
- echo "import Mix.Config" > config/prod.secret.exs
|
- echo "import Mix.Config" > config/prod.secret.exs
|
||||||
- mix local.hex --force
|
- mix local.hex --force
|
||||||
- mix local.rebar --force
|
- mix local.rebar --force
|
||||||
|
@ -211,7 +213,7 @@ amd64-musl:
|
||||||
cache: *release-cache
|
cache: *release-cache
|
||||||
variables: *release-variables
|
variables: *release-variables
|
||||||
before_script: &before-release-musl
|
before_script: &before-release-musl
|
||||||
- apk add git gcc g++ musl-dev make
|
- apk add git gcc g++ musl-dev make cmake
|
||||||
- echo "import Mix.Config" > config/prod.secret.exs
|
- echo "import Mix.Config" > config/prod.secret.exs
|
||||||
- mix local.hex --force
|
- mix local.hex --force
|
||||||
- mix local.rebar --force
|
- mix local.rebar --force
|
||||||
|
|
20
CHANGELOG.md
20
CHANGELOG.md
|
@ -6,15 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
## [unreleased]
|
## [unreleased]
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- **Breaking:** The default descriptions on uploads are now empty. The old behavior (filename as default) can be configured, see the cheat sheet.
|
||||||
|
- **Breaking:** Added the ObjectAgePolicy to the default set of MRFs. This will delist and strip the follower collection of any message received that is older than 7 days. This will stop users from seeing very old messages in the timelines. The messages can still be viewed on the user's page and in conversations. They also still trigger notifications.
|
||||||
- **Breaking:** Elixir >=1.9 is now required (was >= 1.8)
|
- **Breaking:** Elixir >=1.9 is now required (was >= 1.8)
|
||||||
- **Breaking:** Configuration: `:auto_linker, :opts` moved to `:pleroma, Pleroma.Formatter`. Old config namespace is deprecated.
|
- **Breaking:** Configuration: `:auto_linker, :opts` moved to `:pleroma, Pleroma.Formatter`. Old config namespace is deprecated.
|
||||||
|
- **Breaking:** Configuration: `:instance, welcome_user_nickname` moved to `:welcome, :direct_message, :sender_nickname`, `:instance, :welcome_message` moved to `:welcome, :direct_message, :message`. Old config namespace is deprecated.
|
||||||
|
- **Breaking:** LDAP: Fallback to local database authentication has been removed for security reasons and lack of a mechanism to ensure the passwords are synchronized when LDAP passwords are updated.
|
||||||
|
- **Breaking** Changed defaults for `:restrict_unauthenticated` so that when `:instance, :public` is set to `false` then all `:restrict_unauthenticated` items be effectively set to `true`. If you'd like to allow unauthenticated access to specific API endpoints on a private instance, please explicitly set `:restrict_unauthenticated` to non-default value in `config/prod.secret.exs`.
|
||||||
- In Conversations, return only direct messages as `last_status`
|
- In Conversations, return only direct messages as `last_status`
|
||||||
- Using the `only_media` filter on timelines will now exclude reblog media
|
- Using the `only_media` filter on timelines will now exclude reblog media
|
||||||
- MFR policy to set global expiration for all local Create activities
|
- MFR policy to set global expiration for all local Create activities
|
||||||
- OGP rich media parser merged with TwitterCard
|
- OGP rich media parser merged with TwitterCard
|
||||||
- Configuration: `:instance, rewrite_policy` moved to `:mrf, policies`, `:instance, :mrf_transparency` moved to `:mrf, :transparency`, `:instance, :mrf_transparency_exclusions` moved to `:mrf, :transparency_exclusions`. Old config namespace is deprecated.
|
- Configuration: `:instance, rewrite_policy` moved to `:mrf, policies`, `:instance, :mrf_transparency` moved to `:mrf, :transparency`, `:instance, :mrf_transparency_exclusions` moved to `:mrf, :transparency_exclusions`. Old config namespace is deprecated.
|
||||||
- Configuration: `:media_proxy, whitelist` format changed to host with scheme (e.g. `http://example.com` instead of `example.com`). Domain format is deprecated.
|
- Configuration: `:media_proxy, whitelist` format changed to host with scheme (e.g. `http://example.com` instead of `example.com`). Domain format is deprecated.
|
||||||
- **Breaking:** Configuration: `:instance, welcome_user_nickname` moved to `:welcome, :direct_message, :sender_nickname`, `:instance, :welcome_message` moved to `:welcome, :direct_message, :message`. Old config namespace is deprecated.
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>API Changes</summary>
|
<summary>API Changes</summary>
|
||||||
|
@ -22,29 +27,30 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- **Breaking:** Pleroma API: The routes to update avatar, banner and background have been removed.
|
- **Breaking:** Pleroma API: The routes to update avatar, banner and background have been removed.
|
||||||
- **Breaking:** Image description length is limited now.
|
- **Breaking:** Image description length is limited now.
|
||||||
- **Breaking:** Emoji API: changed methods and renamed routes.
|
- **Breaking:** Emoji API: changed methods and renamed routes.
|
||||||
|
- **Breaking:** Notification Settings API for suppressing notifications has been simplified down to `block_from_strangers`.
|
||||||
|
- **Breaking:** Notification Settings API option for hiding push notification contents has been renamed to `hide_notification_contents`.
|
||||||
- MastodonAPI: Allow removal of avatar, banner and background.
|
- MastodonAPI: Allow removal of avatar, banner and background.
|
||||||
- Streaming: Repeats of a user's posts will no longer be pushed to the user's stream.
|
- 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
|
- Mastodon API: Added `pleroma.metadata.fields_limits` to /api/v1/instance
|
||||||
- Mastodon API: On deletion, returns the original post text.
|
- Mastodon API: On deletion, returns the original post text.
|
||||||
- Mastodon API: Add `pleroma.unread_count` to the Marker entity.
|
- Mastodon API: Add `pleroma.unread_count` to the Marker entity.
|
||||||
- **Breaking:** Notification Settings API for suppressing notifications
|
|
||||||
has been simplified down to `block_from_strangers`.
|
|
||||||
- **Breaking:** Notification Settings API option for hiding push notification
|
|
||||||
contents has been renamed to `hide_notification_contents`
|
|
||||||
- Mastodon API: Added `pleroma.metadata.post_formats` to /api/v1/instance
|
- Mastodon API: Added `pleroma.metadata.post_formats` to /api/v1/instance
|
||||||
- Mastodon API (legacy): Allow query parameters for `/api/v1/domain_blocks`, e.g. `/api/v1/domain_blocks?domain=badposters.zone`
|
- Mastodon API (legacy): Allow query parameters for `/api/v1/domain_blocks`, e.g. `/api/v1/domain_blocks?domain=badposters.zone`
|
||||||
- Pleroma API: `/api/pleroma/captcha` responses now include `seconds_valid` with an integer value.
|
- Pleroma API: `/api/pleroma/captcha` responses now include `seconds_valid` with an integer value.
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Admin API Changes</summary>
|
<summary>Admin API Changes</summary>
|
||||||
|
|
||||||
|
- **Breaking** Changed relay `/api/pleroma/admin/relay` endpoints response format.
|
||||||
- Status visibility stats: now can return stats per instance.
|
- Status visibility stats: now can return stats per instance.
|
||||||
|
|
||||||
- Mix task to refresh counter cache (`mix pleroma.refresh_counter_cache`)
|
- Mix task to refresh counter cache (`mix pleroma.refresh_counter_cache`)
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
- **Breaking:** removed `with_move` parameter from notifications timeline.
|
- **Breaking:** removed `with_move` parameter from notifications timeline.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -105,6 +111,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Fix edge case where MediaProxy truncates media, usually caused when Caddy is serving content for the other Federated instance.
|
- Fix edge case where MediaProxy truncates media, usually caused when Caddy is serving content for the other Federated instance.
|
||||||
- Emoji Packs could not be listed when instance was set to `public: false`
|
- Emoji Packs could not be listed when instance was set to `public: false`
|
||||||
- Fix whole_word always returning false on filter get requests
|
- Fix whole_word always returning false on filter get requests
|
||||||
|
- Migrations not working on OTP releases if the database was connected over ssl
|
||||||
|
- Fix relay following
|
||||||
|
|
||||||
## [Unreleased (patch)]
|
## [Unreleased (patch)]
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ COPY . .
|
||||||
|
|
||||||
ENV MIX_ENV=prod
|
ENV MIX_ENV=prod
|
||||||
|
|
||||||
RUN apk add git gcc g++ musl-dev make &&\
|
RUN apk add git gcc g++ musl-dev make cmake &&\
|
||||||
echo "import Mix.Config" > config/prod.secret.exs &&\
|
echo "import Mix.Config" > config/prod.secret.exs &&\
|
||||||
mix local.hex --force &&\
|
mix local.hex --force &&\
|
||||||
mix local.rebar --force &&\
|
mix local.rebar --force &&\
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Pleroma backend security policy
|
||||||
|
|
||||||
|
## Supported versions
|
||||||
|
|
||||||
|
Currently, Pleroma offers bugfixes and security patches only for the latest minor release.
|
||||||
|
|
||||||
|
| Version | Support
|
||||||
|
|---------| --------
|
||||||
|
| 2.0 | Bugfixes and security patches
|
||||||
|
|
||||||
|
## Reporting a vulnerability
|
||||||
|
|
||||||
|
Please use confidential issues (tick the "This issue is confidential and should only be visible to team members with at least Reporter access." box when submitting) at our [bugtracker](https://git.pleroma.social/pleroma/pleroma/-/issues/new) for reporting vulnerabilities.
|
||||||
|
## Announcements
|
||||||
|
|
||||||
|
New releases are announced at [pleroma.social](https://pleroma.social/announcements/). All security releases are tagged with ["Security"](https://pleroma.social/announcements/tags/security/). You can be notified of them by subscribing to an Atom feed at <https://pleroma.social/announcements/tags/security/feed.xml>.
|
|
@ -72,7 +72,8 @@
|
||||||
pool: :upload
|
pool: :upload
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
filename_display_max_length: 30
|
filename_display_max_length: 30,
|
||||||
|
default_description: nil
|
||||||
|
|
||||||
config :pleroma, Pleroma.Uploaders.Local, uploads: "uploads"
|
config :pleroma, Pleroma.Uploaders.Local, uploads: "uploads"
|
||||||
|
|
||||||
|
@ -515,7 +516,13 @@
|
||||||
"user-search",
|
"user-search",
|
||||||
"user_exists",
|
"user_exists",
|
||||||
"users",
|
"users",
|
||||||
"web"
|
"web",
|
||||||
|
"verify_credentials",
|
||||||
|
"update_credentials",
|
||||||
|
"relationships",
|
||||||
|
"search",
|
||||||
|
"confirmation_resend",
|
||||||
|
"mfa"
|
||||||
],
|
],
|
||||||
email_blacklist: []
|
email_blacklist: []
|
||||||
|
|
||||||
|
@ -762,10 +769,12 @@
|
||||||
timeout: 300_000
|
timeout: 300_000
|
||||||
]
|
]
|
||||||
|
|
||||||
|
private_instance? = :if_instance_is_private
|
||||||
|
|
||||||
config :pleroma, :restrict_unauthenticated,
|
config :pleroma, :restrict_unauthenticated,
|
||||||
timelines: %{local: false, federated: false},
|
timelines: %{local: private_instance?, federated: private_instance?},
|
||||||
profiles: %{local: false, remote: false},
|
profiles: %{local: private_instance?, remote: private_instance?},
|
||||||
activities: %{local: false, remote: false}
|
activities: %{local: private_instance?, remote: private_instance?}
|
||||||
|
|
||||||
config :pleroma, Pleroma.Web.ApiSpec.CastAndValidate, strict: false
|
config :pleroma, Pleroma.Web.ApiSpec.CastAndValidate, strict: false
|
||||||
|
|
||||||
|
@ -780,6 +789,10 @@
|
||||||
|
|
||||||
config :pleroma, :instances_favicons, enabled: false
|
config :pleroma, :instances_favicons, enabled: false
|
||||||
|
|
||||||
|
config :floki, :html_parser, Floki.HTMLParser.FastHtml
|
||||||
|
|
||||||
|
config :pleroma, Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.PleromaAuthenticator
|
||||||
|
|
||||||
# Import environment specific config. This must remain at the bottom
|
# Import environment specific config. This must remain at the bottom
|
||||||
# of this file so it overrides the configuration defined above.
|
# of this file so it overrides the configuration defined above.
|
||||||
import_config "#{Mix.env()}.exs"
|
import_config "#{Mix.env()}.exs"
|
||||||
|
|
|
@ -15,13 +15,17 @@
|
||||||
frontend_options = [
|
frontend_options = [
|
||||||
%{
|
%{
|
||||||
key: "name",
|
key: "name",
|
||||||
|
label: "Name",
|
||||||
type: :string,
|
type: :string,
|
||||||
description: "Name of the installed Admin frontend"
|
description:
|
||||||
|
"Name of the frontend. Valid config must include both `Name` and `Reference` values."
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: "ref",
|
key: "ref",
|
||||||
|
label: "Reference",
|
||||||
type: :string,
|
type: :string,
|
||||||
description: "reference of the installed Admin frontend to be used"
|
description:
|
||||||
|
"Reference of the frontend to be used. Valid config must include both `Name` and `Reference` values."
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: "git",
|
key: "git",
|
||||||
|
@ -224,7 +228,7 @@
|
||||||
type: [:string, {:list, :string}, {:list, :tuple}],
|
type: [:string, {:list, :string}, {:list, :tuple}],
|
||||||
description:
|
description:
|
||||||
"List of actions for the mogrify command. It's possible to add self-written settings as string. " <>
|
"List of actions for the mogrify command. It's possible to add self-written settings as string. " <>
|
||||||
"For example `[\"auto-orient\", \"strip\", {\"resize\", \"3840x1080>\"}]` string will be parsed into list of the settings.",
|
"For example `auto-orient, strip, {\"resize\", \"3840x1080>\"}` value will be parsed into valid list of the settings.",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
"strip",
|
"strip",
|
||||||
"auto-orient",
|
"auto-orient",
|
||||||
|
@ -981,7 +985,7 @@
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :instance_thumbnail,
|
key: :instance_thumbnail,
|
||||||
type: :string,
|
type: {:string, :image},
|
||||||
description:
|
description:
|
||||||
"The instance thumbnail can be any image that represents your instance and is used by some apps or services when they display information about your instance.",
|
"The instance thumbnail can be any image that represents your instance and is used by some apps or services when they display information about your instance.",
|
||||||
suggestions: ["/instance/thumbnail.jpeg"]
|
suggestions: ["/instance/thumbnail.jpeg"]
|
||||||
|
@ -994,25 +998,25 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
group: :welcome,
|
group: :pleroma,
|
||||||
|
key: :welcome,
|
||||||
type: :group,
|
type: :group,
|
||||||
description: "Welcome messages settings",
|
description: "Welcome messages settings",
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
group: :direct_message,
|
key: :direct_message,
|
||||||
type: :group,
|
type: :keyword,
|
||||||
descpiption: "Direct message settings",
|
descpiption: "Direct message settings",
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :enabled,
|
key: :enabled,
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
description: "Enables sends direct message for new user after registration"
|
description: "Enables sending a direct message to newly registered users"
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :message,
|
key: :message,
|
||||||
type: :string,
|
type: :string,
|
||||||
description:
|
description: "A message that will be sent to newly registered users",
|
||||||
"A message that will be sent to a newly registered users as a direct message",
|
|
||||||
suggestions: [
|
suggestions: [
|
||||||
"Hi, @username! Welcome on board!"
|
"Hi, @username! Welcome on board!"
|
||||||
]
|
]
|
||||||
|
@ -1020,7 +1024,7 @@
|
||||||
%{
|
%{
|
||||||
key: :sender_nickname,
|
key: :sender_nickname,
|
||||||
type: :string,
|
type: :string,
|
||||||
description: "The nickname of the local user that sends the welcome message",
|
description: "The nickname of the local user that sends a welcome message",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
"lain"
|
"lain"
|
||||||
]
|
]
|
||||||
|
@ -1028,20 +1032,20 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
group: :chat_message,
|
key: :chat_message,
|
||||||
type: :group,
|
type: :keyword,
|
||||||
descpiption: "Chat message settings",
|
descpiption: "Chat message settings",
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :enabled,
|
key: :enabled,
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
description: "Enables sends chat message for new user after registration"
|
description: "Enables sending a chat message to newly registered users"
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :message,
|
key: :message,
|
||||||
type: :string,
|
type: :string,
|
||||||
description:
|
description:
|
||||||
"A message that will be sent to a newly registered users as a chat message",
|
"A message that will be sent to newly registered users as a chat message",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
"Hello, welcome on board!"
|
"Hello, welcome on board!"
|
||||||
]
|
]
|
||||||
|
@ -1049,7 +1053,7 @@
|
||||||
%{
|
%{
|
||||||
key: :sender_nickname,
|
key: :sender_nickname,
|
||||||
type: :string,
|
type: :string,
|
||||||
description: "The nickname of the local user that sends the welcome message",
|
description: "The nickname of the local user that sends a welcome chat message",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
"lain"
|
"lain"
|
||||||
]
|
]
|
||||||
|
@ -1057,20 +1061,20 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
group: :email,
|
key: :email,
|
||||||
type: :group,
|
type: :keyword,
|
||||||
descpiption: "Email message settings",
|
descpiption: "Email message settings",
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :enabled,
|
key: :enabled,
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
description: "Enables sends direct message for new user after registration"
|
description: "Enables sending an email to newly registered users"
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :sender,
|
key: :sender,
|
||||||
type: [:string, :tuple],
|
type: [:string, :tuple],
|
||||||
description:
|
description:
|
||||||
"The email address or tuple with `{nickname, email}` that will use as sender to the welcome email.",
|
"Email address and/or nickname that will be used to send the welcome email.",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
{"Pleroma App", "welcome@pleroma.app"}
|
{"Pleroma App", "welcome@pleroma.app"}
|
||||||
]
|
]
|
||||||
|
@ -1079,21 +1083,21 @@
|
||||||
key: :subject,
|
key: :subject,
|
||||||
type: :string,
|
type: :string,
|
||||||
description:
|
description:
|
||||||
"The subject of welcome email. Can be use EEX template with `user` and `instance_name` variables.",
|
"Subject of the welcome email. EEX template with user and instance_name variables can be used.",
|
||||||
suggestions: ["Welcome to <%= instance_name%>"]
|
suggestions: ["Welcome to <%= instance_name%>"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :html,
|
key: :html,
|
||||||
type: :string,
|
type: :string,
|
||||||
description:
|
description:
|
||||||
"The html content of welcome email. Can be use EEX template with `user` and `instance_name` variables.",
|
"HTML content of the welcome email. EEX template with user and instance_name variables can be used.",
|
||||||
suggestions: ["<h1>Hello <%= user.name%>. Welcome to <%= instance_name%></h1>"]
|
suggestions: ["<h1>Hello <%= user.name%>. Welcome to <%= instance_name%></h1>"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :text,
|
key: :text,
|
||||||
type: :string,
|
type: :string,
|
||||||
description:
|
description:
|
||||||
"The text content of welcome email. Can be use EEX template with `user` and `instance_name` variables.",
|
"Text content of the welcome email. EEX template with user and instance_name variables can be used.",
|
||||||
suggestions: ["Hello <%= user.name%>. \n Welcome to <%= instance_name%>\n"]
|
suggestions: ["Hello <%= user.name%>. \n Welcome to <%= instance_name%>\n"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -1266,7 +1270,7 @@
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :background,
|
key: :background,
|
||||||
type: :string,
|
type: {:string, :image},
|
||||||
description:
|
description:
|
||||||
"URL of the background, unless viewing a user profile with a background that is set",
|
"URL of the background, unless viewing a user profile with a background that is set",
|
||||||
suggestions: ["/images/city.jpg"]
|
suggestions: ["/images/city.jpg"]
|
||||||
|
@ -1323,7 +1327,7 @@
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :logo,
|
key: :logo,
|
||||||
type: :string,
|
type: {:string, :image},
|
||||||
description: "URL of the logo, defaults to Pleroma's logo",
|
description: "URL of the logo, defaults to Pleroma's logo",
|
||||||
suggestions: ["/static/logo.png"]
|
suggestions: ["/static/logo.png"]
|
||||||
},
|
},
|
||||||
|
@ -1355,7 +1359,7 @@
|
||||||
%{
|
%{
|
||||||
key: :nsfwCensorImage,
|
key: :nsfwCensorImage,
|
||||||
label: "NSFW Censor Image",
|
label: "NSFW Censor Image",
|
||||||
type: :string,
|
type: {:string, :image},
|
||||||
description:
|
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"]
|
suggestions: ["/static/img/nsfw.74818f9.png"]
|
||||||
|
@ -1481,7 +1485,7 @@
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :default_user_avatar,
|
key: :default_user_avatar,
|
||||||
type: :string,
|
type: {:string, :image},
|
||||||
description: "URL of the default user avatar",
|
description: "URL of the default user avatar",
|
||||||
suggestions: ["/images/avi.png"]
|
suggestions: ["/images/avi.png"]
|
||||||
}
|
}
|
||||||
|
@ -1840,12 +1844,12 @@
|
||||||
%{
|
%{
|
||||||
key: :enabled,
|
key: :enabled,
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
description: "Enables invalidate media cache"
|
description: "Enables media cache object invalidation."
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :provider,
|
key: :provider,
|
||||||
type: :module,
|
type: :module,
|
||||||
description: "Module which will be used to cache purge.",
|
description: "Module which will be used to purge objects from the cache.",
|
||||||
suggestions: [
|
suggestions: [
|
||||||
Pleroma.Web.MediaProxy.Invalidation.Script,
|
Pleroma.Web.MediaProxy.Invalidation.Script,
|
||||||
Pleroma.Web.MediaProxy.Invalidation.Http
|
Pleroma.Web.MediaProxy.Invalidation.Http
|
||||||
|
@ -2672,7 +2676,7 @@
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :logo,
|
key: :logo,
|
||||||
type: :string,
|
type: {:string, :image},
|
||||||
description: "A path to a custom logo. Set it to `nil` to use the default Pleroma logo.",
|
description: "A path to a custom logo. Set it to `nil` to use the default Pleroma logo.",
|
||||||
suggestions: ["some/path/logo.png"]
|
suggestions: ["some/path/logo.png"]
|
||||||
},
|
},
|
||||||
|
@ -3329,13 +3333,13 @@
|
||||||
group: :pleroma,
|
group: :pleroma,
|
||||||
key: :connections_pool,
|
key: :connections_pool,
|
||||||
type: :group,
|
type: :group,
|
||||||
description: "Advanced settings for `gun` connections pool",
|
description: "Advanced settings for `Gun` connections pool",
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :connection_acquisition_wait,
|
key: :connection_acquisition_wait,
|
||||||
type: :integer,
|
type: :integer,
|
||||||
description:
|
description:
|
||||||
"Timeout to acquire a connection from pool.The total max time is this value multiplied by the number of retries. Default: 250ms.",
|
"Timeout to acquire a connection from pool. The total max time is this value multiplied by the number of retries. Default: 250ms.",
|
||||||
suggestions: [250]
|
suggestions: [250]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
|
@ -3370,7 +3374,7 @@
|
||||||
group: :pleroma,
|
group: :pleroma,
|
||||||
key: :pools,
|
key: :pools,
|
||||||
type: :group,
|
type: :group,
|
||||||
description: "Advanced settings for `gun` workers pools",
|
description: "Advanced settings for `Gun` workers pools",
|
||||||
children:
|
children:
|
||||||
Enum.map([:federation, :media, :upload, :default], fn pool_name ->
|
Enum.map([:federation, :media, :upload, :default], fn pool_name ->
|
||||||
%{
|
%{
|
||||||
|
@ -3399,7 +3403,7 @@
|
||||||
group: :pleroma,
|
group: :pleroma,
|
||||||
key: :hackney_pools,
|
key: :hackney_pools,
|
||||||
type: :group,
|
type: :group,
|
||||||
description: "Advanced settings for `hackney` connections pools",
|
description: "Advanced settings for `Hackney` connections pools",
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :federation,
|
key: :federation,
|
||||||
|
@ -3463,6 +3467,7 @@
|
||||||
%{
|
%{
|
||||||
group: :pleroma,
|
group: :pleroma,
|
||||||
key: :restrict_unauthenticated,
|
key: :restrict_unauthenticated,
|
||||||
|
label: "Restrict Unauthenticated",
|
||||||
type: :group,
|
type: :group,
|
||||||
description:
|
description:
|
||||||
"Disallow viewing timelines, user profiles and statuses for unauthenticated users.",
|
"Disallow viewing timelines, user profiles and statuses for unauthenticated users.",
|
||||||
|
@ -3593,7 +3598,30 @@
|
||||||
%{
|
%{
|
||||||
key: :available,
|
key: :available,
|
||||||
type: :map,
|
type: :map,
|
||||||
description: "A map containing available frontends and parameters for their installation."
|
description:
|
||||||
|
"A map containing available frontends and parameters for their installation.",
|
||||||
|
children: [
|
||||||
|
frontend_options
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
group: :pleroma,
|
||||||
|
key: Pleroma.Web.Preload,
|
||||||
|
type: :group,
|
||||||
|
description: "Preload-related settings",
|
||||||
|
children: [
|
||||||
|
%{
|
||||||
|
key: :providers,
|
||||||
|
type: {:list, :module},
|
||||||
|
description: "List of preload providers to enable",
|
||||||
|
suggestions: [
|
||||||
|
Pleroma.Web.Preload.Providers.Instance,
|
||||||
|
Pleroma.Web.Preload.Providers.User,
|
||||||
|
Pleroma.Web.Preload.Providers.Timelines,
|
||||||
|
Pleroma.Web.Preload.Providers.StatusNet
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,10 @@
|
||||||
|
|
||||||
config :pleroma, :auth, oauth_consumer_strategies: []
|
config :pleroma, :auth, oauth_consumer_strategies: []
|
||||||
|
|
||||||
config :pleroma, Pleroma.Upload, filters: [], link_name: false
|
config :pleroma, Pleroma.Upload,
|
||||||
|
filters: [],
|
||||||
|
link_name: false,
|
||||||
|
default_description: :filename
|
||||||
|
|
||||||
config :pleroma, Pleroma.Uploaders.Local, uploads: "test/uploads"
|
config :pleroma, Pleroma.Uploaders.Local, uploads: "test/uploads"
|
||||||
|
|
||||||
|
|
|
@ -313,31 +313,53 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
||||||
- On failure: `Not found`
|
- On failure: `Not found`
|
||||||
- On success: JSON array of user's latest statuses
|
- On success: JSON array of user's latest statuses
|
||||||
|
|
||||||
|
## `GET /api/pleroma/admin/relay`
|
||||||
|
|
||||||
|
### List Relays
|
||||||
|
|
||||||
|
Params: none
|
||||||
|
Response:
|
||||||
|
|
||||||
|
* On success: JSON array of relays
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{"actor": "https://example.com/relay", "followed_back": true},
|
||||||
|
{"actor": "https://example2.com/relay", "followed_back": false}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
## `POST /api/pleroma/admin/relay`
|
## `POST /api/pleroma/admin/relay`
|
||||||
|
|
||||||
### Follow a Relay
|
### Follow a Relay
|
||||||
|
|
||||||
- Params:
|
Params:
|
||||||
- `relay_url`
|
|
||||||
- Response:
|
* `relay_url`
|
||||||
- On success: URL of the followed relay
|
|
||||||
|
Response:
|
||||||
|
|
||||||
|
* On success: relay json object
|
||||||
|
|
||||||
|
```json
|
||||||
|
{"actor": "https://example.com/relay", "followed_back": true}
|
||||||
|
```
|
||||||
|
|
||||||
## `DELETE /api/pleroma/admin/relay`
|
## `DELETE /api/pleroma/admin/relay`
|
||||||
|
|
||||||
### Unfollow a Relay
|
### Unfollow a Relay
|
||||||
|
|
||||||
- Params:
|
Params:
|
||||||
- `relay_url`
|
|
||||||
- Response:
|
|
||||||
- On success: URL of the unfollowed relay
|
|
||||||
|
|
||||||
## `GET /api/pleroma/admin/relay`
|
* `relay_url`
|
||||||
|
|
||||||
### List Relays
|
Response:
|
||||||
|
|
||||||
- Params: none
|
* On success: URL of the unfollowed relay
|
||||||
- Response:
|
|
||||||
- On success: JSON array of relays
|
```json
|
||||||
|
{"https://example.com/relay"}
|
||||||
|
```
|
||||||
|
|
||||||
## `POST /api/pleroma/admin/users/invite_token`
|
## `POST /api/pleroma/admin/users/invite_token`
|
||||||
|
|
||||||
|
@ -1266,11 +1288,14 @@ Loads json generated from `config/descriptions.exs`.
|
||||||
- Params:
|
- Params:
|
||||||
- *optional* `page`: **integer** page number
|
- *optional* `page`: **integer** page number
|
||||||
- *optional* `page_size`: **integer** number of log entries per page (default is `50`)
|
- *optional* `page_size`: **integer** number of log entries per page (default is `50`)
|
||||||
|
- *optional* `query`: **string** search term
|
||||||
|
|
||||||
- Response:
|
- Response:
|
||||||
|
|
||||||
``` json
|
``` json
|
||||||
{
|
{
|
||||||
|
"page_size": integer,
|
||||||
|
"count": integer,
|
||||||
"urls": [
|
"urls": [
|
||||||
"http://example.com/media/a688346.jpg",
|
"http://example.com/media/a688346.jpg",
|
||||||
"http://example.com/media/fb1f4d.jpg"
|
"http://example.com/media/fb1f4d.jpg"
|
||||||
|
@ -1290,12 +1315,7 @@ Loads json generated from `config/descriptions.exs`.
|
||||||
- Response:
|
- Response:
|
||||||
|
|
||||||
``` json
|
``` json
|
||||||
{
|
{ }
|
||||||
"urls": [
|
|
||||||
"http://example.com/media/a688346.jpg",
|
|
||||||
"http://example.com/media/fb1f4d.jpg"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1311,11 +1331,6 @@ Loads json generated from `config/descriptions.exs`.
|
||||||
- Response:
|
- Response:
|
||||||
|
|
||||||
``` json
|
``` json
|
||||||
{
|
{ }
|
||||||
"urls": [
|
|
||||||
"http://example.com/media/a688346.jpg",
|
|
||||||
"http://example.com/media/fb1f4d.jpg"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -11,14 +11,17 @@
|
||||||
config :pleroma, configurable_from_database: true
|
config :pleroma, configurable_from_database: true
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
|
|
||||||
|
```sh
|
||||||
./bin/pleroma_ctl config migrate_to_db
|
./bin/pleroma_ctl config migrate_to_db
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "From Source"
|
||||||
mix pleroma.config migrate_to_db
|
|
||||||
```
|
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.config migrate_to_db
|
||||||
|
```
|
||||||
|
|
||||||
## Transfer config from DB to `config/env.exported_from_db.secret.exs`
|
## Transfer config from DB to `config/env.exported_from_db.secret.exs`
|
||||||
|
|
||||||
|
@ -31,10 +34,12 @@ mix pleroma.config migrate_to_db
|
||||||
|
|
||||||
To delete transfered settings from database optional flag `-d` can be used. `<env>` is `prod` by default.
|
To delete transfered settings from database optional flag `-d` can be used. `<env>` is `prod` by default.
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
|
```sh
|
||||||
./bin/pleroma_ctl config migrate_from_db [--env=<env>] [-d]
|
./bin/pleroma_ctl config migrate_from_db [--env=<env>] [-d]
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "From Source"
|
||||||
mix pleroma.config migrate_from_db [--env=<env>] [-d]
|
```sh
|
||||||
```
|
mix pleroma.config migrate_from_db [--env=<env>] [-d]
|
||||||
|
```
|
||||||
|
|
|
@ -9,13 +9,18 @@
|
||||||
|
|
||||||
Replaces embedded objects with references to them in the `objects` table. Only needs to be ran once if the instance was created before Pleroma 1.0.5. The reason why this is not a migration is because it could significantly increase the database size after being ran, however after this `VACUUM FULL` will be able to reclaim about 20% (really depends on what is in the database, your mileage may vary) of the db size before the migration.
|
Replaces embedded objects with references to them in the `objects` table. Only needs to be ran once if the instance was created before Pleroma 1.0.5. The reason why this is not a migration is because it could significantly increase the database size after being ran, however after this `VACUUM FULL` will be able to reclaim about 20% (really depends on what is in the database, your mileage may vary) of the db size before the migration.
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl database remove_embedded_objects [option ...]
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl database remove_embedded_objects [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.database remove_embedded_objects [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
```sh tab="From Source"
|
|
||||||
mix pleroma.database remove_embedded_objects [option ...]
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
- `--vacuum` - run `VACUUM FULL` after the embedded objects are replaced with their references
|
- `--vacuum` - run `VACUUM FULL` after the embedded objects are replaced with their references
|
||||||
|
@ -27,13 +32,17 @@ This will prune remote posts older than 90 days (configurable with [`config :ple
|
||||||
!!! danger
|
!!! danger
|
||||||
The disk space will only be reclaimed after `VACUUM FULL`. You may run out of disk space during the execution of the task or vacuuming if you don't have about 1/3rds of the database size free.
|
The disk space will only be reclaimed after `VACUUM FULL`. You may run out of disk space during the execution of the task or vacuuming if you don't have about 1/3rds of the database size free.
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl database prune_objects [option ...]
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.database prune_objects [option ...]
|
./bin/pleroma_ctl database prune_objects [option ...]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.database prune_objects [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
- `--vacuum` - run `VACUUM FULL` after the objects are pruned
|
- `--vacuum` - run `VACUUM FULL` after the objects are pruned
|
||||||
|
@ -42,33 +51,45 @@ mix pleroma.database prune_objects [option ...]
|
||||||
|
|
||||||
Can be safely re-run
|
Can be safely re-run
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl database bump_all_conversations
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.database bump_all_conversations
|
./bin/pleroma_ctl database bump_all_conversations
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.database bump_all_conversations
|
||||||
|
```
|
||||||
|
|
||||||
## Remove duplicated items from following and update followers count for all users
|
## Remove duplicated items from following and update followers count for all users
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl database update_users_following_followers_counts
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.database update_users_following_followers_counts
|
./bin/pleroma_ctl database update_users_following_followers_counts
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.database update_users_following_followers_counts
|
||||||
|
```
|
||||||
|
|
||||||
## Fix the pre-existing "likes" collections for all objects
|
## Fix the pre-existing "likes" collections for all objects
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl database fix_likes_collections
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.database fix_likes_collections
|
./bin/pleroma_ctl database fix_likes_collections
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.database fix_likes_collections
|
||||||
|
```
|
||||||
|
|
||||||
## Vacuum the database
|
## Vacuum the database
|
||||||
|
|
||||||
|
@ -76,13 +97,17 @@ mix pleroma.database fix_likes_collections
|
||||||
|
|
||||||
Running an `analyze` vacuum job can improve performance by updating statistics used by the query planner. **It is safe to cancel this.**
|
Running an `analyze` vacuum job can improve performance by updating statistics used by the query planner. **It is safe to cancel this.**
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl database vacuum analyze
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.database vacuum analyze
|
./bin/pleroma_ctl database vacuum analyze
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.database vacuum analyze
|
||||||
|
```
|
||||||
|
|
||||||
### Full
|
### Full
|
||||||
|
|
||||||
|
@ -91,10 +116,28 @@ and more compact files with an optimized layout. This process will take a long t
|
||||||
it builds the files side-by-side the existing database files. It can make your database faster and use less disk space,
|
it builds the files side-by-side the existing database files. It can make your database faster and use less disk space,
|
||||||
but should only be run if necessary. **It is safe to cancel this.**
|
but should only be run if necessary. **It is safe to cancel this.**
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl database vacuum full
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.database vacuum full
|
./bin/pleroma_ctl database vacuum full
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.database vacuum full
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add expiration to all local statuses
|
||||||
|
|
||||||
|
=== "OTP"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./bin/pleroma_ctl database ensure_expiration
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.database ensure_expiration
|
||||||
|
```
|
||||||
|
|
|
@ -4,22 +4,30 @@
|
||||||
|
|
||||||
## Send digest email since given date (user registration date by default) ignoring user activity status.
|
## Send digest email since given date (user registration date by default) ignoring user activity status.
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl digest test <nickname> [since_date]
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.digest test <nickname> [since_date]
|
./bin/pleroma_ctl digest test <nickname> [since_date]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.digest test <nickname> [since_date]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl digest test donaldtheduck 2019-05-20
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.digest test donaldtheduck 2019-05-20
|
./bin/pleroma_ctl digest test donaldtheduck 2019-05-20
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.digest test donaldtheduck 2019-05-20
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
@ -4,21 +4,29 @@
|
||||||
|
|
||||||
## Send test email (instance email by default)
|
## Send test email (instance email by default)
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl email test [--to <destination email address>]
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.email test [--to <destination email address>]
|
./bin/pleroma_ctl email test [--to <destination email address>]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.email test [--to <destination email address>]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl email test --to root@example.org
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.email test --to root@example.org
|
./bin/pleroma_ctl email test --to root@example.org
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.email test --to root@example.org
|
||||||
|
```
|
||||||
|
|
|
@ -4,13 +4,15 @@
|
||||||
|
|
||||||
## Lists emoji packs and metadata specified in the manifest
|
## Lists emoji packs and metadata specified in the manifest
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl emoji ls-packs [option ...]
|
```sh
|
||||||
```
|
./bin/pleroma_ctl emoji ls-packs [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "From Source"
|
||||||
mix pleroma.emoji ls-packs [option ...]
|
```sh
|
||||||
```
|
mix pleroma.emoji ls-packs [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
@ -18,26 +20,30 @@ mix pleroma.emoji ls-packs [option ...]
|
||||||
|
|
||||||
## Fetch, verify and install the specified packs from the manifest into `STATIC-DIR/emoji/PACK-NAME`
|
## Fetch, verify and install the specified packs from the manifest into `STATIC-DIR/emoji/PACK-NAME`
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl emoji get-packs [option ...] <pack ...>
|
```sh
|
||||||
```
|
./bin/pleroma_ctl emoji get-packs [option ...] <pack ...>
|
||||||
|
```
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "From Source"
|
||||||
mix pleroma.emoji get-packs [option ...] <pack ...>
|
```sh
|
||||||
```
|
mix pleroma.emoji get-packs [option ...] <pack ...>
|
||||||
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
- `-m, --manifest PATH/URL` - same as [`ls-packs`](#ls-packs)
|
- `-m, --manifest PATH/URL` - same as [`ls-packs`](#ls-packs)
|
||||||
|
|
||||||
## Create a new manifest entry and a file list from the specified remote pack file
|
## Create a new manifest entry and a file list from the specified remote pack file
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl emoji gen-pack PACK-URL
|
```sh
|
||||||
```
|
./bin/pleroma_ctl emoji gen-pack PACK-URL
|
||||||
|
```
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "From Source"
|
||||||
mix pleroma.emoji gen-pack PACK-URL
|
```sh
|
||||||
```
|
mix pleroma.emoji gen-pack PACK-URL
|
||||||
|
```
|
||||||
|
|
||||||
Currently, only .zip archives are recognized as remote pack files and packs are therefore assumed to be zip archives. This command is intended to run interactively and will first ask you some basic questions about the pack, then download the remote file and generate an SHA256 checksum for it, then generate an emoji file list for you.
|
Currently, only .zip archives are recognized as remote pack files and packs are therefore assumed to be zip archives. This command is intended to run interactively and will first ask you some basic questions about the pack, then download the remote file and generate an SHA256 checksum for it, then generate an emoji file list for you.
|
||||||
|
|
||||||
|
@ -47,8 +53,9 @@ Currently, only .zip archives are recognized as remote pack files and packs are
|
||||||
|
|
||||||
## Reload emoji packs
|
## Reload emoji packs
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl emoji reload
|
```sh
|
||||||
```
|
./bin/pleroma_ctl emoji reload
|
||||||
|
```
|
||||||
|
|
||||||
This command only works with OTP releases.
|
This command only works with OTP releases.
|
||||||
|
|
|
@ -3,13 +3,17 @@
|
||||||
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
|
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
|
||||||
|
|
||||||
## Generate a new configuration file
|
## Generate a new configuration file
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl instance gen [option ...]
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.instance gen [option ...]
|
./bin/pleroma_ctl instance gen [option ...]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.instance gen [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
If any of the options are left unspecified, you will be prompted interactively.
|
If any of the options are left unspecified, you will be prompted interactively.
|
||||||
|
|
|
@ -7,10 +7,14 @@
|
||||||
Optional params:
|
Optional params:
|
||||||
* `-s SCOPES` - scopes for app, e.g. `read,write,follow,push`.
|
* `-s SCOPES` - scopes for app, e.g. `read,write,follow,push`.
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl app create -n APP_NAME -r REDIRECT_URI
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.app create -n APP_NAME -r REDIRECT_URI
|
./bin/pleroma_ctl app create -n APP_NAME -r REDIRECT_URI
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.app create -n APP_NAME -r REDIRECT_URI
|
||||||
|
```
|
|
@ -4,30 +4,42 @@
|
||||||
|
|
||||||
## Follow a relay
|
## Follow a relay
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl relay follow <relay_url>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.relay follow <relay_url>
|
./bin/pleroma_ctl relay follow <relay_url>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.relay follow <relay_url>
|
||||||
|
```
|
||||||
|
|
||||||
## Unfollow a remote relay
|
## Unfollow a remote relay
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl relay unfollow <relay_url>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.relay unfollow <relay_url>
|
./bin/pleroma_ctl relay unfollow <relay_url>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.relay unfollow <relay_url>
|
||||||
|
```
|
||||||
|
|
||||||
## List relay subscriptions
|
## List relay subscriptions
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl relay list
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.relay list
|
./bin/pleroma_ctl relay list
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.relay list
|
||||||
|
```
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
# Generate release environment file
|
|
||||||
|
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl release_env gen
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
|
||||||
mix pleroma.release_env gen
|
|
||||||
```
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Managing robots.txt
|
||||||
|
|
||||||
|
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
|
||||||
|
|
||||||
|
## Generate a new robots.txt file and add it to the static directory
|
||||||
|
|
||||||
|
The `robots.txt` that ships by default is permissive. It allows well-behaved search engines to index all of your instance's URIs.
|
||||||
|
|
||||||
|
If you want to generate a restrictive `robots.txt`, you can run the following mix task. The generated `robots.txt` will be written in your instance [static directory](../../../configuration/static_dir/).
|
||||||
|
|
||||||
|
=== "OTP"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./bin/pleroma_ctl robots_txt disallow_all
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.robots_txt disallow_all
|
||||||
|
```
|
|
@ -3,13 +3,17 @@
|
||||||
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
|
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
|
||||||
|
|
||||||
## Migrate uploads from local to remote storage
|
## Migrate uploads from local to remote storage
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl uploads migrate_local <target_uploader> [option ...]
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.uploads migrate_local <target_uploader> [option ...]
|
./bin/pleroma_ctl uploads migrate_local <target_uploader> [option ...]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.uploads migrate_local <target_uploader> [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
- `--delete` - delete local uploads after migrating them to the target uploader
|
- `--delete` - delete local uploads after migrating them to the target uploader
|
||||||
|
|
|
@ -4,13 +4,17 @@
|
||||||
|
|
||||||
## Create a user
|
## Create a user
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl user new <nickname> <email> [option ...]
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.user new <nickname> <email> [option ...]
|
./bin/pleroma_ctl user new <nickname> <email> [option ...]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user new <nickname> <email> [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
@ -22,23 +26,33 @@ mix pleroma.user new <nickname> <email> [option ...]
|
||||||
- `-y`, `--assume-yes`/`--no-assume-yes` - whether to assume yes to all questions
|
- `-y`, `--assume-yes`/`--no-assume-yes` - whether to assume yes to all questions
|
||||||
|
|
||||||
## List local users
|
## List local users
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user list
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user list
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user list
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user list
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Generate an invite link
|
## Generate an invite link
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user invite [option ...]
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user invite [option ...]
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user invite [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user invite [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
@ -46,113 +60,168 @@ mix pleroma.user invite [option ...]
|
||||||
- `--max-use NUMBER` - maximum numbers of token uses
|
- `--max-use NUMBER` - maximum numbers of token uses
|
||||||
|
|
||||||
## List generated invites
|
## List generated invites
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user invites
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user invites
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user invites
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user invites
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Revoke invite
|
## Revoke invite
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user revoke_invite <token>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user revoke_invite <token>
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user revoke_invite <token>
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user revoke_invite <token>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Delete a user
|
## Delete a user
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user rm <nickname>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user rm <nickname>
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user rm <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user rm <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Delete user's posts and interactions
|
## Delete user's posts and interactions
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user delete_activities <nickname>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user delete_activities <nickname>
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user delete_activities <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user delete_activities <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Sign user out from all applications (delete user's OAuth tokens and authorizations)
|
## Sign user out from all applications (delete user's OAuth tokens and authorizations)
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user sign_out <nickname>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user sign_out <nickname>
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user sign_out <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user sign_out <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Deactivate or activate a user
|
## Deactivate or activate a user
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user toggle_activated <nickname>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user toggle_activated <nickname>
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user toggle_activated <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user toggle_activated <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Deactivate a user and unsubscribes local users from the user
|
## Deactivate a user and unsubscribes local users from the user
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user deactivate NICKNAME
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user deactivate NICKNAME
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user deactivate NICKNAME
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user deactivate NICKNAME
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Deactivate all accounts from an instance and unsubscribe local users on it
|
## Deactivate all accounts from an instance and unsubscribe local users on it
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user deactivate_all_from_instance <instance>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user deactivate_all_from_instance <instance>
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user deactivate_all_from_instance <instance>
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user deactivate_all_from_instance <instance>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Create a password reset link for user
|
## Create a password reset link for user
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user reset_password <nickname>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user reset_password <nickname>
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user reset_password <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user reset_password <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Disable Multi Factor Authentication (MFA/2FA) for a user
|
## Disable Multi Factor Authentication (MFA/2FA) for a user
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user reset_mfa <nickname>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user reset_mfa <nickname>
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user reset_mfa <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user reset_mfa <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Set the value of the given user's settings
|
## Set the value of the given user's settings
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user set <nickname> [option ...]
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user set <nickname> [option ...]
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user set <nickname> [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user set <nickname> [option ...]
|
||||||
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
- `--locked`/`--no-locked` - whether the user should be locked
|
- `--locked`/`--no-locked` - whether the user should be locked
|
||||||
|
@ -160,30 +229,45 @@ mix pleroma.user set <nickname> [option ...]
|
||||||
- `--admin`/`--no-admin` - whether the user should be an admin
|
- `--admin`/`--no-admin` - whether the user should be an admin
|
||||||
|
|
||||||
## Add tags to a user
|
## Add tags to a user
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user tag <nickname> <tags>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user tag <nickname> <tags>
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user tag <nickname> <tags>
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user tag <nickname> <tags>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Delete tags from a user
|
## Delete tags from a user
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user untag <nickname> <tags>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user untag <nickname> <tags>
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user untag <nickname> <tags>
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user untag <nickname> <tags>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Toggle confirmation status of the user
|
## Toggle confirmation status of the user
|
||||||
```sh tab="OTP"
|
|
||||||
./bin/pleroma_ctl user toggle_confirmed <nickname>
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
=== "OTP"
|
||||||
mix pleroma.user toggle_confirmed <nickname>
|
|
||||||
```
|
```sh
|
||||||
|
./bin/pleroma_ctl user toggle_confirmed <nickname>
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.user toggle_confirmed <nickname>
|
||||||
|
```
|
||||||
|
|
|
@ -6,11 +6,11 @@ Feel free to contact us to be added to this list!
|
||||||
### Roma for Desktop
|
### Roma for Desktop
|
||||||
- Homepage: <https://www.pleroma.com/#desktopApp>
|
- Homepage: <https://www.pleroma.com/#desktopApp>
|
||||||
- Source Code: <https://github.com/roma-apps/roma-desktop>
|
- Source Code: <https://github.com/roma-apps/roma-desktop>
|
||||||
- Platforms: Windows, Mac, (Linux?)
|
- Platforms: Windows, Mac, Linux
|
||||||
- Features: Streaming Ready
|
- Features: Streaming Ready
|
||||||
|
|
||||||
### Social
|
### Social
|
||||||
- Source Code: <https://gitlab.gnome.org/BrainBlasted/Social>
|
- Source Code: <https://gitlab.gnome.org/World/Social>
|
||||||
- Contact: [@brainblasted@social.libre.fi](https://social.libre.fi/users/brainblasted)
|
- Contact: [@brainblasted@social.libre.fi](https://social.libre.fi/users/brainblasted)
|
||||||
- Platforms: Linux (GNOME)
|
- Platforms: Linux (GNOME)
|
||||||
- Note(2019-01-28): Not at a pre-alpha stage yet
|
- Note(2019-01-28): Not at a pre-alpha stage yet
|
||||||
|
@ -48,16 +48,9 @@ Feel free to contact us to be added to this list!
|
||||||
- Platforms: Android
|
- Platforms: Android
|
||||||
- Features: No Streaming, Emoji Reactions, Text Formatting, FE Stickers
|
- Features: No Streaming, Emoji Reactions, Text Formatting, FE Stickers
|
||||||
|
|
||||||
### Nekonium
|
|
||||||
- Homepage: [F-Droid Repository](https://repo.gdgd.jp.net/), [Google Play](https://play.google.com/store/apps/details?id=com.apps.nekonium), [Amazon](https://www.amazon.co.jp/dp/B076FXPRBC/)
|
|
||||||
- Source: <https://gogs.gdgd.jp.net/lin/nekonium>
|
|
||||||
- Contact: [@lin@pleroma.gdgd.jp.net](https://pleroma.gdgd.jp.net/users/lin)
|
|
||||||
- Platforms: Android
|
|
||||||
- Features: Streaming Ready
|
|
||||||
|
|
||||||
### Fedi
|
### Fedi
|
||||||
- Homepage: <https://www.fediapp.com/>
|
- Homepage: <https://www.fediapp.com/>
|
||||||
- Source Code: Proprietary, but free
|
- Source Code: Proprietary, but gratis
|
||||||
- Platforms: iOS, Android
|
- Platforms: iOS, Android
|
||||||
- Features: Pleroma-specific features like Reactions
|
- Features: Pleroma-specific features like Reactions
|
||||||
|
|
||||||
|
@ -70,9 +63,9 @@ Feel free to contact us to be added to this list!
|
||||||
|
|
||||||
### Twidere
|
### Twidere
|
||||||
- Homepage: <https://twidere.mariotaku.org/>
|
- Homepage: <https://twidere.mariotaku.org/>
|
||||||
- Source Code: <https://github.com/TwidereProject/Twidere-Android/>, <https://github.com/TwidereProject/Twidere-iOS/>
|
- Source Code: <https://github.com/TwidereProject/Twidere-Android/>
|
||||||
- Contact: <me@mariotaku.org>
|
- Contact: <me@mariotaku.org>
|
||||||
- Platform: Android, iOS
|
- Platform: Android
|
||||||
- Features: No Streaming
|
- Features: No Streaming
|
||||||
|
|
||||||
### Indigenous
|
### Indigenous
|
||||||
|
@ -89,11 +82,6 @@ Feel free to contact us to be added to this list!
|
||||||
- Contact: [@gcupc@glitch.social](https://glitch.social/users/gcupc)
|
- Contact: [@gcupc@glitch.social](https://glitch.social/users/gcupc)
|
||||||
- Features: No Streaming
|
- Features: No Streaming
|
||||||
|
|
||||||
### Feather
|
|
||||||
- Source Code: <https://github.com/kaniini/feather>
|
|
||||||
- Contact: [@kaniini@pleroma.site](https://pleroma.site/kaniini)
|
|
||||||
- Features: No Streaming
|
|
||||||
|
|
||||||
### Halcyon
|
### Halcyon
|
||||||
- Source Code: <https://notabug.org/halcyon-suite/halcyon>
|
- Source Code: <https://notabug.org/halcyon-suite/halcyon>
|
||||||
- Contact: [@halcyon@social.csswg.org](https://social.csswg.org/users/halcyon)
|
- Contact: [@halcyon@social.csswg.org](https://social.csswg.org/users/halcyon)
|
||||||
|
@ -107,6 +95,15 @@ Feel free to contact us to be added to this list!
|
||||||
- Features: No Streaming
|
- Features: No Streaming
|
||||||
|
|
||||||
### Sengi
|
### Sengi
|
||||||
|
- Homepage: <https://nicolasconstant.github.io/sengi/>
|
||||||
- Source Code: <https://github.com/NicolasConstant/sengi>
|
- Source Code: <https://github.com/NicolasConstant/sengi>
|
||||||
- Contact: [@sengi_app@mastodon.social](https://mastodon.social/users/sengi_app)
|
- Contact: [@sengi_app@mastodon.social](https://mastodon.social/users/sengi_app)
|
||||||
- Note(2019-01-28): The development is currently in a early stage.
|
|
||||||
|
### DashFE
|
||||||
|
- Source Code: <https://notabug.org/daisuke/DashboardFE>
|
||||||
|
- Contact: [@dashfe@stereophonic.space](https://stereophonic.space/users/dashfe)
|
||||||
|
|
||||||
|
### BloatFE
|
||||||
|
- Source Code: <https://git.freesoftwareextremist.com/bloat/>
|
||||||
|
- Contact: [@r@freesoftwareextremist.com](https://freesoftwareextremist.com/users/r)
|
||||||
|
- Features: Does not requires JavaScript
|
||||||
|
|
|
@ -38,8 +38,8 @@ To add configuration to your config file, you can copy it from the base config.
|
||||||
* `federation_incoming_replies_max_depth`: Max. depth of reply-to activities fetching on incoming federation, to prevent out-of-memory situations while fetching very long threads. If set to `nil`, threads of any depth will be fetched. Lower this value if you experience out-of-memory crashes.
|
* `federation_incoming_replies_max_depth`: Max. depth of reply-to activities fetching on incoming federation, to prevent out-of-memory situations while fetching very long threads. If set to `nil`, threads of any depth will be fetched. Lower this value if you experience out-of-memory crashes.
|
||||||
* `federation_reachability_timeout_days`: Timeout (in days) of each external federation target being unreachable prior to pausing federating to it.
|
* `federation_reachability_timeout_days`: Timeout (in days) of each external federation target being unreachable prior to pausing federating to it.
|
||||||
* `allow_relay`: Enable Pleroma’s Relay, which makes it possible to follow a whole instance.
|
* `allow_relay`: Enable Pleroma’s Relay, which makes it possible to follow a whole instance.
|
||||||
* `public`: Makes the client API in authenticated mode-only except for user-profiles. Useful for disabling the Local Timeline and The Whole Known Network. See also: `restrict_unauthenticated`.
|
* `public`: Makes the client API in authenticated mode-only except for user-profiles. Useful for disabling the Local Timeline and The Whole Known Network. Note that there is a dependent setting restricting or allowing unauthenticated access to specific resources, see `restrict_unauthenticated` for more details.
|
||||||
* `quarantined_instances`: List of ActivityPub instances where private(DMs, followers-only) activities will not be send.
|
* `quarantined_instances`: List of ActivityPub instances where private (DMs, followers-only) activities will not be send.
|
||||||
* `managed_config`: Whenether the config for pleroma-fe is configured in [:frontend_configurations](#frontend_configurations) or in ``static/config.json``.
|
* `managed_config`: Whenether the config for pleroma-fe is configured in [:frontend_configurations](#frontend_configurations) or in ``static/config.json``.
|
||||||
* `allowed_post_formats`: MIME-type list of formats allowed to be posted (transformed into HTML).
|
* `allowed_post_formats`: MIME-type list of formats allowed to be posted (transformed into HTML).
|
||||||
* `extended_nickname_format`: Set to `true` to use extended local nicknames format (allows underscores/dashes). This will break federation with
|
* `extended_nickname_format`: Set to `true` to use extended local nicknames format (allows underscores/dashes). This will break federation with
|
||||||
|
@ -114,6 +114,7 @@ To add configuration to your config file, you can copy it from the base config.
|
||||||
* `Pleroma.Web.ActivityPub.MRF.MentionPolicy`: Drops posts mentioning configurable users. (See [`:mrf_mention`](#mrf_mention)).
|
* `Pleroma.Web.ActivityPub.MRF.MentionPolicy`: Drops posts mentioning configurable users. (See [`:mrf_mention`](#mrf_mention)).
|
||||||
* `Pleroma.Web.ActivityPub.MRF.VocabularyPolicy`: Restricts activities to a configured set of vocabulary. (See [`:mrf_vocabulary`](#mrf_vocabulary)).
|
* `Pleroma.Web.ActivityPub.MRF.VocabularyPolicy`: Restricts activities to a configured set of vocabulary. (See [`:mrf_vocabulary`](#mrf_vocabulary)).
|
||||||
* `Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy`: Rejects or delists posts based on their age when received. (See [`:mrf_object_age`](#mrf_object_age)).
|
* `Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy`: Rejects or delists posts based on their age when received. (See [`:mrf_object_age`](#mrf_object_age)).
|
||||||
|
* `Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy`: Sets a default expiration on all posts made by users of the local instance. Requires `Pleroma.ActivityExpiration` to be enabled for processing the scheduled delections.
|
||||||
* `transparency`: Make the content of your Message Rewrite Facility settings public (via nodeinfo).
|
* `transparency`: Make the content of your Message Rewrite Facility settings public (via nodeinfo).
|
||||||
* `transparency_exclusions`: Exclude specific instance names from MRF transparency. The use of the exclusions feature will be disclosed in nodeinfo as a boolean value.
|
* `transparency_exclusions`: Exclude specific instance names from MRF transparency. The use of the exclusions feature will be disclosed in nodeinfo as a boolean value.
|
||||||
|
|
||||||
|
@ -220,6 +221,8 @@ config :pleroma, :mrf_user_allowlist, %{
|
||||||
|
|
||||||
## Pleroma.ActivityExpiration
|
## Pleroma.ActivityExpiration
|
||||||
|
|
||||||
|
Enables the worker which processes posts scheduled for deletion. Pinned posts are exempt from expiration.
|
||||||
|
|
||||||
* `enabled`: whether expired activities will be sent to the job queue to be deleted
|
* `enabled`: whether expired activities will be sent to the job queue to be deleted
|
||||||
|
|
||||||
## Frontends
|
## Frontends
|
||||||
|
@ -549,6 +552,7 @@ the source code is here: [kocaptcha](https://github.com/koto-bank/kocaptcha). Th
|
||||||
* `proxy_remote`: If you're using a remote uploader, Pleroma will proxy media requests instead of redirecting to it.
|
* `proxy_remote`: If you're using a remote uploader, Pleroma will proxy media requests instead of redirecting to it.
|
||||||
* `proxy_opts`: Proxy options, see `Pleroma.ReverseProxy` documentation.
|
* `proxy_opts`: Proxy options, see `Pleroma.ReverseProxy` documentation.
|
||||||
* `filename_display_max_length`: Set max length of a filename to display. 0 = no limit. Default: 30.
|
* `filename_display_max_length`: Set max length of a filename to display. 0 = no limit. Default: 30.
|
||||||
|
* `default_description`: Sets which default description an image has if none is set explicitly. Options: nil (default) - Don't set a default, :filename - use the filename of the file, a string (e.g. "attachment") - Use this string
|
||||||
|
|
||||||
!!! warning
|
!!! warning
|
||||||
`strip_exif` has been replaced by `Pleroma.Upload.Filter.Mogrify`.
|
`strip_exif` has been replaced by `Pleroma.Upload.Filter.Mogrify`.
|
||||||
|
@ -858,9 +862,6 @@ Warning: it's discouraged to use this feature because of the associated security
|
||||||
|
|
||||||
### :auth
|
### :auth
|
||||||
|
|
||||||
* `Pleroma.Web.Auth.PleromaAuthenticator`: default database authenticator.
|
|
||||||
* `Pleroma.Web.Auth.LDAPAuthenticator`: LDAP authentication.
|
|
||||||
|
|
||||||
Authentication / authorization settings.
|
Authentication / authorization settings.
|
||||||
|
|
||||||
* `auth_template`: authentication form template. By default it's `show.html` which corresponds to `lib/pleroma/web/templates/o_auth/o_auth/show.html.eex`.
|
* `auth_template`: authentication form template. By default it's `show.html` which corresponds to `lib/pleroma/web/templates/o_auth/o_auth/show.html.eex`.
|
||||||
|
@ -890,6 +891,9 @@ Pleroma account will be created with the same name as the LDAP user name.
|
||||||
* `base`: LDAP base, e.g. "dc=example,dc=com"
|
* `base`: LDAP base, e.g. "dc=example,dc=com"
|
||||||
* `uid`: LDAP attribute name to authenticate the user, e.g. when "cn", the filter will be "cn=username,base"
|
* `uid`: LDAP attribute name to authenticate the user, e.g. when "cn", the filter will be "cn=username,base"
|
||||||
|
|
||||||
|
Note, if your LDAP server is an Active Directory server the correct value is commonly `uid: "cn"`, but if you use an
|
||||||
|
OpenLDAP server the value may be `uid: "uid"`.
|
||||||
|
|
||||||
### OAuth consumer mode
|
### OAuth consumer mode
|
||||||
|
|
||||||
OAuth consumer mode allows sign in / sign up via external OAuth providers (e.g. Twitter, Facebook, Google, Microsoft, etc.).
|
OAuth consumer mode allows sign in / sign up via external OAuth providers (e.g. Twitter, Facebook, Google, Microsoft, etc.).
|
||||||
|
@ -1048,6 +1052,8 @@ Restrict access for unauthenticated users to timelines (public and federated), u
|
||||||
* `local`
|
* `local`
|
||||||
* `remote`
|
* `remote`
|
||||||
|
|
||||||
|
Note: when `:instance, :public` is set to `false`, all `:restrict_unauthenticated` items be effectively set to `true` by default. If you'd like to allow unauthenticated access to specific API endpoints on a private instance, please explicitly set `:restrict_unauthenticated` to non-default value in `config/prod.secret.exs`.
|
||||||
|
|
||||||
Note: setting `restrict_unauthenticated/timelines/local` to `true` has no practical sense if `restrict_unauthenticated/timelines/federated` is set to `false` (since local public activities will still be delivered to unauthenticated users as part of federated timeline).
|
Note: setting `restrict_unauthenticated/timelines/local` to `true` has no practical sense if `restrict_unauthenticated/timelines/federated` is set to `false` (since local public activities will still be delivered to unauthenticated users as part of federated timeline).
|
||||||
|
|
||||||
## Pleroma.Web.ApiSpec.CastAndValidate
|
## Pleroma.Web.ApiSpec.CastAndValidate
|
||||||
|
|
|
@ -1,45 +1,61 @@
|
||||||
# Static Directory
|
# Static Directory
|
||||||
|
|
||||||
Static frontend files are shipped in `priv/static/` and tracked by version control in this repository. If you want to overwrite or update these without the possibility of merge conflicts, you can write your custom versions to `instance/static/`.
|
Static frontend files are shipped with pleroma. If you want to overwrite or update these without problems during upgrades, you can write your custom versions to the static directory.
|
||||||
|
|
||||||
```
|
You can find the location of the static directory in the [configuration](../cheatsheet/#instance).
|
||||||
config :pleroma, :instance,
|
|
||||||
static_dir: "instance/static/",
|
|
||||||
```
|
|
||||||
|
|
||||||
For example, edit `instance/static/instance/panel.html` .
|
=== "OTP"
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
config :pleroma, :instance,
|
||||||
|
static_dir: "/var/lib/pleroma/static/"
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
config :pleroma, :instance,
|
||||||
|
static_dir: "instance/static/"
|
||||||
|
```
|
||||||
|
|
||||||
Alternatively, you can overwrite this value in your configuration to use a different static instance directory.
|
Alternatively, you can overwrite this value in your configuration to use a different static instance directory.
|
||||||
|
|
||||||
This document is written assuming `instance/static/`.
|
This document is written using `$static_dir` as the value of the `config :pleroma, :instance, static_dir` setting.
|
||||||
|
|
||||||
Or, if you want to manage your custom file in git repository, basically remove the `instance/` entry from `.gitignore`.
|
If you use a From Source installation and want to manage your custom files in the git repository, you can remove the `instance/` entry from `.gitignore`.
|
||||||
|
|
||||||
## robots.txt
|
## robots.txt
|
||||||
|
|
||||||
By default, the `robots.txt` that ships in `priv/static/` is permissive. It allows well-behaved search engines to index all of your instance's URIs.
|
There's a mix tasks to [generate a new robot.txt](../../administration/CLI_tasks/robots_txt/).
|
||||||
|
|
||||||
If you want to generate a restrictive `robots.txt`, you can run the following mix task. The generated `robots.txt` will be written in your instance static directory.
|
For more complex things, you can write your own robots.txt to `$static_dir/robots.txt`.
|
||||||
|
|
||||||
|
E.g. if you want to block all crawlers except for [fediverse.network](https://fediverse.network/about) you can use
|
||||||
|
|
||||||
```
|
```
|
||||||
mix pleroma.robots_txt disallow_all
|
User-Agent: *
|
||||||
|
Disallow: /
|
||||||
|
|
||||||
|
User-Agent: crawler-us-il-1.fediverse.network
|
||||||
|
Allow: /
|
||||||
|
|
||||||
|
User-Agent: makhnovtchina.random.sh
|
||||||
|
Allow: /
|
||||||
```
|
```
|
||||||
|
|
||||||
## Thumbnail
|
## Thumbnail
|
||||||
|
|
||||||
Put on `instance/static/instance/thumbnail.jpeg` with your selfie or other neat picture. It will appear in [Pleroma Instances](http://distsn.org/pleroma-instances.html).
|
Add `$static_dir/instance/thumbnail.jpeg` with your selfie or other neat picture. It will be available on `http://your-domain.tld/instance/thumbnail.jpeg` and can be used by external applications.
|
||||||
|
|
||||||
## Instance-specific panel
|
## Instance-specific panel
|
||||||
|
|
||||||
![instance-specific panel demo](/uploads/296b19ec806b130e0b49b16bfe29ce8a/image.png)
|
Create and Edit your file at `$static_dir/instance/panel.html`.
|
||||||
|
|
||||||
Create and Edit your file on `instance/static/instance/panel.html`.
|
|
||||||
|
|
||||||
## Background
|
## Background
|
||||||
|
|
||||||
You can change the background of your Pleroma instance by uploading it to `instance/static/`, and then changing `background` in `config/prod.secret.exs` accordingly.
|
You can change the background of your Pleroma instance by uploading it to `$static_dir/`, and then changing `background` in [your configuration](../cheatsheet/#frontend_configurations) accordingly.
|
||||||
|
|
||||||
If you put `instance/static/images/background.jpg`
|
E.g. if you put `$static_dir/images/background.jpg`
|
||||||
|
|
||||||
```
|
```
|
||||||
config :pleroma, :frontend_configurations,
|
config :pleroma, :frontend_configurations,
|
||||||
|
@ -50,12 +66,14 @@ config :pleroma, :frontend_configurations,
|
||||||
|
|
||||||
## Logo
|
## Logo
|
||||||
|
|
||||||
![logo modification demo](/uploads/c70b14de60fa74245e7f0dcfa695ebff/image.png)
|
!!! important
|
||||||
|
Note the extra `static` folder for the default logo.png location
|
||||||
|
|
||||||
If you want to give a brand to your instance, You can change the logo of your instance by uploading it to `instance/static/`.
|
If you want to give a brand to your instance, You can change the logo of your instance by uploading it to the static directory `$static_dir/static/logo.png`.
|
||||||
|
|
||||||
Alternatively, you can specify the path with config.
|
Alternatively, you can specify the path to your logo in [your configuration](../cheatsheet/#frontend_configurations).
|
||||||
If you put `instance/static/static/mylogo-file.png`
|
|
||||||
|
E.g. if you put `$static_dir/static/mylogo-file.png`
|
||||||
|
|
||||||
```
|
```
|
||||||
config :pleroma, :frontend_configurations,
|
config :pleroma, :frontend_configurations,
|
||||||
|
@ -66,4 +84,7 @@ config :pleroma, :frontend_configurations,
|
||||||
|
|
||||||
## Terms of Service
|
## Terms of Service
|
||||||
|
|
||||||
Terms of Service will be shown to all users on the registration page. It's the best place where to write down the rules for your instance. You can modify the rules by changing `instance/static/static/terms-of-service.html`.
|
!!! important
|
||||||
|
Note the extra `static` folder for the terms-of-service.html
|
||||||
|
|
||||||
|
Terms of Service will be shown to all users on the registration page. It's the best place where to write down the rules for your instance. You can modify the rules by adding and changing `$static_dir/static/terms-of-service.html`.
|
||||||
|
|
|
@ -14,6 +14,7 @@ It assumes that you have administrative rights, either as root or a user with [s
|
||||||
* `erlang-xmerl`
|
* `erlang-xmerl`
|
||||||
* `git`
|
* `git`
|
||||||
* Development Tools
|
* Development Tools
|
||||||
|
* `cmake`
|
||||||
|
|
||||||
#### Optional packages used in this guide
|
#### Optional packages used in this guide
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ sudo apk upgrade
|
||||||
* Install some tools, which are needed later:
|
* Install some tools, which are needed later:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo apk add git build-base
|
sudo apk add git build-base cmake
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install Elixir and Erlang
|
### Install Elixir and Erlang
|
||||||
|
|
|
@ -9,6 +9,7 @@ This guide will assume that you have administrative rights, either as root or a
|
||||||
* `elixir`
|
* `elixir`
|
||||||
* `git`
|
* `git`
|
||||||
* `base-devel`
|
* `base-devel`
|
||||||
|
* `cmake`
|
||||||
|
|
||||||
#### Optional packages used in this guide
|
#### Optional packages used in this guide
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ sudo pacman -Syu
|
||||||
* Install some of the above mentioned programs:
|
* Install some of the above mentioned programs:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo pacman -S git base-devel elixir
|
sudo pacman -S git base-devel elixir cmake
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install PostgreSQL
|
### Install PostgreSQL
|
||||||
|
|
|
@ -12,6 +12,7 @@ This guide will assume you are on Debian Stretch. This guide should also work wi
|
||||||
* `erlang-nox`
|
* `erlang-nox`
|
||||||
* `git`
|
* `git`
|
||||||
* `build-essential`
|
* `build-essential`
|
||||||
|
* `cmake`
|
||||||
|
|
||||||
#### Optional packages used in this guide
|
#### Optional packages used in this guide
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ sudo apt full-upgrade
|
||||||
* Install some of the above mentioned programs:
|
* Install some of the above mentioned programs:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo apt install git build-essential postgresql postgresql-contrib
|
sudo apt install git build-essential postgresql postgresql-contrib cmake
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install Elixir and Erlang
|
### Install Elixir and Erlang
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
- `erlang-nox`
|
- `erlang-nox`
|
||||||
- `git`
|
- `git`
|
||||||
- `build-essential`
|
- `build-essential`
|
||||||
|
- `cmake`
|
||||||
|
|
||||||
#### このガイドで利用している追加パッケージ
|
#### このガイドで利用している追加パッケージ
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ sudo apt full-upgrade
|
||||||
|
|
||||||
* 上記に挙げたパッケージをインストールしておきます。
|
* 上記に挙げたパッケージをインストールしておきます。
|
||||||
```
|
```
|
||||||
sudo apt install git build-essential postgresql postgresql-contrib
|
sudo apt install git build-essential postgresql postgresql-contrib cmake
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,210 @@
|
||||||
|
# Installing on FreeBSD
|
||||||
|
|
||||||
|
This document was written for FreeBSD 12.1, but should be work on future releases.
|
||||||
|
|
||||||
|
## Required software
|
||||||
|
|
||||||
|
This assumes the target system has `pkg(8)`.
|
||||||
|
|
||||||
|
```
|
||||||
|
# pkg install elixir postgresql12-server postgresql12-client postgresql12-contrib git-lite sudo nginx gmake acme.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Copy the rc.d scripts to the right directory:
|
||||||
|
|
||||||
|
Setup the required services to automatically start at boot, using `sysrc(8)`.
|
||||||
|
|
||||||
|
```
|
||||||
|
# sysrc nginx_enable=YES
|
||||||
|
# sysrc postgresql_enable=YES
|
||||||
|
```
|
||||||
|
|
||||||
|
## Initialize postgres
|
||||||
|
|
||||||
|
```
|
||||||
|
# service postgresql initdb
|
||||||
|
# service postgresql start
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuring Pleroma
|
||||||
|
|
||||||
|
Create a user for Pleroma:
|
||||||
|
|
||||||
|
```
|
||||||
|
# pw add user pleroma -m
|
||||||
|
# echo 'export LC_ALL="en_US.UTF-8"' >> /home/pleroma/.profile
|
||||||
|
# su -l pleroma
|
||||||
|
```
|
||||||
|
|
||||||
|
Clone the repository:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ cd $HOME # Should be the same as /home/pleroma
|
||||||
|
$ git clone -b stable https://git.pleroma.social/pleroma/pleroma.git
|
||||||
|
```
|
||||||
|
|
||||||
|
Configure Pleroma. Note that you need a domain name at this point:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ cd /home/pleroma/pleroma
|
||||||
|
$ mix deps.get # Enter "y" when asked to install Hex
|
||||||
|
$ mix pleroma.instance gen # You will be asked a few questions here.
|
||||||
|
$ cp config/generated_config.exs config/prod.secret.exs
|
||||||
|
```
|
||||||
|
|
||||||
|
Since Postgres is configured, we can now initialize the database. There should
|
||||||
|
now be a file in `config/setup_db.psql` that makes this easier. Edit it, and
|
||||||
|
*change the password* to a password of your choice. Make sure it is secure, since
|
||||||
|
it'll be protecting your database. As root, you can now initialize the database:
|
||||||
|
|
||||||
|
```
|
||||||
|
# cd /home/pleroma/pleroma
|
||||||
|
# sudo -Hu postgres -g postgres psql -f config/setup_db.psql
|
||||||
|
```
|
||||||
|
|
||||||
|
Postgres allows connections from all users without a password by default. To
|
||||||
|
fix this, edit `/var/db/postgres/data12/pg_hba.conf`. Change every `trust` to
|
||||||
|
`password`.
|
||||||
|
|
||||||
|
Once this is done, restart Postgres with:
|
||||||
|
```
|
||||||
|
# service postgresql restart
|
||||||
|
```
|
||||||
|
|
||||||
|
Run the database migrations.
|
||||||
|
|
||||||
|
Back as the pleroma user, run the following to implement any database migrations.
|
||||||
|
|
||||||
|
```
|
||||||
|
# su -l pleroma
|
||||||
|
$ cd /home/pleroma/pleroma
|
||||||
|
$ MIX_ENV=prod mix ecto.migrate
|
||||||
|
```
|
||||||
|
|
||||||
|
You will need to do this whenever you update with `git pull`:
|
||||||
|
|
||||||
|
## Configuring acme.sh
|
||||||
|
|
||||||
|
We'll be using acme.sh in Stateless Mode for TLS certificate renewal.
|
||||||
|
|
||||||
|
First, as root, allow the user `acme` to have access to the acme log file, as follows:
|
||||||
|
|
||||||
|
```
|
||||||
|
# touch /var/log/acme.sh.log
|
||||||
|
# chown acme:acme /var/log/acme.sh.log
|
||||||
|
# chmod 600 /var/log/acme.sh.log
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, obtain your account fingerprint:
|
||||||
|
|
||||||
|
```
|
||||||
|
# sudo -Hu acme -g acme acme.sh --register-account
|
||||||
|
```
|
||||||
|
|
||||||
|
You need to add the following to your nginx configuration for the server
|
||||||
|
running on port 80:
|
||||||
|
|
||||||
|
```
|
||||||
|
location ~ ^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)$ {
|
||||||
|
default_type text/plain;
|
||||||
|
return 200 "$1.6fXAG9VyG0IahirPEU2ZerUtItW2DHzDzD9wZaEKpqd";
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the string after after `$1.` with your fingerprint.
|
||||||
|
|
||||||
|
Start nginx:
|
||||||
|
|
||||||
|
```
|
||||||
|
# service nginx start
|
||||||
|
```
|
||||||
|
|
||||||
|
It should now be possible to issue a cert (replace `example.com`
|
||||||
|
with your domain name):
|
||||||
|
|
||||||
|
```
|
||||||
|
# sudo -Hu acme -g acme acme.sh --issue -d example.com --stateless
|
||||||
|
```
|
||||||
|
|
||||||
|
Let's add auto-renewal to `/etc/crontab`
|
||||||
|
(replace `example.com` with your domain):
|
||||||
|
|
||||||
|
```
|
||||||
|
/usr/local/bin/sudo -Hu acme -g acme /usr/local/sbin/acme.sh -r -d example.com --stateless
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuring nginx
|
||||||
|
|
||||||
|
FreeBSD's default nginx configuration does not contain an include directive, which is
|
||||||
|
typically used for multiple sites. Therefore, you will need to first create the required
|
||||||
|
directory as follows:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
# mkdir -p /usr/local/etc/nginx/sites-available
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, add an `include` directive to `/usr/local/etc/nginx/nginx.conf`, within the `http {}`
|
||||||
|
block, as follows:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
http {
|
||||||
|
...
|
||||||
|
include /usr/local/etc/nginx/sites-available/*;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
As root, copy `/home/pleroma/pleroma/installation/pleroma.nginx` to
|
||||||
|
`/usr/local/etc/nginx/sites-available/pleroma.nginx`.
|
||||||
|
|
||||||
|
Edit the defaults of `/usr/local/etc/nginx/sites-available/pleroma.nginx`:
|
||||||
|
|
||||||
|
* Change `ssl_trusted_certificate` to `/var/db/acme/certs/example.tld/example.tld.cer`.
|
||||||
|
* Change `ssl_certificate` to `/var/db/acme/certs/example.tld/fullchain.cer`.
|
||||||
|
* Change `ssl_certificate_key` to `/var/db/acme/certs/example.tld/example.tld.key`.
|
||||||
|
* Change all references of `example.tld` to your instance's domain name.
|
||||||
|
|
||||||
|
## Creating a startup script for Pleroma
|
||||||
|
|
||||||
|
Pleroma will need to compile when it initially starts, which typically takes a longer
|
||||||
|
period of time. Therefore, it is good practice to initially run pleroma from the
|
||||||
|
command-line before utilizing the rc.d script. That is done as follows:
|
||||||
|
|
||||||
|
```
|
||||||
|
# su -l pleroma
|
||||||
|
$ cd $HOME/pleroma
|
||||||
|
$ MIX_ENV=prod mix phx.server
|
||||||
|
```
|
||||||
|
|
||||||
|
Copy the startup script to the correct location and make sure it's executable:
|
||||||
|
|
||||||
|
```
|
||||||
|
# cp /home/pleroma/pleroma/installation/freebsd/rc.d/pleroma /usr/local/etc/rc.d/pleroma
|
||||||
|
# chmod +x /usr/local/etc/rc.d/pleroma
|
||||||
|
```
|
||||||
|
|
||||||
|
Update the `/etc/rc.conf` and start pleroma with the following commands:
|
||||||
|
|
||||||
|
```
|
||||||
|
# sysrc pleroma_enable=YES
|
||||||
|
# service pleroma start
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Create your first user
|
||||||
|
|
||||||
|
If your instance is up and running, you can create your first user with administrative rights with the following task:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress> --admin
|
||||||
|
```
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
Restart nginx with `# service nginx restart` and you should be up and running.
|
||||||
|
|
||||||
|
Make sure your time is in sync, or other instances will receive your posts with
|
||||||
|
incorrect timestamps. You should have ntpd running.
|
||||||
|
|
||||||
|
## Questions
|
||||||
|
|
||||||
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
|
@ -28,6 +28,7 @@ Gentoo quite pointedly does not come with a cron daemon installed, and as such i
|
||||||
* `dev-db/postgresql`
|
* `dev-db/postgresql`
|
||||||
* `dev-lang/elixir`
|
* `dev-lang/elixir`
|
||||||
* `dev-vcs/git`
|
* `dev-vcs/git`
|
||||||
|
* `dev-util/cmake`
|
||||||
|
|
||||||
#### Optional ebuilds used in this guide
|
#### Optional ebuilds used in this guide
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ Gentoo quite pointedly does not come with a cron daemon installed, and as such i
|
||||||
* Emerge all required the required and suggested software in one go:
|
* Emerge all required the required and suggested software in one go:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# emerge --ask dev-db/postgresql dev-lang/elixir dev-vcs/git www-servers/nginx app-crypt/certbot app-crypt/certbot-nginx
|
# emerge --ask dev-db/postgresql dev-lang/elixir dev-vcs/git www-servers/nginx app-crypt/certbot app-crypt/certbot-nginx dev-util/cmake
|
||||||
```
|
```
|
||||||
|
|
||||||
If you would not like to install the optional packages, remove them from this line.
|
If you would not like to install the optional packages, remove them from this line.
|
||||||
|
|
|
@ -8,13 +8,15 @@ You will be running commands as root. If you aren't root already, please elevate
|
||||||
|
|
||||||
The system needs to have `curl` and `unzip` installed for downloading and unpacking release builds.
|
The system needs to have `curl` and `unzip` installed for downloading and unpacking release builds.
|
||||||
|
|
||||||
```sh tab="Alpine"
|
=== "Alpine"
|
||||||
apk add curl unzip
|
```sh
|
||||||
```
|
apk add curl unzip
|
||||||
|
```
|
||||||
|
|
||||||
```sh tab="Debian/Ubuntu"
|
=== "Debian/Ubuntu"
|
||||||
apt install curl unzip
|
```sh
|
||||||
```
|
apt install curl unzip
|
||||||
|
```
|
||||||
|
|
||||||
## Moving content out of the application directory
|
## Moving content out of the application directory
|
||||||
When using OTP releases the application directory changes with every version so it would be a bother to keep content there (and also dangerous unless `--no-rm` option is used when updating). Fortunately almost all paths in Pleroma are configurable, so it is possible to move them out of there.
|
When using OTP releases the application directory changes with every version so it would be a bother to keep content there (and also dangerous unless `--no-rm` option is used when updating). Fortunately almost all paths in Pleroma are configurable, so it is possible to move them out of there.
|
||||||
|
@ -110,27 +112,29 @@ OTP releases have different service files than from-source installs so they need
|
||||||
|
|
||||||
**Warning:** The service files assume pleroma user's home directory is `/opt/pleroma`, please make sure all paths fit your installation.
|
**Warning:** The service files assume pleroma user's home directory is `/opt/pleroma`, please make sure all paths fit your installation.
|
||||||
|
|
||||||
```sh tab="Alpine"
|
=== "Alpine"
|
||||||
# Copy the service into a proper directory
|
```sh
|
||||||
cp -f ~pleroma/installation/init.d/pleroma /etc/init.d/pleroma
|
# Copy the service into a proper directory
|
||||||
|
cp -f ~pleroma/installation/init.d/pleroma /etc/init.d/pleroma
|
||||||
|
|
||||||
# Start pleroma
|
# Start pleroma
|
||||||
rc-service pleroma start
|
rc-service pleroma start
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh tab="Debian/Ubuntu"
|
=== "Debian/Ubuntu"
|
||||||
# Copy the service into a proper directory
|
```sh
|
||||||
cp ~pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
|
# Copy the service into a proper directory
|
||||||
|
cp ~pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
|
||||||
|
|
||||||
# Reload service files
|
# Reload service files
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
# Reenable pleroma to start on boot
|
# Reenable pleroma to start on boot
|
||||||
systemctl reenable pleroma
|
systemctl reenable pleroma
|
||||||
|
|
||||||
# Start pleroma
|
# Start pleroma
|
||||||
systemctl start pleroma
|
systemctl start pleroma
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running mix tasks
|
## Running mix tasks
|
||||||
Refer to [Running mix tasks](otp_en.md#running-mix-tasks) section from OTP release installation guide.
|
Refer to [Running mix tasks](otp_en.md#running-mix-tasks) section from OTP release installation guide.
|
||||||
|
|
|
@ -19,6 +19,7 @@ databases/postgresql11-client
|
||||||
databases/postgresql11-server
|
databases/postgresql11-server
|
||||||
devel/git-base
|
devel/git-base
|
||||||
devel/git-docs
|
devel/git-docs
|
||||||
|
devel/cmake
|
||||||
lang/elixir
|
lang/elixir
|
||||||
security/acmesh
|
security/acmesh
|
||||||
security/sudo
|
security/sudo
|
||||||
|
|
|
@ -14,11 +14,12 @@ The following packages need to be installed:
|
||||||
* git
|
* git
|
||||||
* postgresql-server
|
* postgresql-server
|
||||||
* postgresql-contrib
|
* postgresql-contrib
|
||||||
|
* cmake
|
||||||
|
|
||||||
To install them, run the following command (with doas or as root):
|
To install them, run the following command (with doas or as root):
|
||||||
|
|
||||||
```
|
```
|
||||||
pkg_add elixir gmake ImageMagick git postgresql-server postgresql-contrib
|
pkg_add elixir gmake ImageMagick git postgresql-server postgresql-contrib cmake
|
||||||
```
|
```
|
||||||
|
|
||||||
Pleroma requires a reverse proxy, OpenBSD has relayd in base (and is used in this guide) and packages/ports are available for nginx (www/nginx) and apache (www/apache-httpd). Independently of the reverse proxy, [acme-client(1)](https://man.openbsd.org/acme-client) can be used to get a certificate from Let's Encrypt.
|
Pleroma requires a reverse proxy, OpenBSD has relayd in base (and is used in this guide) and packages/ports are available for nginx (www/nginx) and apache (www/apache-httpd). Independently of the reverse proxy, [acme-client(1)](https://man.openbsd.org/acme-client) can be used to get a certificate from Let's Encrypt.
|
||||||
|
|
|
@ -16,7 +16,7 @@ Matrix-kanava #freenode_#pleroma:matrix.org ovat hyviä paikkoja löytää apua
|
||||||
|
|
||||||
Asenna tarvittava ohjelmisto:
|
Asenna tarvittava ohjelmisto:
|
||||||
|
|
||||||
`# pkg_add git elixir gmake postgresql-server-10.3 postgresql-contrib-10.3`
|
`# pkg_add git elixir gmake postgresql-server-10.3 postgresql-contrib-10.3 cmake`
|
||||||
|
|
||||||
Luo postgresql-tietokanta:
|
Luo postgresql-tietokanta:
|
||||||
|
|
||||||
|
|
|
@ -28,15 +28,17 @@ Other than things bundled in the OTP release Pleroma depends on:
|
||||||
* nginx (could be swapped with another reverse proxy but this guide covers only it)
|
* nginx (could be swapped with another reverse proxy but this guide covers only it)
|
||||||
* certbot (for Let's Encrypt certificates, could be swapped with another ACME client, but this guide covers only it)
|
* certbot (for Let's Encrypt certificates, could be swapped with another ACME client, but this guide covers only it)
|
||||||
|
|
||||||
```sh tab="Alpine"
|
=== "Alpine"
|
||||||
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
|
```
|
||||||
apk update
|
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
|
||||||
apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot
|
apk update
|
||||||
```
|
apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot
|
||||||
|
```
|
||||||
|
|
||||||
```sh tab="Debian/Ubuntu"
|
=== "Debian/Ubuntu"
|
||||||
apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot
|
```
|
||||||
```
|
apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot
|
||||||
|
```
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
### Configuring PostgreSQL
|
### Configuring PostgreSQL
|
||||||
|
@ -47,31 +49,35 @@ apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot
|
||||||
|
|
||||||
RUM indexes are an alternative indexing scheme that is not included in PostgreSQL by default. You can read more about them on the [Configuration page](../configuration/cheatsheet.md#rum-indexing-for-full-text-search). They are completely optional and most of the time are not worth it, especially if you are running a single user instance (unless you absolutely need ordered search results).
|
RUM indexes are an alternative indexing scheme that is not included in PostgreSQL by default. You can read more about them on the [Configuration page](../configuration/cheatsheet.md#rum-indexing-for-full-text-search). They are completely optional and most of the time are not worth it, especially if you are running a single user instance (unless you absolutely need ordered search results).
|
||||||
|
|
||||||
```sh tab="Alpine"
|
=== "Alpine"
|
||||||
apk add git build-base postgresql-dev
|
```
|
||||||
git clone https://github.com/postgrespro/rum /tmp/rum
|
apk add git build-base postgresql-dev
|
||||||
cd /tmp/rum
|
git clone https://github.com/postgrespro/rum /tmp/rum
|
||||||
make USE_PGXS=1
|
cd /tmp/rum
|
||||||
make USE_PGXS=1 install
|
make USE_PGXS=1
|
||||||
cd
|
make USE_PGXS=1 install
|
||||||
rm -r /tmp/rum
|
cd
|
||||||
```
|
rm -r /tmp/rum
|
||||||
|
```
|
||||||
|
|
||||||
```sh tab="Debian/Ubuntu"
|
=== "Debian/Ubuntu"
|
||||||
# Available only on Buster/19.04
|
```
|
||||||
apt install postgresql-11-rum
|
# Available only on Buster/19.04
|
||||||
```
|
apt install postgresql-11-rum
|
||||||
|
```
|
||||||
|
|
||||||
#### (Optional) Performance configuration
|
#### (Optional) Performance configuration
|
||||||
It is encouraged to check [Optimizing your PostgreSQL performance](../configuration/postgresql.md) document, for tips on PostgreSQL tuning.
|
It is encouraged to check [Optimizing your PostgreSQL performance](../configuration/postgresql.md) document, for tips on PostgreSQL tuning.
|
||||||
|
|
||||||
```sh tab="Alpine"
|
=== "Alpine"
|
||||||
rc-service postgresql restart
|
```
|
||||||
```
|
rc-service postgresql restart
|
||||||
|
```
|
||||||
|
|
||||||
```sh tab="Debian/Ubuntu"
|
=== "Debian/Ubuntu"
|
||||||
systemctl restart postgresql
|
```
|
||||||
```
|
systemctl restart postgresql
|
||||||
|
```
|
||||||
|
|
||||||
If you are using PostgreSQL 12 or higher, add this to your Ecto database configuration
|
If you are using PostgreSQL 12 or higher, add this to your Ecto database configuration
|
||||||
|
|
||||||
|
@ -121,9 +127,6 @@ chown -R pleroma /etc/pleroma
|
||||||
# Run the config generator
|
# Run the config generator
|
||||||
su pleroma -s $SHELL -lc "./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql"
|
su pleroma -s $SHELL -lc "./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql"
|
||||||
|
|
||||||
# Run the environment file generator.
|
|
||||||
su pleroma -s $SHELL -lc "./bin/pleroma_ctl release_env gen"
|
|
||||||
|
|
||||||
# Create the postgres database
|
# Create the postgres database
|
||||||
su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"
|
su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"
|
||||||
|
|
||||||
|
@ -134,7 +137,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/"
|
# 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
|
# 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
|
# 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
|
sleep 20 && curl http://localhost:4000/api/v1/instance
|
||||||
|
@ -154,14 +157,16 @@ certbot certonly --standalone --preferred-challenges http -d yourinstance.tld
|
||||||
|
|
||||||
The location of nginx configs is dependent on the distro
|
The location of nginx configs is dependent on the distro
|
||||||
|
|
||||||
```sh tab="Alpine"
|
=== "Alpine"
|
||||||
cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/conf.d/pleroma.conf
|
```
|
||||||
```
|
cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/conf.d/pleroma.conf
|
||||||
|
```
|
||||||
|
|
||||||
```sh tab="Debian/Ubuntu"
|
=== "Debian/Ubuntu"
|
||||||
cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/sites-available/pleroma.conf
|
```
|
||||||
ln -s /etc/nginx/sites-available/pleroma.conf /etc/nginx/sites-enabled/pleroma.conf
|
cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/sites-available/pleroma.conf
|
||||||
```
|
ln -s /etc/nginx/sites-available/pleroma.conf /etc/nginx/sites-enabled/pleroma.conf
|
||||||
|
```
|
||||||
|
|
||||||
If your distro does not have either of those you can append `include /etc/nginx/pleroma.conf` to the end of the http section in /etc/nginx/nginx.conf and
|
If your distro does not have either of those you can append `include /etc/nginx/pleroma.conf` to the end of the http section in /etc/nginx/nginx.conf and
|
||||||
```sh
|
```sh
|
||||||
|
@ -178,36 +183,39 @@ nginx -t
|
||||||
```
|
```
|
||||||
#### Start nginx
|
#### Start nginx
|
||||||
|
|
||||||
```sh tab="Alpine"
|
=== "Alpine"
|
||||||
rc-service nginx start
|
```
|
||||||
```
|
rc-service nginx start
|
||||||
|
```
|
||||||
|
|
||||||
```sh tab="Debian/Ubuntu"
|
=== "Debian/Ubuntu"
|
||||||
systemctl start nginx
|
```
|
||||||
```
|
systemctl start nginx
|
||||||
|
```
|
||||||
|
|
||||||
At this point if you open your (sub)domain in a browser you should see a 502 error, that's because Pleroma is not started yet.
|
At this point if you open your (sub)domain in a browser you should see a 502 error, that's because Pleroma is not started yet.
|
||||||
|
|
||||||
### Setting up a system service
|
### Setting up a system service
|
||||||
|
|
||||||
```sh tab="Alpine"
|
=== "Alpine"
|
||||||
# Copy the service into a proper directory
|
```
|
||||||
cp /opt/pleroma/installation/init.d/pleroma /etc/init.d/pleroma
|
# Copy the service into a proper directory
|
||||||
|
cp /opt/pleroma/installation/init.d/pleroma /etc/init.d/pleroma
|
||||||
|
|
||||||
# Start pleroma and enable it on boot
|
# Start pleroma and enable it on boot
|
||||||
rc-service pleroma start
|
rc-service pleroma start
|
||||||
rc-update add pleroma
|
rc-update add pleroma
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh tab="Debian/Ubuntu"
|
=== "Debian/Ubuntu"
|
||||||
# Copy the service into a proper directory
|
```
|
||||||
cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
|
# Copy the service into a proper directory
|
||||||
|
cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
|
||||||
|
|
||||||
|
# Start pleroma and enable it on boot
|
||||||
# Start pleroma and enable it on boot
|
systemctl start pleroma
|
||||||
systemctl start pleroma
|
systemctl enable pleroma
|
||||||
systemctl enable pleroma
|
```
|
||||||
```
|
|
||||||
|
|
||||||
If everything worked, you should see Pleroma-FE when visiting your domain. If that didn't happen, try reviewing the installation steps, starting Pleroma in the foreground and seeing if there are any errrors.
|
If everything worked, you should see Pleroma-FE when visiting your domain. If that didn't happen, try reviewing the installation steps, starting Pleroma in the foreground and seeing if there are any errrors.
|
||||||
|
|
||||||
|
@ -227,43 +235,45 @@ $EDITOR path-to-nginx-config
|
||||||
nginx -t
|
nginx -t
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh tab="Alpine"
|
=== "Alpine"
|
||||||
# Restart nginx
|
```
|
||||||
rc-service nginx restart
|
# Restart nginx
|
||||||
|
rc-service nginx restart
|
||||||
|
|
||||||
# Start the cron daemon and make it start on boot
|
# Start the cron daemon and make it start on boot
|
||||||
rc-service crond start
|
rc-service crond start
|
||||||
rc-update add crond
|
rc-update add crond
|
||||||
|
|
||||||
# Ensure the webroot menthod and post hook is working
|
# Ensure the webroot menthod and post hook is working
|
||||||
certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --dry-run --post-hook 'rc-service nginx reload'
|
certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --dry-run --post-hook 'rc-service nginx reload'
|
||||||
|
|
||||||
# Add it to the daily cron
|
# Add it to the daily cron
|
||||||
echo '#!/bin/sh
|
echo '#!/bin/sh
|
||||||
certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --post-hook "rc-service nginx reload"
|
certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --post-hook "rc-service nginx reload"
|
||||||
' > /etc/periodic/daily/renew-pleroma-cert
|
' > /etc/periodic/daily/renew-pleroma-cert
|
||||||
chmod +x /etc/periodic/daily/renew-pleroma-cert
|
chmod +x /etc/periodic/daily/renew-pleroma-cert
|
||||||
|
|
||||||
# If everything worked the output should contain /etc/cron.daily/renew-pleroma-cert
|
# If everything worked the output should contain /etc/cron.daily/renew-pleroma-cert
|
||||||
run-parts --test /etc/periodic/daily
|
run-parts --test /etc/periodic/daily
|
||||||
```
|
```
|
||||||
|
|
||||||
```sh tab="Debian/Ubuntu"
|
=== "Debian/Ubuntu"
|
||||||
# Restart nginx
|
```
|
||||||
systemctl restart nginx
|
# Restart nginx
|
||||||
|
systemctl restart nginx
|
||||||
|
|
||||||
# Ensure the webroot menthod and post hook is working
|
# Ensure the webroot menthod and post hook is working
|
||||||
certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --dry-run --post-hook 'systemctl reload nginx'
|
certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --dry-run --post-hook 'systemctl reload nginx'
|
||||||
|
|
||||||
# Add it to the daily cron
|
# Add it to the daily cron
|
||||||
echo '#!/bin/sh
|
echo '#!/bin/sh
|
||||||
certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --post-hook "systemctl reload nginx"
|
certbot renew --cert-name yourinstance.tld --webroot -w /var/lib/letsencrypt/ --post-hook "systemctl reload nginx"
|
||||||
' > /etc/cron.daily/renew-pleroma-cert
|
' > /etc/cron.daily/renew-pleroma-cert
|
||||||
chmod +x /etc/cron.daily/renew-pleroma-cert
|
chmod +x /etc/cron.daily/renew-pleroma-cert
|
||||||
|
|
||||||
# If everything worked the output should contain /etc/cron.daily/renew-pleroma-cert
|
# If everything worked the output should contain /etc/cron.daily/renew-pleroma-cert
|
||||||
run-parts --test /etc/cron.daily
|
run-parts --test /etc/cron.daily
|
||||||
```
|
```
|
||||||
|
|
||||||
## Create your first user and set as admin
|
## Create your first user and set as admin
|
||||||
```sh
|
```sh
|
||||||
|
@ -279,3 +289,4 @@ This will create an account withe the username of 'joeuser' with the email addre
|
||||||
## Questions
|
## Questions
|
||||||
|
|
||||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# $FreeBSD$
|
||||||
|
# PROVIDE: pleroma
|
||||||
|
# REQUIRE: DAEMON postgresql
|
||||||
|
# KEYWORD: shutdown
|
||||||
|
|
||||||
|
# sudo -u pleroma MIX_ENV=prod elixir --erl \"-detached\" -S mix phx.server
|
||||||
|
|
||||||
|
. /etc/rc.subr
|
||||||
|
|
||||||
|
name=pleroma
|
||||||
|
rcvar=pleroma_enable
|
||||||
|
|
||||||
|
desc="Pleroma Social Media Platform"
|
||||||
|
|
||||||
|
load_rc_config ${name}
|
||||||
|
|
||||||
|
: ${pleroma_user:=pleroma}
|
||||||
|
: ${pleroma_home:=$(getent passwd ${pleroma_user} | awk -F: '{print $6}')}
|
||||||
|
: ${pleroma_chdir:="${pleroma_home}/pleroma"}
|
||||||
|
: ${pleroma_env:="HOME=${pleroma_home} MIX_ENV=prod"}
|
||||||
|
|
||||||
|
command=/usr/local/bin/elixir
|
||||||
|
command_args="--erl \"-detached\" -S /usr/local/bin/mix phx.server"
|
||||||
|
procname="*beam.smp"
|
||||||
|
|
||||||
|
run_rc_command "$1"
|
|
@ -8,7 +8,6 @@ pidfile="/var/run/pleroma.pid"
|
||||||
directory=/opt/pleroma
|
directory=/opt/pleroma
|
||||||
healthcheck_delay=60
|
healthcheck_delay=60
|
||||||
healthcheck_timer=30
|
healthcheck_timer=30
|
||||||
export $(cat /opt/pleroma/config/pleroma.env)
|
|
||||||
|
|
||||||
: ${pleroma_port:-4000}
|
: ${pleroma_port:-4000}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,6 @@ Environment="MIX_ENV=prod"
|
||||||
Environment="HOME=/var/lib/pleroma"
|
Environment="HOME=/var/lib/pleroma"
|
||||||
; Path to the folder containing the Pleroma installation.
|
; Path to the folder containing the Pleroma installation.
|
||||||
WorkingDirectory=/opt/pleroma
|
WorkingDirectory=/opt/pleroma
|
||||||
; Path to the environment file. the file contains RELEASE_COOKIE and etc
|
|
||||||
EnvironmentFile=/opt/pleroma/config/pleroma.env
|
|
||||||
; Path to the Mix binary.
|
; Path to the Mix binary.
|
||||||
ExecStart=/usr/bin/mix phx.server
|
ExecStart=/usr/bin/mix phx.server
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ defmodule Mix.Pleroma do
|
||||||
:swoosh,
|
:swoosh,
|
||||||
:timex
|
:timex
|
||||||
]
|
]
|
||||||
@cachex_children ["object", "user"]
|
@cachex_children ["object", "user", "scrubber"]
|
||||||
@doc "Common functions to be reused in mix tasks"
|
@doc "Common functions to be reused in mix tasks"
|
||||||
def start_pleroma do
|
def start_pleroma do
|
||||||
Pleroma.Config.Holder.save_default()
|
Pleroma.Config.Holder.save_default()
|
||||||
|
|
|
@ -10,6 +10,7 @@ defmodule Mix.Tasks.Pleroma.Database do
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
require Logger
|
require Logger
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
import Ecto.Query
|
||||||
import Mix.Pleroma
|
import Mix.Pleroma
|
||||||
use Mix.Task
|
use Mix.Task
|
||||||
|
|
||||||
|
@ -53,8 +54,6 @@ def run(["update_users_following_followers_counts"]) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(["prune_objects" | args]) do
|
def run(["prune_objects" | args]) do
|
||||||
import Ecto.Query
|
|
||||||
|
|
||||||
{options, [], []} =
|
{options, [], []} =
|
||||||
OptionParser.parse(
|
OptionParser.parse(
|
||||||
args,
|
args,
|
||||||
|
@ -94,8 +93,6 @@ def run(["prune_objects" | args]) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def run(["fix_likes_collections"]) do
|
def run(["fix_likes_collections"]) do
|
||||||
import Ecto.Query
|
|
||||||
|
|
||||||
start_pleroma()
|
start_pleroma()
|
||||||
|
|
||||||
from(object in Object,
|
from(object in Object,
|
||||||
|
@ -130,4 +127,33 @@ def run(["vacuum", args]) do
|
||||||
|
|
||||||
Maintenance.vacuum(args)
|
Maintenance.vacuum(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def run(["ensure_expiration"]) do
|
||||||
|
start_pleroma()
|
||||||
|
days = Pleroma.Config.get([:mrf_activity_expiration, :days], 365)
|
||||||
|
|
||||||
|
Pleroma.Activity
|
||||||
|
|> join(:left, [a], u in assoc(a, :expiration))
|
||||||
|
|> join(:inner, [a, _u], o in Object,
|
||||||
|
on:
|
||||||
|
fragment(
|
||||||
|
"(?->>'id') = COALESCE((?)->'object'->> 'id', (?)->>'object')",
|
||||||
|
o.data,
|
||||||
|
a.data,
|
||||||
|
a.data
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|> where(local: true)
|
||||||
|
|> where([a, u], is_nil(u))
|
||||||
|
|> where([a], fragment("(? ->> 'type'::text) = 'Create'", a.data))
|
||||||
|
|> where([_a, _u, o], fragment("?->>'type' = 'Note'", o.data))
|
||||||
|
|> Pleroma.RepoStreamer.chunk_stream(100)
|
||||||
|
|> Stream.each(fn activities ->
|
||||||
|
Enum.each(activities, fn activity ->
|
||||||
|
expires_at = Timex.shift(activity.inserted_at, days: days)
|
||||||
|
Pleroma.ActivityExpiration.create(activity, expires_at, false)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|> Stream.run()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -41,6 +41,10 @@ def run(args \\ []) do
|
||||||
load_pleroma()
|
load_pleroma()
|
||||||
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
|
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
|
||||||
|
|
||||||
|
if Application.get_env(:pleroma, Pleroma.Repo)[:ssl] do
|
||||||
|
Application.ensure_all_started(:ssl)
|
||||||
|
end
|
||||||
|
|
||||||
opts =
|
opts =
|
||||||
if opts[:to] || opts[:step] || opts[:all],
|
if opts[:to] || opts[:step] || opts[:all],
|
||||||
do: opts,
|
do: opts,
|
||||||
|
|
|
@ -40,6 +40,10 @@ def run(args \\ []) do
|
||||||
load_pleroma()
|
load_pleroma()
|
||||||
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
|
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
|
||||||
|
|
||||||
|
if Application.get_env(:pleroma, Pleroma.Repo)[:ssl] do
|
||||||
|
Application.ensure_all_started(:ssl)
|
||||||
|
end
|
||||||
|
|
||||||
opts =
|
opts =
|
||||||
if opts[:to] || opts[:step] || opts[:all],
|
if opts[:to] || opts[:step] || opts[:all],
|
||||||
do: opts,
|
do: opts,
|
||||||
|
|
|
@ -15,7 +15,7 @@ def run(["ls-packs" | args]) do
|
||||||
{options, [], []} = parse_global_opts(args)
|
{options, [], []} = parse_global_opts(args)
|
||||||
|
|
||||||
url_or_path = options[:manifest] || default_manifest()
|
url_or_path = options[:manifest] || default_manifest()
|
||||||
manifest = fetch_and_decode(url_or_path)
|
manifest = fetch_and_decode!(url_or_path)
|
||||||
|
|
||||||
Enum.each(manifest, fn {name, info} ->
|
Enum.each(manifest, fn {name, info} ->
|
||||||
to_print = [
|
to_print = [
|
||||||
|
@ -42,7 +42,7 @@ def run(["get-packs" | args]) do
|
||||||
|
|
||||||
url_or_path = options[:manifest] || default_manifest()
|
url_or_path = options[:manifest] || default_manifest()
|
||||||
|
|
||||||
manifest = fetch_and_decode(url_or_path)
|
manifest = fetch_and_decode!(url_or_path)
|
||||||
|
|
||||||
for pack_name <- pack_names do
|
for pack_name <- pack_names do
|
||||||
if Map.has_key?(manifest, pack_name) do
|
if Map.has_key?(manifest, pack_name) do
|
||||||
|
@ -92,7 +92,7 @@ def run(["get-packs" | args]) do
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
|
|
||||||
files = fetch_and_decode(files_loc)
|
files = fetch_and_decode!(files_loc)
|
||||||
|
|
||||||
IO.puts(IO.ANSI.format(["Unpacking ", :bright, pack_name]))
|
IO.puts(IO.ANSI.format(["Unpacking ", :bright, pack_name]))
|
||||||
|
|
||||||
|
@ -243,9 +243,11 @@ def run(["reload"]) do
|
||||||
IO.puts("Emoji packs have been reloaded.")
|
IO.puts("Emoji packs have been reloaded.")
|
||||||
end
|
end
|
||||||
|
|
||||||
defp fetch_and_decode(from) do
|
defp fetch_and_decode!(from) do
|
||||||
with {:ok, json} <- fetch(from) do
|
with {:ok, json} <- fetch(from) do
|
||||||
Jason.decode!(json)
|
Jason.decode!(json)
|
||||||
|
else
|
||||||
|
{:error, error} -> raise "#{from} cannot be fetched. Error: #{error} occur."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -35,10 +35,16 @@ def run(["unfollow", target]) do
|
||||||
def run(["list"]) do
|
def run(["list"]) do
|
||||||
start_pleroma()
|
start_pleroma()
|
||||||
|
|
||||||
with {:ok, list} <- Relay.list(true) do
|
with {:ok, list} <- Relay.list() do
|
||||||
list |> Enum.each(&shell_info(&1))
|
Enum.each(list, &print_relay_url/1)
|
||||||
else
|
else
|
||||||
{:error, e} -> shell_error("Error while fetching relay subscription list: #{inspect(e)}")
|
{:error, e} -> shell_error("Error while fetching relay subscription list: #{inspect(e)}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp print_relay_url(%{followed_back: false} = relay) do
|
||||||
|
shell_info("#{relay.actor} - no Accept received (relay didn't follow back)")
|
||||||
|
end
|
||||||
|
|
||||||
|
defp print_relay_url(relay), do: shell_info(relay.actor)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
# Pleroma: A lightweight social networking server
|
|
||||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
|
|
||||||
defmodule Mix.Tasks.Pleroma.ReleaseEnv do
|
|
||||||
use Mix.Task
|
|
||||||
import Mix.Pleroma
|
|
||||||
|
|
||||||
@shortdoc "Generate Pleroma environment file."
|
|
||||||
@moduledoc File.read!("docs/administration/CLI_tasks/release_environments.md")
|
|
||||||
|
|
||||||
def run(["gen" | rest]) do
|
|
||||||
{options, [], []} =
|
|
||||||
OptionParser.parse(
|
|
||||||
rest,
|
|
||||||
strict: [
|
|
||||||
force: :boolean,
|
|
||||||
path: :string
|
|
||||||
],
|
|
||||||
aliases: [
|
|
||||||
p: :path,
|
|
||||||
f: :force
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
file_path =
|
|
||||||
get_option(
|
|
||||||
options,
|
|
||||||
:path,
|
|
||||||
"Environment file path",
|
|
||||||
"./config/pleroma.env"
|
|
||||||
)
|
|
||||||
|
|
||||||
env_path = Path.expand(file_path)
|
|
||||||
|
|
||||||
proceed? =
|
|
||||||
if File.exists?(env_path) do
|
|
||||||
get_option(
|
|
||||||
options,
|
|
||||||
:force,
|
|
||||||
"Environment file already exists. Do you want to overwrite the #{env_path} file? (y/n)",
|
|
||||||
"n"
|
|
||||||
) === "y"
|
|
||||||
else
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
if proceed? do
|
|
||||||
case do_generate(env_path) do
|
|
||||||
{:error, reason} ->
|
|
||||||
shell_error(
|
|
||||||
File.Error.message(%{action: "write to file", reason: reason, path: env_path})
|
|
||||||
)
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
shell_info("\nThe file generated: #{env_path}.\n")
|
|
||||||
|
|
||||||
shell_info("""
|
|
||||||
WARNING: before start pleroma app please make sure to make the file read-only and non-modifiable.
|
|
||||||
Example:
|
|
||||||
chmod 0444 #{file_path}
|
|
||||||
chattr +i #{file_path}
|
|
||||||
""")
|
|
||||||
end
|
|
||||||
else
|
|
||||||
shell_info("\nThe file is exist. #{env_path}.\n")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def do_generate(path) do
|
|
||||||
content = "RELEASE_COOKIE=#{Base.encode32(:crypto.strong_rand_bytes(32))}"
|
|
||||||
|
|
||||||
File.mkdir_p!(Path.dirname(path))
|
|
||||||
File.write(path, content)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -340,4 +340,10 @@ def direct_conversation_id(activity, for_user) do
|
||||||
_ -> nil
|
_ -> nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec pinned_by_actor?(Activity.t()) :: boolean()
|
||||||
|
def pinned_by_actor?(%Activity{} = activity) do
|
||||||
|
actor = user_actor(activity)
|
||||||
|
activity.id in actor.pinned_activities
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,11 +20,11 @@ defmodule Pleroma.ActivityExpiration do
|
||||||
field(:scheduled_at, :naive_datetime)
|
field(:scheduled_at, :naive_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
def changeset(%ActivityExpiration{} = expiration, attrs) do
|
def changeset(%ActivityExpiration{} = expiration, attrs, validate_scheduled_at) do
|
||||||
expiration
|
expiration
|
||||||
|> cast(attrs, [:scheduled_at])
|
|> cast(attrs, [:scheduled_at])
|
||||||
|> validate_required([:scheduled_at])
|
|> validate_required([:scheduled_at])
|
||||||
|> validate_scheduled_at()
|
|> validate_scheduled_at(validate_scheduled_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_by_activity_id(activity_id) do
|
def get_by_activity_id(activity_id) do
|
||||||
|
@ -33,9 +33,9 @@ def get_by_activity_id(activity_id) do
|
||||||
|> Repo.one()
|
|> Repo.one()
|
||||||
end
|
end
|
||||||
|
|
||||||
def create(%Activity{} = activity, scheduled_at) do
|
def create(%Activity{} = activity, scheduled_at, validate_scheduled_at \\ true) do
|
||||||
%ActivityExpiration{activity_id: activity.id}
|
%ActivityExpiration{activity_id: activity.id}
|
||||||
|> changeset(%{scheduled_at: scheduled_at})
|
|> changeset(%{scheduled_at: scheduled_at}, validate_scheduled_at)
|
||||||
|> Repo.insert()
|
|> Repo.insert()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -46,10 +46,17 @@ def due_expirations(offset \\ 0) do
|
||||||
|
|
||||||
ActivityExpiration
|
ActivityExpiration
|
||||||
|> where([exp], exp.scheduled_at < ^naive_datetime)
|
|> where([exp], exp.scheduled_at < ^naive_datetime)
|
||||||
|
|> limit(50)
|
||||||
|
|> preload(:activity)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|
|> Enum.reject(fn %{activity: activity} ->
|
||||||
|
Activity.pinned_by_actor?(activity)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_scheduled_at(changeset) do
|
def validate_scheduled_at(changeset, false), do: changeset
|
||||||
|
|
||||||
|
def validate_scheduled_at(changeset, true) do
|
||||||
validate_change(changeset, :scheduled_at, fn _, scheduled_at ->
|
validate_change(changeset, :scheduled_at, fn _, scheduled_at ->
|
||||||
if not expires_late_enough?(scheduled_at) do
|
if not expires_late_enough?(scheduled_at) do
|
||||||
[scheduled_at: "an ephemeral activity must live for at least one hour"]
|
[scheduled_at: "an ephemeral activity must live for at least one hour"]
|
||||||
|
|
|
@ -81,6 +81,16 @@ def delete(key) do
|
||||||
Application.delete_env(:pleroma, key)
|
Application.delete_env(:pleroma, key)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def restrict_unauthenticated_access?(resource, kind) do
|
||||||
|
setting = get([:restrict_unauthenticated, resource, kind])
|
||||||
|
|
||||||
|
if setting in [nil, :if_instance_is_private] do
|
||||||
|
!get!([:instance, :public])
|
||||||
|
else
|
||||||
|
setting
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def oauth_consumer_strategies, do: get([:auth, :oauth_consumer_strategies], [])
|
def oauth_consumer_strategies, do: get([:auth, :oauth_consumer_strategies], [])
|
||||||
|
|
||||||
def oauth_consumer_enabled?, do: oauth_consumer_strategies() != []
|
def oauth_consumer_enabled?, do: oauth_consumer_strategies() != []
|
||||||
|
|
|
@ -107,6 +107,8 @@ def digest_email(user) do
|
||||||
|> Enum.filter(&(&1.activity.data["type"] == "Create"))
|
|> Enum.filter(&(&1.activity.data["type"] == "Create"))
|
||||||
|> Enum.map(fn notification ->
|
|> Enum.map(fn notification ->
|
||||||
object = Pleroma.Object.normalize(notification.activity)
|
object = Pleroma.Object.normalize(notification.activity)
|
||||||
|
|
||||||
|
if not is_nil(object) do
|
||||||
object = update_in(object.data["content"], &format_links/1)
|
object = update_in(object.data["content"], &format_links/1)
|
||||||
|
|
||||||
%{
|
%{
|
||||||
|
@ -114,18 +116,25 @@ def digest_email(user) do
|
||||||
object: object,
|
object: object,
|
||||||
from: User.get_by_ap_id(notification.activity.actor)
|
from: User.get_by_ap_id(notification.activity.actor)
|
||||||
}
|
}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|> Enum.filter(& &1)
|
||||||
|
|
||||||
followers =
|
followers =
|
||||||
notifications
|
notifications
|
||||||
|> Enum.filter(&(&1.activity.data["type"] == "Follow"))
|
|> Enum.filter(&(&1.activity.data["type"] == "Follow"))
|
||||||
|> Enum.map(fn notification ->
|
|> Enum.map(fn notification ->
|
||||||
|
from = User.get_by_ap_id(notification.activity.actor)
|
||||||
|
|
||||||
|
if not is_nil(from) do
|
||||||
%{
|
%{
|
||||||
data: notification,
|
data: notification,
|
||||||
object: Pleroma.Object.normalize(notification.activity),
|
object: Pleroma.Object.normalize(notification.activity),
|
||||||
from: User.get_by_ap_id(notification.activity.actor)
|
from: User.get_by_ap_id(notification.activity.actor)
|
||||||
}
|
}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|> Enum.filter(& &1)
|
||||||
|
|
||||||
unless Enum.empty?(mentions) do
|
unless Enum.empty?(mentions) do
|
||||||
styling = Config.get([__MODULE__, :styling])
|
styling = Config.get([__MODULE__, :styling])
|
||||||
|
|
|
@ -264,4 +264,12 @@ defp validate_following_id_follower_id_inequality(%Changeset{} = changeset) do
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec following_ap_ids(User.t()) :: [String.t()]
|
||||||
|
def following_ap_ids(%User{} = user) do
|
||||||
|
user
|
||||||
|
|> following_query()
|
||||||
|
|> select([r, u], u.ap_id)
|
||||||
|
|> Repo.all()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,8 +15,8 @@ def start_link(_) do
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def init(state) do
|
def init(state) do
|
||||||
:telemetry.attach("oban-monitor-failure", [:oban, :failure], &handle_event/4, nil)
|
:telemetry.attach("oban-monitor-failure", [:oban, :job, :exception], &handle_event/4, nil)
|
||||||
:telemetry.attach("oban-monitor-success", [:oban, :success], &handle_event/4, nil)
|
:telemetry.attach("oban-monitor-success", [:oban, :job, :stop], &handle_event/4, nil)
|
||||||
|
|
||||||
{:ok, state}
|
{:ok, state}
|
||||||
end
|
end
|
||||||
|
@ -25,8 +25,11 @@ def stats do
|
||||||
GenServer.call(__MODULE__, :stats)
|
GenServer.call(__MODULE__, :stats)
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_event([:oban, status], %{duration: duration}, meta, _) do
|
def handle_event([:oban, :job, event], %{duration: duration}, meta, _) do
|
||||||
GenServer.cast(__MODULE__, {:process_event, status, duration, meta})
|
GenServer.cast(
|
||||||
|
__MODULE__,
|
||||||
|
{:process_event, mapping_status(event), duration, meta}
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
|
@ -75,4 +78,7 @@ defp update_queue(queue, status, _meta, _duration) do
|
||||||
|> Map.update!(:processed_jobs, &(&1 + 1))
|
|> Map.update!(:processed_jobs, &(&1 + 1))
|
||||||
|> Map.update!(status, &(&1 + 1))
|
|> Map.update!(status, &(&1 + 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp mapping_status(:stop), do: :success
|
||||||
|
defp mapping_status(:exception), do: :failure
|
||||||
end
|
end
|
||||||
|
|
|
@ -255,6 +255,10 @@ def increase_replies_count(ap_id) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp poll_is_multiple?(%Object{data: %{"anyOf" => [_ | _]}}), do: true
|
||||||
|
|
||||||
|
defp poll_is_multiple?(_), do: false
|
||||||
|
|
||||||
def decrease_replies_count(ap_id) do
|
def decrease_replies_count(ap_id) do
|
||||||
Object
|
Object
|
||||||
|> where([o], fragment("?->>'id' = ?::text", o.data, ^to_string(ap_id)))
|
|> where([o], fragment("?->>'id' = ?::text", o.data, ^to_string(ap_id)))
|
||||||
|
@ -281,10 +285,10 @@ def decrease_replies_count(ap_id) do
|
||||||
def increase_vote_count(ap_id, name, actor) do
|
def increase_vote_count(ap_id, name, actor) do
|
||||||
with %Object{} = object <- Object.normalize(ap_id),
|
with %Object{} = object <- Object.normalize(ap_id),
|
||||||
"Question" <- object.data["type"] do
|
"Question" <- object.data["type"] do
|
||||||
multiple = Map.has_key?(object.data, "anyOf")
|
key = if poll_is_multiple?(object), do: "anyOf", else: "oneOf"
|
||||||
|
|
||||||
options =
|
options =
|
||||||
(object.data["anyOf"] || object.data["oneOf"] || [])
|
object.data[key]
|
||||||
|> Enum.map(fn
|
|> Enum.map(fn
|
||||||
%{"name" => ^name} = option ->
|
%{"name" => ^name} = option ->
|
||||||
Kernel.update_in(option["replies"]["totalItems"], &(&1 + 1))
|
Kernel.update_in(option["replies"]["totalItems"], &(&1 + 1))
|
||||||
|
@ -296,11 +300,8 @@ def increase_vote_count(ap_id, name, actor) do
|
||||||
voters = [actor | object.data["voters"] || []] |> Enum.uniq()
|
voters = [actor | object.data["voters"] || []] |> Enum.uniq()
|
||||||
|
|
||||||
data =
|
data =
|
||||||
if multiple do
|
object.data
|
||||||
Map.put(object.data, "anyOf", options)
|
|> Map.put(key, options)
|
||||||
else
|
|
||||||
Map.put(object.data, "oneOf", options)
|
|
||||||
end
|
|
||||||
|> Map.put("voters", voters)
|
|> Map.put("voters", voters)
|
||||||
|
|
||||||
object
|
object
|
||||||
|
|
|
@ -55,7 +55,7 @@ defp compare_uris(%URI{host: host} = _id_uri, %URI{host: host} = _other_uri), do
|
||||||
defp compare_uris(_id_uri, _other_uri), do: :error
|
defp compare_uris(_id_uri, _other_uri), do: :error
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Checks that an imported AP object's actor matches the domain it came from.
|
Checks that an imported AP object's actor matches the host it came from.
|
||||||
"""
|
"""
|
||||||
def contain_origin(_id, %{"actor" => nil}), do: :error
|
def contain_origin(_id, %{"actor" => nil}), do: :error
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.Object.Fetcher do
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
alias Pleroma.Signature
|
alias Pleroma.Signature
|
||||||
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidator
|
||||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||||
alias Pleroma.Web.Federator
|
alias Pleroma.Web.Federator
|
||||||
|
|
||||||
|
@ -23,21 +24,39 @@ defp touch_changeset(changeset) do
|
||||||
Ecto.Changeset.put_change(changeset, :updated_at, updated_at)
|
Ecto.Changeset.put_change(changeset, :updated_at, updated_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_reinject_internal_fields(data, %{data: %{} = old_data}) do
|
defp maybe_reinject_internal_fields(%{data: %{} = old_data}, new_data) do
|
||||||
internal_fields = Map.take(old_data, Pleroma.Constants.object_internal_fields())
|
internal_fields = Map.take(old_data, Pleroma.Constants.object_internal_fields())
|
||||||
|
|
||||||
Map.merge(data, internal_fields)
|
Map.merge(new_data, internal_fields)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_reinject_internal_fields(data, _), do: data
|
defp maybe_reinject_internal_fields(_, new_data), do: new_data
|
||||||
|
|
||||||
@spec reinject_object(struct(), map()) :: {:ok, Object.t()} | {:error, any()}
|
@spec reinject_object(struct(), map()) :: {:ok, Object.t()} | {:error, any()}
|
||||||
defp reinject_object(struct, data) do
|
defp reinject_object(%Object{data: %{"type" => "Question"}} = object, new_data) do
|
||||||
Logger.debug("Reinjecting object #{data["id"]}")
|
Logger.debug("Reinjecting object #{new_data["id"]}")
|
||||||
|
|
||||||
with data <- Transmogrifier.fix_object(data),
|
with new_data <- Transmogrifier.fix_object(new_data),
|
||||||
data <- maybe_reinject_internal_fields(data, struct),
|
data <- maybe_reinject_internal_fields(object, new_data),
|
||||||
changeset <- Object.change(struct, %{data: data}),
|
{:ok, data, _} <- ObjectValidator.validate(data, %{}),
|
||||||
|
changeset <- Object.change(object, %{data: data}),
|
||||||
|
changeset <- touch_changeset(changeset),
|
||||||
|
{:ok, object} <- Repo.insert_or_update(changeset),
|
||||||
|
{:ok, object} <- Object.set_cache(object) do
|
||||||
|
{:ok, object}
|
||||||
|
else
|
||||||
|
e ->
|
||||||
|
Logger.error("Error while processing object: #{inspect(e)}")
|
||||||
|
{:error, e}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp reinject_object(%Object{} = object, new_data) do
|
||||||
|
Logger.debug("Reinjecting object #{new_data["id"]}")
|
||||||
|
|
||||||
|
with new_data <- Transmogrifier.fix_object(new_data),
|
||||||
|
data <- maybe_reinject_internal_fields(object, new_data),
|
||||||
|
changeset <- Object.change(object, %{data: data}),
|
||||||
changeset <- touch_changeset(changeset),
|
changeset <- touch_changeset(changeset),
|
||||||
{:ok, object} <- Repo.insert_or_update(changeset),
|
{:ok, object} <- Repo.insert_or_update(changeset),
|
||||||
{:ok, object} <- Object.set_cache(object) do
|
{:ok, object} <- Object.set_cache(object) do
|
||||||
|
@ -51,8 +70,8 @@ defp reinject_object(struct, data) do
|
||||||
|
|
||||||
def refetch_object(%Object{data: %{"id" => id}} = object) do
|
def refetch_object(%Object{data: %{"id" => id}} = object) do
|
||||||
with {:local, false} <- {:local, Object.local?(object)},
|
with {:local, false} <- {:local, Object.local?(object)},
|
||||||
{:ok, data} <- fetch_and_contain_remote_object_from_id(id),
|
{:ok, new_data} <- fetch_and_contain_remote_object_from_id(id),
|
||||||
{:ok, object} <- reinject_object(object, data) do
|
{:ok, object} <- reinject_object(object, new_data) do
|
||||||
{:ok, object}
|
{:ok, object}
|
||||||
else
|
else
|
||||||
{:local, true} -> {:ok, object}
|
{:local, true} -> {:ok, object}
|
||||||
|
@ -106,8 +125,8 @@ def fetch_object_from_id(id, options \\ []) do
|
||||||
defp prepare_activity_params(data) do
|
defp prepare_activity_params(data) do
|
||||||
%{
|
%{
|
||||||
"type" => "Create",
|
"type" => "Create",
|
||||||
"to" => data["to"],
|
"to" => data["to"] || [],
|
||||||
"cc" => data["cc"],
|
"cc" => data["cc"] || [],
|
||||||
# Should we seriously keep this attributedTo thing?
|
# Should we seriously keep this attributedTo thing?
|
||||||
"actor" => data["actor"] || data["attributedTo"],
|
"actor" => data["actor"] || data["attributedTo"],
|
||||||
"object" => data
|
"object" => data
|
||||||
|
|
|
@ -56,6 +56,15 @@ defmodule Pleroma.Upload do
|
||||||
}
|
}
|
||||||
defstruct [:id, :name, :tempfile, :content_type, :path]
|
defstruct [:id, :name, :tempfile, :content_type, :path]
|
||||||
|
|
||||||
|
defp get_description(opts, upload) do
|
||||||
|
case {opts[:description], Pleroma.Config.get([Pleroma.Upload, :default_description])} do
|
||||||
|
{description, _} when is_binary(description) -> description
|
||||||
|
{_, :filename} -> upload.name
|
||||||
|
{_, str} when is_binary(str) -> str
|
||||||
|
_ -> ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
@spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()}
|
@spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()}
|
||||||
def store(upload, opts \\ []) do
|
def store(upload, opts \\ []) do
|
||||||
opts = get_opts(opts)
|
opts = get_opts(opts)
|
||||||
|
@ -63,7 +72,7 @@ def store(upload, opts \\ []) do
|
||||||
with {:ok, upload} <- prepare_upload(upload, opts),
|
with {:ok, upload} <- prepare_upload(upload, opts),
|
||||||
upload = %__MODULE__{upload | path: upload.path || "#{upload.id}/#{upload.name}"},
|
upload = %__MODULE__{upload | path: upload.path || "#{upload.id}/#{upload.name}"},
|
||||||
{:ok, upload} <- Pleroma.Upload.Filter.filter(opts.filters, upload),
|
{:ok, upload} <- Pleroma.Upload.Filter.filter(opts.filters, upload),
|
||||||
description = Map.get(opts, :description) || upload.name,
|
description = get_description(opts, upload),
|
||||||
{_, true} <-
|
{_, true} <-
|
||||||
{:description_limit,
|
{:description_limit,
|
||||||
String.length(description) <= Pleroma.Config.get([:instance, :description_limit])},
|
String.length(description) <= Pleroma.Config.get([:instance, :description_limit])},
|
||||||
|
|
|
@ -6,6 +6,10 @@ defmodule Pleroma.Upload.Filter.Mogrifun do
|
||||||
@behaviour Pleroma.Upload.Filter
|
@behaviour Pleroma.Upload.Filter
|
||||||
alias Pleroma.Upload.Filter
|
alias Pleroma.Upload.Filter
|
||||||
|
|
||||||
|
@moduledoc """
|
||||||
|
This module is just an example of an Upload filter. It's not supposed to be used in production.
|
||||||
|
"""
|
||||||
|
|
||||||
@filters [
|
@filters [
|
||||||
{"implode", "1"},
|
{"implode", "1"},
|
||||||
{"-raise", "20"},
|
{"-raise", "20"},
|
||||||
|
|
|
@ -247,6 +247,13 @@ def unquote(:"#{outgoing_relation_target}_ap_ids")(user, restrict_deactivated? \
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defdelegate following_count(user), to: FollowingRelationship
|
||||||
|
defdelegate following(user), to: FollowingRelationship
|
||||||
|
defdelegate following?(follower, followed), to: FollowingRelationship
|
||||||
|
defdelegate following_ap_ids(user), to: FollowingRelationship
|
||||||
|
defdelegate get_follow_requests(user), to: FollowingRelationship
|
||||||
|
defdelegate search(query, opts \\ []), to: User.Search
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Dumps Flake Id to SQL-compatible format (16-byte UUID).
|
Dumps Flake Id to SQL-compatible format (16-byte UUID).
|
||||||
E.g. "9pQtDGXuq4p3VlcJEm" -> <<0, 0, 1, 110, 179, 218, 42, 92, 213, 41, 44, 227, 95, 213, 0, 0>>
|
E.g. "9pQtDGXuq4p3VlcJEm" -> <<0, 0, 1, 110, 179, 218, 42, 92, 213, 41, 44, 227, 95, 213, 0, 0>>
|
||||||
|
@ -311,10 +318,12 @@ def visible_for(%User{} = user, for_user) do
|
||||||
|
|
||||||
def visible_for(_, _), do: :invisible
|
def visible_for(_, _), do: :invisible
|
||||||
|
|
||||||
defp restrict_unauthenticated?(%User{local: local}) do
|
defp restrict_unauthenticated?(%User{local: true}) do
|
||||||
config_key = if local, do: :local, else: :remote
|
Config.restrict_unauthenticated_access?(:profiles, :local)
|
||||||
|
end
|
||||||
|
|
||||||
Config.get([:restrict_unauthenticated, :profiles, config_key], false)
|
defp restrict_unauthenticated?(%User{local: _}) do
|
||||||
|
Config.restrict_unauthenticated_access?(:profiles, :remote)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp visible_account_status(user) do
|
defp visible_account_status(user) do
|
||||||
|
@ -370,8 +379,6 @@ def restrict_deactivated(query) do
|
||||||
from(u in query, where: u.deactivated != ^true)
|
from(u in query, where: u.deactivated != ^true)
|
||||||
end
|
end
|
||||||
|
|
||||||
defdelegate following_count(user), to: FollowingRelationship
|
|
||||||
|
|
||||||
defp truncate_fields_param(params) do
|
defp truncate_fields_param(params) do
|
||||||
if Map.has_key?(params, :fields) do
|
if Map.has_key?(params, :fields) do
|
||||||
Map.put(params, :fields, Enum.map(params[:fields], &truncate_field/1))
|
Map.put(params, :fields, Enum.map(params[:fields], &truncate_field/1))
|
||||||
|
@ -638,6 +645,34 @@ def force_password_reset_async(user) do
|
||||||
@spec force_password_reset(User.t()) :: {:ok, User.t()} | {:error, Ecto.Changeset.t()}
|
@spec force_password_reset(User.t()) :: {:ok, User.t()} | {:error, Ecto.Changeset.t()}
|
||||||
def force_password_reset(user), do: update_password_reset_pending(user, true)
|
def force_password_reset(user), do: update_password_reset_pending(user, true)
|
||||||
|
|
||||||
|
# Used to auto-register LDAP accounts which won't have a password hash stored locally
|
||||||
|
def register_changeset_ldap(struct, params = %{password: password})
|
||||||
|
when is_nil(password) do
|
||||||
|
params = Map.put_new(params, :accepts_chat_messages, true)
|
||||||
|
|
||||||
|
params =
|
||||||
|
if Map.has_key?(params, :email) do
|
||||||
|
Map.put_new(params, :email, params[:email])
|
||||||
|
else
|
||||||
|
params
|
||||||
|
end
|
||||||
|
|
||||||
|
struct
|
||||||
|
|> cast(params, [
|
||||||
|
:name,
|
||||||
|
:nickname,
|
||||||
|
:email,
|
||||||
|
:accepts_chat_messages
|
||||||
|
])
|
||||||
|
|> validate_required([:name, :nickname])
|
||||||
|
|> unique_constraint(:nickname)
|
||||||
|
|> validate_exclusion(:nickname, Config.get([User, :restricted_nicknames]))
|
||||||
|
|> validate_format(:nickname, local_nickname_regex())
|
||||||
|
|> put_ap_id()
|
||||||
|
|> unique_constraint(:ap_id)
|
||||||
|
|> put_following_and_follower_address()
|
||||||
|
end
|
||||||
|
|
||||||
def register_changeset(struct, params \\ %{}, opts \\ []) do
|
def register_changeset(struct, params \\ %{}, opts \\ []) do
|
||||||
bio_limit = Config.get([:instance, :user_bio_length], 5000)
|
bio_limit = Config.get([:instance, :user_bio_length], 5000)
|
||||||
name_limit = Config.get([:instance, :user_name_length], 100)
|
name_limit = Config.get([:instance, :user_name_length], 100)
|
||||||
|
@ -838,8 +873,6 @@ def follow_all(follower, followeds) do
|
||||||
set_cache(follower)
|
set_cache(follower)
|
||||||
end
|
end
|
||||||
|
|
||||||
defdelegate following(user), to: FollowingRelationship
|
|
||||||
|
|
||||||
def follow(%User{} = follower, %User{} = followed, state \\ :follow_accept) do
|
def follow(%User{} = follower, %User{} = followed, state \\ :follow_accept) do
|
||||||
deny_follow_blocked = Config.get([:user, :deny_follow_blocked])
|
deny_follow_blocked = Config.get([:user, :deny_follow_blocked])
|
||||||
|
|
||||||
|
@ -893,8 +926,6 @@ defp do_unfollow(%User{} = follower, %User{} = followed) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defdelegate following?(follower, followed), to: FollowingRelationship
|
|
||||||
|
|
||||||
@doc "Returns follow state as Pleroma.FollowingRelationship.State value"
|
@doc "Returns follow state as Pleroma.FollowingRelationship.State value"
|
||||||
def get_follow_state(%User{} = follower, %User{} = following) do
|
def get_follow_state(%User{} = follower, %User{} = following) do
|
||||||
following_relationship = FollowingRelationship.get(follower, following)
|
following_relationship = FollowingRelationship.get(follower, following)
|
||||||
|
@ -1159,8 +1190,6 @@ def get_friends_ids(user, page \\ nil) do
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
||||||
defdelegate get_follow_requests(user), to: FollowingRelationship
|
|
||||||
|
|
||||||
def increase_note_count(%User{} = user) do
|
def increase_note_count(%User{} = user) do
|
||||||
User
|
User
|
||||||
|> where(id: ^user.id)
|
|> where(id: ^user.id)
|
||||||
|
@ -1553,6 +1582,49 @@ def update_notification_settings(%User{} = user, settings) do
|
||||||
|> update_and_set_cache()
|
|> update_and_set_cache()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec purge_user_changeset(User.t()) :: Changeset.t()
|
||||||
|
def purge_user_changeset(user) do
|
||||||
|
# "Right to be forgotten"
|
||||||
|
# https://gdpr.eu/right-to-be-forgotten/
|
||||||
|
change(user, %{
|
||||||
|
bio: nil,
|
||||||
|
raw_bio: nil,
|
||||||
|
email: nil,
|
||||||
|
name: nil,
|
||||||
|
password_hash: nil,
|
||||||
|
keys: nil,
|
||||||
|
public_key: nil,
|
||||||
|
avatar: %{},
|
||||||
|
tags: [],
|
||||||
|
last_refreshed_at: nil,
|
||||||
|
last_digest_emailed_at: nil,
|
||||||
|
banner: %{},
|
||||||
|
background: %{},
|
||||||
|
note_count: 0,
|
||||||
|
follower_count: 0,
|
||||||
|
following_count: 0,
|
||||||
|
locked: false,
|
||||||
|
confirmation_pending: false,
|
||||||
|
password_reset_pending: false,
|
||||||
|
approval_pending: false,
|
||||||
|
registration_reason: nil,
|
||||||
|
confirmation_token: nil,
|
||||||
|
domain_blocks: [],
|
||||||
|
deactivated: true,
|
||||||
|
ap_enabled: false,
|
||||||
|
is_moderator: false,
|
||||||
|
is_admin: false,
|
||||||
|
mastofe_settings: nil,
|
||||||
|
mascot: nil,
|
||||||
|
emoji: %{},
|
||||||
|
pleroma_settings_store: %{},
|
||||||
|
fields: [],
|
||||||
|
raw_fields: [],
|
||||||
|
discoverable: false,
|
||||||
|
also_known_as: []
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
def delete(users) when is_list(users) do
|
def delete(users) when is_list(users) do
|
||||||
for user <- users, do: delete(user)
|
for user <- users, do: delete(user)
|
||||||
end
|
end
|
||||||
|
@ -1580,7 +1652,7 @@ defp delete_or_deactivate(%User{local: true} = user) do
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
user
|
user
|
||||||
|> change(%{deactivated: true, email: nil})
|
|> purge_user_changeset()
|
||||||
|> update_and_set_cache()
|
|> update_and_set_cache()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -2090,8 +2162,6 @@ def get_ap_ids_by_nicknames(nicknames) do
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
end
|
end
|
||||||
|
|
||||||
defdelegate search(query, opts \\ []), to: User.Search
|
|
||||||
|
|
||||||
defp put_password_hash(
|
defp put_password_hash(
|
||||||
%Ecto.Changeset{valid?: true, changes: %{password: password}} = changeset
|
%Ecto.Changeset{valid?: true, changes: %{password: password}} = changeset
|
||||||
) do
|
) do
|
||||||
|
|
|
@ -130,6 +130,7 @@ defp compose_query({:external, _}, query), do: location_query(query, false)
|
||||||
defp compose_query({:active, _}, query) do
|
defp compose_query({:active, _}, query) do
|
||||||
User.restrict_deactivated(query)
|
User.restrict_deactivated(query)
|
||||||
|> where([u], not is_nil(u.nickname))
|
|> where([u], not is_nil(u.nickname))
|
||||||
|
|> where([u], u.approval_pending == false)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp compose_query({:legacy_active, _}, query) do
|
defp compose_query({:legacy_active, _}, query) do
|
||||||
|
|
|
@ -66,7 +66,7 @@ defp check_remote_limit(%{"object" => %{"content" => content}}) when not is_nil(
|
||||||
|
|
||||||
defp check_remote_limit(_), do: true
|
defp check_remote_limit(_), do: true
|
||||||
|
|
||||||
defp increase_note_count_if_public(actor, object) do
|
def increase_note_count_if_public(actor, object) do
|
||||||
if is_public?(object), do: User.increase_note_count(actor), else: {:ok, actor}
|
if is_public?(object), do: User.increase_note_count(actor), else: {:ok, actor}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -85,17 +85,7 @@ defp increase_replies_count_if_reply(%{
|
||||||
|
|
||||||
defp increase_replies_count_if_reply(_create_data), do: :noop
|
defp increase_replies_count_if_reply(_create_data), do: :noop
|
||||||
|
|
||||||
defp increase_poll_votes_if_vote(%{
|
@object_types ~w[ChatMessage Question Answer Audio Event]
|
||||||
"object" => %{"inReplyTo" => reply_ap_id, "name" => name},
|
|
||||||
"type" => "Create",
|
|
||||||
"actor" => actor
|
|
||||||
}) do
|
|
||||||
Object.increase_vote_count(reply_ap_id, name, actor)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp increase_poll_votes_if_vote(_create_data), do: :noop
|
|
||||||
|
|
||||||
@object_types ["ChatMessage"]
|
|
||||||
@spec persist(map(), keyword()) :: {:ok, Activity.t() | Object.t()}
|
@spec persist(map(), keyword()) :: {:ok, Activity.t() | Object.t()}
|
||||||
def persist(%{"type" => type} = object, meta) when type in @object_types do
|
def persist(%{"type" => type} = object, meta) when type in @object_types do
|
||||||
with {:ok, object} <- Object.create(object) do
|
with {:ok, object} <- Object.create(object) do
|
||||||
|
@ -258,7 +248,6 @@ defp do_create(%{to: to, actor: actor, context: context, object: object} = param
|
||||||
with {:ok, activity} <- insert(create_data, local, fake),
|
with {:ok, activity} <- insert(create_data, local, fake),
|
||||||
{:fake, false, activity} <- {:fake, fake, activity},
|
{:fake, false, activity} <- {:fake, fake, activity},
|
||||||
_ <- increase_replies_count_if_reply(create_data),
|
_ <- increase_replies_count_if_reply(create_data),
|
||||||
_ <- increase_poll_votes_if_vote(create_data),
|
|
||||||
{:quick_insert, false, activity} <- {:quick_insert, quick_insert?, activity},
|
{:quick_insert, false, activity} <- {:quick_insert, quick_insert?, activity},
|
||||||
{:ok, _actor} <- increase_note_count_if_public(actor, activity),
|
{:ok, _actor} <- increase_note_count_if_public(actor, activity),
|
||||||
_ <- notify_and_stream(activity),
|
_ <- notify_and_stream(activity),
|
||||||
|
@ -296,32 +285,6 @@ def listen(%{to: to, actor: actor, context: context, object: object} = params) d
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec accept(map()) :: {:ok, Activity.t()} | {:error, any()}
|
|
||||||
def accept(params) do
|
|
||||||
accept_or_reject("Accept", params)
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec reject(map()) :: {:ok, Activity.t()} | {:error, any()}
|
|
||||||
def reject(params) do
|
|
||||||
accept_or_reject("Reject", params)
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec accept_or_reject(String.t(), map()) :: {:ok, Activity.t()} | {:error, any()}
|
|
||||||
defp accept_or_reject(type, %{to: to, actor: actor, object: object} = params) do
|
|
||||||
local = Map.get(params, :local, true)
|
|
||||||
activity_id = Map.get(params, :activity_id, nil)
|
|
||||||
|
|
||||||
data =
|
|
||||||
%{"to" => to, "type" => type, "actor" => actor.ap_id, "object" => object}
|
|
||||||
|> Maps.put_if_present("id", activity_id)
|
|
||||||
|
|
||||||
with {:ok, activity} <- insert(data, local),
|
|
||||||
_ <- notify_and_stream(activity),
|
|
||||||
:ok <- maybe_federate(activity) do
|
|
||||||
{:ok, activity}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec unfollow(User.t(), User.t(), String.t() | nil, boolean()) ::
|
@spec unfollow(User.t(), User.t(), String.t() | nil, boolean()) ::
|
||||||
{:ok, Activity.t()} | nil | {:error, any()}
|
{:ok, Activity.t()} | nil | {:error, any()}
|
||||||
def unfollow(follower, followed, activity_id \\ nil, local \\ true) do
|
def unfollow(follower, followed, activity_id \\ nil, local \\ true) do
|
||||||
|
@ -1381,9 +1344,8 @@ def fetch_and_prepare_user_from_ap_id(ap_id) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_handle_clashing_nickname(data) do
|
def maybe_handle_clashing_nickname(data) do
|
||||||
nickname = data[:nickname]
|
with nickname when is_binary(nickname) <- data[:nickname],
|
||||||
|
%User{} = old_user <- User.get_by_nickname(nickname),
|
||||||
with %User{} = old_user <- User.get_by_nickname(nickname),
|
|
||||||
{_, false} <- {:ap_id_comparison, data[:ap_id] == old_user.ap_id} do
|
{_, false} <- {:ap_id_comparison, data[:ap_id] == old_user.ap_id} do
|
||||||
Logger.info(
|
Logger.info(
|
||||||
"Found an old user for #{nickname}, the old ap id is #{old_user.ap_id}, new one is #{
|
"Found an old user for #{nickname}, the old ap id is #{old_user.ap_id}, new one is #{
|
||||||
|
@ -1397,7 +1359,7 @@ def maybe_handle_clashing_nickname(data) do
|
||||||
else
|
else
|
||||||
{:ap_id_comparison, true} ->
|
{:ap_id_comparison, true} ->
|
||||||
Logger.info(
|
Logger.info(
|
||||||
"Found an old user for #{nickname}, but the ap id #{data[:ap_id]} is the same as the new user. Race condition? Not changing anything."
|
"Found an old user for #{data[:nickname]}, but the ap id #{data[:ap_id]} is the same as the new user. Race condition? Not changing anything."
|
||||||
)
|
)
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
|
|
|
@ -14,6 +14,28 @@ defmodule Pleroma.Web.ActivityPub.Builder do
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
|
def accept_or_reject(actor, activity, type) do
|
||||||
|
data = %{
|
||||||
|
"id" => Utils.generate_activity_id(),
|
||||||
|
"actor" => actor.ap_id,
|
||||||
|
"type" => type,
|
||||||
|
"object" => activity.data["id"],
|
||||||
|
"to" => [activity.actor]
|
||||||
|
}
|
||||||
|
|
||||||
|
{:ok, data, []}
|
||||||
|
end
|
||||||
|
|
||||||
|
@spec reject(User.t(), Activity.t()) :: {:ok, map(), keyword()}
|
||||||
|
def reject(actor, rejected_activity) do
|
||||||
|
accept_or_reject(actor, rejected_activity, "Reject")
|
||||||
|
end
|
||||||
|
|
||||||
|
@spec accept(User.t(), Activity.t()) :: {:ok, map(), keyword()}
|
||||||
|
def accept(actor, accepted_activity) do
|
||||||
|
accept_or_reject(actor, accepted_activity, "Accept")
|
||||||
|
end
|
||||||
|
|
||||||
@spec follow(User.t(), User.t()) :: {:ok, map(), keyword()}
|
@spec follow(User.t(), User.t()) :: {:ok, map(), keyword()}
|
||||||
def follow(follower, followed) do
|
def follow(follower, followed) do
|
||||||
data = %{
|
data = %{
|
||||||
|
@ -80,6 +102,13 @@ def delete(actor, object_id) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def create(actor, object, recipients) do
|
def create(actor, object, recipients) do
|
||||||
|
context =
|
||||||
|
if is_map(object) do
|
||||||
|
object["context"]
|
||||||
|
else
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
{:ok,
|
{:ok,
|
||||||
%{
|
%{
|
||||||
"id" => Utils.generate_activity_id(),
|
"id" => Utils.generate_activity_id(),
|
||||||
|
@ -88,7 +117,8 @@ def create(actor, object, recipients) do
|
||||||
"object" => object,
|
"object" => object,
|
||||||
"type" => "Create",
|
"type" => "Create",
|
||||||
"published" => DateTime.utc_now() |> DateTime.to_iso8601()
|
"published" => DateTime.utc_now() |> DateTime.to_iso8601()
|
||||||
}, []}
|
}
|
||||||
|
|> Pleroma.Maps.put_if_present("context", context), []}
|
||||||
end
|
end
|
||||||
|
|
||||||
def chat_message(actor, recipient, content, opts \\ []) do
|
def chat_message(actor, recipient, content, opts \\ []) do
|
||||||
|
@ -115,6 +145,22 @@ def chat_message(actor, recipient, content, opts \\ []) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def answer(user, object, name) do
|
||||||
|
{:ok,
|
||||||
|
%{
|
||||||
|
"type" => "Answer",
|
||||||
|
"actor" => user.ap_id,
|
||||||
|
"attributedTo" => user.ap_id,
|
||||||
|
"cc" => [object.data["actor"]],
|
||||||
|
"to" => [],
|
||||||
|
"name" => name,
|
||||||
|
"inReplyTo" => object.data["id"],
|
||||||
|
"context" => object.data["context"],
|
||||||
|
"published" => DateTime.utc_now() |> DateTime.to_iso8601(),
|
||||||
|
"id" => Utils.generate_object_id()
|
||||||
|
}, []}
|
||||||
|
end
|
||||||
|
|
||||||
@spec tombstone(String.t(), String.t()) :: {:ok, map(), keyword()}
|
@spec tombstone(String.t(), String.t()) :: {:ok, map(), keyword()}
|
||||||
def tombstone(actor, id) do
|
def tombstone(actor, id) do
|
||||||
{:ok,
|
{:ok,
|
||||||
|
@ -169,7 +215,7 @@ def announce(actor, object, options \\ []) do
|
||||||
|
|
||||||
to =
|
to =
|
||||||
cond do
|
cond do
|
||||||
actor.ap_id == Relay.relay_ap_id() ->
|
actor.ap_id == Relay.ap_id() ->
|
||||||
[actor.follower_address]
|
[actor.follower_address]
|
||||||
|
|
||||||
public? ->
|
public? ->
|
||||||
|
|
|
@ -13,20 +13,47 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidator do
|
||||||
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.AcceptRejectValidator
|
||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.AnnounceValidator
|
alias Pleroma.Web.ActivityPub.ObjectValidators.AnnounceValidator
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.AnswerValidator
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.AudioValidator
|
||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.BlockValidator
|
alias Pleroma.Web.ActivityPub.ObjectValidators.BlockValidator
|
||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.ChatMessageValidator
|
alias Pleroma.Web.ActivityPub.ObjectValidators.ChatMessageValidator
|
||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.CreateChatMessageValidator
|
alias Pleroma.Web.ActivityPub.ObjectValidators.CreateChatMessageValidator
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.CreateGenericValidator
|
||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidator
|
alias Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidator
|
||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator
|
alias Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.EventValidator
|
||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.FollowValidator
|
alias Pleroma.Web.ActivityPub.ObjectValidators.FollowValidator
|
||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator
|
alias Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.QuestionValidator
|
||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.UndoValidator
|
alias Pleroma.Web.ActivityPub.ObjectValidators.UndoValidator
|
||||||
alias Pleroma.Web.ActivityPub.ObjectValidators.UpdateValidator
|
alias Pleroma.Web.ActivityPub.ObjectValidators.UpdateValidator
|
||||||
|
|
||||||
@spec validate(map(), keyword()) :: {:ok, map(), keyword()} | {:error, any()}
|
@spec validate(map(), keyword()) :: {:ok, map(), keyword()} | {:error, any()}
|
||||||
def validate(object, meta)
|
def validate(object, meta)
|
||||||
|
|
||||||
|
def validate(%{"type" => type} = object, meta)
|
||||||
|
when type in ~w[Accept Reject] do
|
||||||
|
with {:ok, object} <-
|
||||||
|
object
|
||||||
|
|> AcceptRejectValidator.cast_and_validate()
|
||||||
|
|> Ecto.Changeset.apply_action(:insert) do
|
||||||
|
object = stringify_keys(object)
|
||||||
|
{:ok, object, meta}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate(%{"type" => "Event"} = object, meta) do
|
||||||
|
with {:ok, object} <-
|
||||||
|
object
|
||||||
|
|> EventValidator.cast_and_validate()
|
||||||
|
|> Ecto.Changeset.apply_action(:insert) do
|
||||||
|
object = stringify_keys(object)
|
||||||
|
{:ok, object, meta}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def validate(%{"type" => "Follow"} = object, meta) do
|
def validate(%{"type" => "Follow"} = object, meta) do
|
||||||
with {:ok, object} <-
|
with {:ok, object} <-
|
||||||
object
|
object
|
||||||
|
@ -112,17 +139,50 @@ def validate(%{"type" => "ChatMessage"} = object, meta) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validate(%{"type" => "Question"} = object, meta) do
|
||||||
|
with {:ok, object} <-
|
||||||
|
object
|
||||||
|
|> QuestionValidator.cast_and_validate()
|
||||||
|
|> Ecto.Changeset.apply_action(:insert) do
|
||||||
|
object = stringify_keys(object)
|
||||||
|
{:ok, object, meta}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate(%{"type" => "Audio"} = object, meta) do
|
||||||
|
with {:ok, object} <-
|
||||||
|
object
|
||||||
|
|> AudioValidator.cast_and_validate()
|
||||||
|
|> Ecto.Changeset.apply_action(:insert) do
|
||||||
|
object = stringify_keys(object)
|
||||||
|
{:ok, object, meta}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate(%{"type" => "Answer"} = object, meta) do
|
||||||
|
with {:ok, object} <-
|
||||||
|
object
|
||||||
|
|> AnswerValidator.cast_and_validate()
|
||||||
|
|> Ecto.Changeset.apply_action(:insert) do
|
||||||
|
object = stringify_keys(object)
|
||||||
|
{:ok, object, meta}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def validate(%{"type" => "EmojiReact"} = object, meta) do
|
def validate(%{"type" => "EmojiReact"} = object, meta) do
|
||||||
with {:ok, object} <-
|
with {:ok, object} <-
|
||||||
object
|
object
|
||||||
|> EmojiReactValidator.cast_and_validate()
|
|> EmojiReactValidator.cast_and_validate()
|
||||||
|> Ecto.Changeset.apply_action(:insert) do
|
|> Ecto.Changeset.apply_action(:insert) do
|
||||||
object = stringify_keys(object |> Map.from_struct())
|
object = stringify_keys(object)
|
||||||
{:ok, object, meta}
|
{:ok, object, meta}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate(%{"type" => "Create", "object" => object} = create_activity, meta) do
|
def validate(
|
||||||
|
%{"type" => "Create", "object" => %{"type" => "ChatMessage"} = object} = create_activity,
|
||||||
|
meta
|
||||||
|
) do
|
||||||
with {:ok, object_data} <- cast_and_apply(object),
|
with {:ok, object_data} <- cast_and_apply(object),
|
||||||
meta = Keyword.put(meta, :object_data, object_data |> stringify_keys),
|
meta = Keyword.put(meta, :object_data, object_data |> stringify_keys),
|
||||||
{:ok, create_activity} <-
|
{:ok, create_activity} <-
|
||||||
|
@ -134,12 +194,28 @@ def validate(%{"type" => "Create", "object" => object} = create_activity, meta)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validate(
|
||||||
|
%{"type" => "Create", "object" => %{"type" => objtype} = object} = create_activity,
|
||||||
|
meta
|
||||||
|
)
|
||||||
|
when objtype in ~w[Question Answer Audio Event] do
|
||||||
|
with {:ok, object_data} <- cast_and_apply(object),
|
||||||
|
meta = Keyword.put(meta, :object_data, object_data |> stringify_keys),
|
||||||
|
{:ok, create_activity} <-
|
||||||
|
create_activity
|
||||||
|
|> CreateGenericValidator.cast_and_validate(meta)
|
||||||
|
|> Ecto.Changeset.apply_action(:insert) do
|
||||||
|
create_activity = stringify_keys(create_activity)
|
||||||
|
{:ok, create_activity, meta}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def validate(%{"type" => "Announce"} = object, meta) do
|
def validate(%{"type" => "Announce"} = object, meta) do
|
||||||
with {:ok, object} <-
|
with {:ok, object} <-
|
||||||
object
|
object
|
||||||
|> AnnounceValidator.cast_and_validate()
|
|> AnnounceValidator.cast_and_validate()
|
||||||
|> Ecto.Changeset.apply_action(:insert) do
|
|> Ecto.Changeset.apply_action(:insert) do
|
||||||
object = stringify_keys(object |> Map.from_struct())
|
object = stringify_keys(object)
|
||||||
{:ok, object, meta}
|
{:ok, object, meta}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -148,8 +224,25 @@ def cast_and_apply(%{"type" => "ChatMessage"} = object) do
|
||||||
ChatMessageValidator.cast_and_apply(object)
|
ChatMessageValidator.cast_and_apply(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cast_and_apply(%{"type" => "Question"} = object) do
|
||||||
|
QuestionValidator.cast_and_apply(object)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_apply(%{"type" => "Answer"} = object) do
|
||||||
|
AnswerValidator.cast_and_apply(object)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_apply(%{"type" => "Audio"} = object) do
|
||||||
|
AudioValidator.cast_and_apply(object)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_apply(%{"type" => "Event"} = object) do
|
||||||
|
EventValidator.cast_and_apply(object)
|
||||||
|
end
|
||||||
|
|
||||||
def cast_and_apply(o), do: {:error, {:validator_not_set, o}}
|
def cast_and_apply(o), do: {:error, {:validator_not_set, o}}
|
||||||
|
|
||||||
|
# is_struct/1 isn't present in Elixir 1.8.x
|
||||||
def stringify_keys(%{__struct__: _} = object) do
|
def stringify_keys(%{__struct__: _} = object) do
|
||||||
object
|
object
|
||||||
|> Map.from_struct()
|
|> Map.from_struct()
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AcceptRejectValidator do
|
||||||
|
use Ecto.Schema
|
||||||
|
|
||||||
|
alias Pleroma.Activity
|
||||||
|
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
||||||
|
|
||||||
|
import Ecto.Changeset
|
||||||
|
import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
||||||
|
|
||||||
|
@primary_key false
|
||||||
|
|
||||||
|
embedded_schema do
|
||||||
|
field(:id, ObjectValidators.ObjectID, primary_key: true)
|
||||||
|
field(:type, :string)
|
||||||
|
field(:object, ObjectValidators.ObjectID)
|
||||||
|
field(:actor, ObjectValidators.ObjectID)
|
||||||
|
field(:to, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:cc, ObjectValidators.Recipients, default: [])
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_data(data) do
|
||||||
|
%__MODULE__{}
|
||||||
|
|> cast(data, __schema__(:fields))
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_data(cng) do
|
||||||
|
cng
|
||||||
|
|> validate_required([:id, :type, :actor, :to, :cc, :object])
|
||||||
|
|> validate_inclusion(:type, ["Accept", "Reject"])
|
||||||
|
|> validate_actor_presence()
|
||||||
|
|> validate_object_presence(allowed_types: ["Follow"])
|
||||||
|
|> validate_accept_reject_rights()
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_validate(data) do
|
||||||
|
data
|
||||||
|
|> cast_data
|
||||||
|
|> validate_data
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_accept_reject_rights(cng) do
|
||||||
|
with object_id when is_binary(object_id) <- get_field(cng, :object),
|
||||||
|
%Activity{data: %{"object" => followed_actor}} <- Activity.get_by_ap_id(object_id),
|
||||||
|
true <- followed_actor == get_field(cng, :actor) do
|
||||||
|
cng
|
||||||
|
else
|
||||||
|
_e ->
|
||||||
|
cng
|
||||||
|
|> add_error(:actor, "can't accept or reject the given activity")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,62 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AnswerValidator do
|
||||||
|
use Ecto.Schema
|
||||||
|
|
||||||
|
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
||||||
|
|
||||||
|
import Ecto.Changeset
|
||||||
|
|
||||||
|
@primary_key false
|
||||||
|
@derive Jason.Encoder
|
||||||
|
|
||||||
|
embedded_schema do
|
||||||
|
field(:id, ObjectValidators.ObjectID, primary_key: true)
|
||||||
|
field(:to, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:cc, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:bto, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:bcc, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:type, :string)
|
||||||
|
field(:name, :string)
|
||||||
|
field(:inReplyTo, ObjectValidators.ObjectID)
|
||||||
|
field(:attributedTo, ObjectValidators.ObjectID)
|
||||||
|
|
||||||
|
# TODO: Remove actor on objects
|
||||||
|
field(:actor, ObjectValidators.ObjectID)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_apply(data) do
|
||||||
|
data
|
||||||
|
|> cast_data()
|
||||||
|
|> apply_action(:insert)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_validate(data) do
|
||||||
|
data
|
||||||
|
|> cast_data()
|
||||||
|
|> validate_data()
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_data(data) do
|
||||||
|
%__MODULE__{}
|
||||||
|
|> changeset(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
def changeset(struct, data) do
|
||||||
|
struct
|
||||||
|
|> cast(data, __schema__(:fields))
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_data(data_cng) do
|
||||||
|
data_cng
|
||||||
|
|> validate_inclusion(:type, ["Answer"])
|
||||||
|
|> validate_required([:id, :inReplyTo, :name, :attributedTo, :actor])
|
||||||
|
|> CommonValidations.validate_any_presence([:cc, :to])
|
||||||
|
|> CommonValidations.validate_fields_match([:actor, :attributedTo])
|
||||||
|
|> CommonValidations.validate_actor_presence()
|
||||||
|
|> CommonValidations.validate_host_match()
|
||||||
|
end
|
||||||
|
end
|
|
@ -41,34 +41,34 @@ def changeset(struct, data) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_media_type(data) do
|
def fix_media_type(data) do
|
||||||
data =
|
data = Map.put_new(data, "mediaType", data["mimeType"])
|
||||||
data
|
|
||||||
|> Map.put_new("mediaType", data["mimeType"])
|
|
||||||
|
|
||||||
if MIME.valid?(data["mediaType"]) do
|
if MIME.valid?(data["mediaType"]) do
|
||||||
data
|
data
|
||||||
else
|
else
|
||||||
data
|
Map.put(data, "mediaType", "application/octet-stream")
|
||||||
|> Map.put("mediaType", "application/octet-stream")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_url(data) do
|
defp handle_href(href, mediaType) do
|
||||||
case data["url"] do
|
|
||||||
url when is_binary(url) ->
|
|
||||||
data
|
|
||||||
|> Map.put(
|
|
||||||
"url",
|
|
||||||
[
|
[
|
||||||
%{
|
%{
|
||||||
"href" => url,
|
"href" => href,
|
||||||
"type" => "Link",
|
"type" => "Link",
|
||||||
"mediaType" => data["mediaType"]
|
"mediaType" => mediaType
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
)
|
end
|
||||||
|
|
||||||
_ ->
|
defp fix_url(data) do
|
||||||
|
cond do
|
||||||
|
is_binary(data["url"]) ->
|
||||||
|
Map.put(data, "url", handle_href(data["url"], data["mediaType"]))
|
||||||
|
|
||||||
|
is_binary(data["href"]) and data["url"] == nil ->
|
||||||
|
Map.put(data, "url", handle_href(data["href"], data["mediaType"]))
|
||||||
|
|
||||||
|
true ->
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AudioValidator do
|
||||||
|
use Ecto.Schema
|
||||||
|
|
||||||
|
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonFixes
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
||||||
|
|
||||||
|
import Ecto.Changeset
|
||||||
|
|
||||||
|
@primary_key false
|
||||||
|
@derive Jason.Encoder
|
||||||
|
|
||||||
|
embedded_schema do
|
||||||
|
field(:id, ObjectValidators.ObjectID, primary_key: true)
|
||||||
|
field(:to, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:cc, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:bto, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:bcc, ObjectValidators.Recipients, default: [])
|
||||||
|
# TODO: Write type
|
||||||
|
field(:tag, {:array, :map}, default: [])
|
||||||
|
field(:type, :string)
|
||||||
|
field(:content, :string)
|
||||||
|
field(:context, :string)
|
||||||
|
|
||||||
|
# TODO: Remove actor on objects
|
||||||
|
field(:actor, ObjectValidators.ObjectID)
|
||||||
|
|
||||||
|
field(:attributedTo, ObjectValidators.ObjectID)
|
||||||
|
field(:summary, :string)
|
||||||
|
field(:published, ObjectValidators.DateTime)
|
||||||
|
# TODO: Write type
|
||||||
|
field(:emoji, :map, default: %{})
|
||||||
|
field(:sensitive, :boolean, default: false)
|
||||||
|
embeds_many(:attachment, AttachmentValidator)
|
||||||
|
field(:replies_count, :integer, default: 0)
|
||||||
|
field(:like_count, :integer, default: 0)
|
||||||
|
field(:announcement_count, :integer, default: 0)
|
||||||
|
field(:inReplyTo, :string)
|
||||||
|
field(:url, ObjectValidators.Uri)
|
||||||
|
# short identifier for PleromaFE to group statuses by context
|
||||||
|
field(:context_id, :integer)
|
||||||
|
|
||||||
|
field(:likes, {:array, :string}, default: [])
|
||||||
|
field(:announcements, {:array, :string}, default: [])
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_apply(data) do
|
||||||
|
data
|
||||||
|
|> cast_data
|
||||||
|
|> apply_action(:insert)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_validate(data) do
|
||||||
|
data
|
||||||
|
|> cast_data()
|
||||||
|
|> validate_data()
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_data(data) do
|
||||||
|
%__MODULE__{}
|
||||||
|
|> changeset(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp fix_url(%{"url" => url} = data) when is_list(url) do
|
||||||
|
attachment =
|
||||||
|
Enum.find(url, fn x -> is_map(x) and String.starts_with?(x["mimeType"], "audio/") end)
|
||||||
|
|
||||||
|
link_element = Enum.find(url, fn x -> is_map(x) and x["mimeType"] == "text/html" end)
|
||||||
|
|
||||||
|
data
|
||||||
|
|> Map.put("attachment", [attachment])
|
||||||
|
|> Map.put("url", link_element["href"])
|
||||||
|
end
|
||||||
|
|
||||||
|
defp fix_url(data), do: data
|
||||||
|
|
||||||
|
defp fix(data) do
|
||||||
|
data
|
||||||
|
|> CommonFixes.fix_defaults()
|
||||||
|
|> CommonFixes.fix_attribution()
|
||||||
|
|> fix_url()
|
||||||
|
end
|
||||||
|
|
||||||
|
def changeset(struct, data) do
|
||||||
|
data = fix(data)
|
||||||
|
|
||||||
|
struct
|
||||||
|
|> cast(data, __schema__(:fields) -- [:attachment])
|
||||||
|
|> cast_embed(:attachment)
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_data(data_cng) do
|
||||||
|
data_cng
|
||||||
|
|> validate_inclusion(:type, ["Audio"])
|
||||||
|
|> validate_required([:id, :actor, :attributedTo, :type, :context, :attachment])
|
||||||
|
|> CommonValidations.validate_any_presence([:cc, :to])
|
||||||
|
|> CommonValidations.validate_fields_match([:actor, :attributedTo])
|
||||||
|
|> CommonValidations.validate_actor_presence()
|
||||||
|
|> CommonValidations.validate_host_match()
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ActivityPub.ObjectValidators.CommonFixes do
|
||||||
|
alias Pleroma.Web.ActivityPub.Utils
|
||||||
|
|
||||||
|
# based on Pleroma.Web.ActivityPub.Utils.lazy_put_objects_defaults
|
||||||
|
def fix_defaults(data) do
|
||||||
|
%{data: %{"id" => context}, id: context_id} =
|
||||||
|
Utils.create_context(data["context"] || data["conversation"])
|
||||||
|
|
||||||
|
data
|
||||||
|
|> Map.put_new("context", context)
|
||||||
|
|> Map.put_new("context_id", context_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def fix_attribution(data) do
|
||||||
|
data
|
||||||
|
|> Map.put_new("actor", data["attributedTo"])
|
||||||
|
end
|
||||||
|
end
|
|
@ -9,7 +9,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations do
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
||||||
def validate_recipients_presence(cng, fields \\ [:to, :cc]) do
|
def validate_any_presence(cng, fields) do
|
||||||
non_empty =
|
non_empty =
|
||||||
fields
|
fields
|
||||||
|> Enum.map(fn field -> get_field(cng, field) end)
|
|> Enum.map(fn field -> get_field(cng, field) end)
|
||||||
|
@ -24,7 +24,7 @@ def validate_recipients_presence(cng, fields \\ [:to, :cc]) do
|
||||||
fields
|
fields
|
||||||
|> Enum.reduce(cng, fn field, cng ->
|
|> Enum.reduce(cng, fn field, cng ->
|
||||||
cng
|
cng
|
||||||
|> add_error(field, "no recipients in any field")
|
|> add_error(field, "none of #{inspect(fields)} present")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -82,4 +82,60 @@ def validate_object_or_user_presence(cng, options \\ []) do
|
||||||
|
|
||||||
if actor_cng.valid?, do: actor_cng, else: object_cng
|
if actor_cng.valid?, do: actor_cng, else: object_cng
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def validate_host_match(cng, fields \\ [:id, :actor]) do
|
||||||
|
if same_domain?(cng, fields) do
|
||||||
|
cng
|
||||||
|
else
|
||||||
|
fields
|
||||||
|
|> Enum.reduce(cng, fn field, cng ->
|
||||||
|
cng
|
||||||
|
|> add_error(field, "hosts of #{inspect(fields)} aren't matching")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_fields_match(cng, fields) do
|
||||||
|
if map_unique?(cng, fields) do
|
||||||
|
cng
|
||||||
|
else
|
||||||
|
fields
|
||||||
|
|> Enum.reduce(cng, fn field, cng ->
|
||||||
|
cng
|
||||||
|
|> add_error(field, "Fields #{inspect(fields)} aren't matching")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp map_unique?(cng, fields, func \\ & &1) do
|
||||||
|
Enum.reduce_while(fields, nil, fn field, acc ->
|
||||||
|
value =
|
||||||
|
cng
|
||||||
|
|> get_field(field)
|
||||||
|
|> func.()
|
||||||
|
|
||||||
|
case {value, acc} do
|
||||||
|
{value, nil} -> {:cont, value}
|
||||||
|
{value, value} -> {:cont, value}
|
||||||
|
_ -> {:halt, false}
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
def same_domain?(cng, fields \\ [:actor, :object]) do
|
||||||
|
map_unique?(cng, fields, fn value -> URI.parse(value).host end)
|
||||||
|
end
|
||||||
|
|
||||||
|
# This figures out if a user is able to create, delete or modify something
|
||||||
|
# based on the domain and superuser status
|
||||||
|
def validate_modification_rights(cng) do
|
||||||
|
actor = User.get_cached_by_ap_id(get_field(cng, :actor))
|
||||||
|
|
||||||
|
if User.superuser?(actor) || same_domain?(cng) do
|
||||||
|
cng
|
||||||
|
else
|
||||||
|
cng
|
||||||
|
|> add_error(:actor, "is not allowed to modify object")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,144 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
# Code based on CreateChatMessageValidator
|
||||||
|
# NOTES
|
||||||
|
# - doesn't embed, will only get the object id
|
||||||
|
defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateGenericValidator do
|
||||||
|
use Ecto.Schema
|
||||||
|
|
||||||
|
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
||||||
|
alias Pleroma.Object
|
||||||
|
|
||||||
|
import Ecto.Changeset
|
||||||
|
import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
||||||
|
|
||||||
|
@primary_key false
|
||||||
|
|
||||||
|
embedded_schema do
|
||||||
|
field(:id, ObjectValidators.ObjectID, primary_key: true)
|
||||||
|
field(:actor, ObjectValidators.ObjectID)
|
||||||
|
field(:type, :string)
|
||||||
|
field(:to, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:cc, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:object, ObjectValidators.ObjectID)
|
||||||
|
field(:expires_at, ObjectValidators.DateTime)
|
||||||
|
|
||||||
|
# Should be moved to object, done for CommonAPI.Utils.make_context
|
||||||
|
field(:context, :string)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_data(data, meta \\ []) do
|
||||||
|
data = fix(data, meta)
|
||||||
|
|
||||||
|
%__MODULE__{}
|
||||||
|
|> changeset(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_apply(data) do
|
||||||
|
data
|
||||||
|
|> cast_data
|
||||||
|
|> apply_action(:insert)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_validate(data, meta \\ []) do
|
||||||
|
data
|
||||||
|
|> cast_data(meta)
|
||||||
|
|> validate_data(meta)
|
||||||
|
end
|
||||||
|
|
||||||
|
def changeset(struct, data) do
|
||||||
|
struct
|
||||||
|
|> cast(data, __schema__(:fields))
|
||||||
|
end
|
||||||
|
|
||||||
|
defp fix_context(data, meta) do
|
||||||
|
if object = meta[:object_data] do
|
||||||
|
Map.put_new(data, "context", object["context"])
|
||||||
|
else
|
||||||
|
data
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp fix_addressing(data, meta) do
|
||||||
|
if object = meta[:object_data] do
|
||||||
|
data
|
||||||
|
|> Map.put_new("to", object["to"] || [])
|
||||||
|
|> Map.put_new("cc", object["cc"] || [])
|
||||||
|
else
|
||||||
|
data
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp fix(data, meta) do
|
||||||
|
data
|
||||||
|
|> fix_context(meta)
|
||||||
|
|> fix_addressing(meta)
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_data(cng, meta \\ []) do
|
||||||
|
cng
|
||||||
|
|> validate_required([:actor, :type, :object])
|
||||||
|
|> validate_inclusion(:type, ["Create"])
|
||||||
|
|> validate_actor_presence()
|
||||||
|
|> validate_any_presence([:to, :cc])
|
||||||
|
|> validate_actors_match(meta)
|
||||||
|
|> validate_context_match(meta)
|
||||||
|
|> validate_object_nonexistence()
|
||||||
|
|> validate_object_containment()
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_object_containment(cng) do
|
||||||
|
actor = get_field(cng, :actor)
|
||||||
|
|
||||||
|
cng
|
||||||
|
|> validate_change(:object, fn :object, object_id ->
|
||||||
|
%URI{host: object_id_host} = URI.parse(object_id)
|
||||||
|
%URI{host: actor_host} = URI.parse(actor)
|
||||||
|
|
||||||
|
if object_id_host == actor_host do
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
[{:object, "The host of the object id doesn't match with the host of the actor"}]
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_object_nonexistence(cng) do
|
||||||
|
cng
|
||||||
|
|> validate_change(:object, fn :object, object_id ->
|
||||||
|
if Object.get_cached_by_ap_id(object_id) do
|
||||||
|
[{:object, "The object to create already exists"}]
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_actors_match(cng, meta) do
|
||||||
|
attributed_to = meta[:object_data]["attributedTo"] || meta[:object_data]["actor"]
|
||||||
|
|
||||||
|
cng
|
||||||
|
|> validate_change(:actor, fn :actor, actor ->
|
||||||
|
if actor == attributed_to do
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
[{:actor, "Actor doesn't match with object attributedTo"}]
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_context_match(cng, %{object_data: %{"context" => object_context}}) do
|
||||||
|
cng
|
||||||
|
|> validate_change(:context, fn :context, context ->
|
||||||
|
if context == object_context do
|
||||||
|
[]
|
||||||
|
else
|
||||||
|
[{:context, "context field not matching between Create and object (#{object_context})"}]
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_context_match(cng, _), do: cng
|
||||||
|
end
|
|
@ -16,11 +16,10 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.CreateNoteValidator do
|
||||||
field(:id, ObjectValidators.ObjectID, primary_key: true)
|
field(:id, ObjectValidators.ObjectID, primary_key: true)
|
||||||
field(:actor, ObjectValidators.ObjectID)
|
field(:actor, ObjectValidators.ObjectID)
|
||||||
field(:type, :string)
|
field(:type, :string)
|
||||||
field(:to, {:array, :string})
|
field(:to, ObjectValidators.Recipients, default: [])
|
||||||
field(:cc, {:array, :string})
|
field(:cc, ObjectValidators.Recipients, default: [])
|
||||||
field(:bto, {:array, :string}, default: [])
|
field(:bto, ObjectValidators.Recipients, default: [])
|
||||||
field(:bcc, {:array, :string}, default: [])
|
field(:bcc, ObjectValidators.Recipients, default: [])
|
||||||
|
|
||||||
embeds_one(:object, NoteValidator)
|
embeds_one(:object, NoteValidator)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.DeleteValidator do
|
||||||
|
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
||||||
alias Pleroma.User
|
|
||||||
|
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
import Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
||||||
|
@ -59,7 +58,7 @@ def validate_data(cng) do
|
||||||
|> validate_required([:id, :type, :actor, :to, :cc, :object])
|
|> validate_required([:id, :type, :actor, :to, :cc, :object])
|
||||||
|> validate_inclusion(:type, ["Delete"])
|
|> validate_inclusion(:type, ["Delete"])
|
||||||
|> validate_actor_presence()
|
|> validate_actor_presence()
|
||||||
|> validate_deletion_rights()
|
|> validate_modification_rights()
|
||||||
|> validate_object_or_user_presence(allowed_types: @deletable_types)
|
|> validate_object_or_user_presence(allowed_types: @deletable_types)
|
||||||
|> add_deleted_activity_id()
|
|> add_deleted_activity_id()
|
||||||
end
|
end
|
||||||
|
@ -68,31 +67,6 @@ def do_not_federate?(cng) do
|
||||||
!same_domain?(cng)
|
!same_domain?(cng)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp same_domain?(cng) do
|
|
||||||
actor_uri =
|
|
||||||
cng
|
|
||||||
|> get_field(:actor)
|
|
||||||
|> URI.parse()
|
|
||||||
|
|
||||||
object_uri =
|
|
||||||
cng
|
|
||||||
|> get_field(:object)
|
|
||||||
|> URI.parse()
|
|
||||||
|
|
||||||
object_uri.host == actor_uri.host
|
|
||||||
end
|
|
||||||
|
|
||||||
def validate_deletion_rights(cng) do
|
|
||||||
actor = User.get_cached_by_ap_id(get_field(cng, :actor))
|
|
||||||
|
|
||||||
if User.superuser?(actor) || same_domain?(cng) do
|
|
||||||
cng
|
|
||||||
else
|
|
||||||
cng
|
|
||||||
|> add_error(:actor, "is not allowed to delete object")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def cast_and_validate(data) do
|
def cast_and_validate(data) do
|
||||||
data
|
data
|
||||||
|> cast_data
|
|> cast_data
|
||||||
|
|
|
@ -20,8 +20,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.EmojiReactValidator do
|
||||||
field(:actor, ObjectValidators.ObjectID)
|
field(:actor, ObjectValidators.ObjectID)
|
||||||
field(:context, :string)
|
field(:context, :string)
|
||||||
field(:content, :string)
|
field(:content, :string)
|
||||||
field(:to, {:array, :string}, default: [])
|
field(:to, ObjectValidators.Recipients, default: [])
|
||||||
field(:cc, {:array, :string}, default: [])
|
field(:cc, ObjectValidators.Recipients, default: [])
|
||||||
end
|
end
|
||||||
|
|
||||||
def cast_and_validate(data) do
|
def cast_and_validate(data) do
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ActivityPub.ObjectValidators.EventValidator do
|
||||||
|
use Ecto.Schema
|
||||||
|
|
||||||
|
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonFixes
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
||||||
|
|
||||||
|
import Ecto.Changeset
|
||||||
|
|
||||||
|
@primary_key false
|
||||||
|
@derive Jason.Encoder
|
||||||
|
|
||||||
|
# Extends from NoteValidator
|
||||||
|
embedded_schema do
|
||||||
|
field(:id, ObjectValidators.ObjectID, primary_key: true)
|
||||||
|
field(:to, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:cc, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:bto, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:bcc, ObjectValidators.Recipients, default: [])
|
||||||
|
# TODO: Write type
|
||||||
|
field(:tag, {:array, :map}, default: [])
|
||||||
|
field(:type, :string)
|
||||||
|
|
||||||
|
field(:name, :string)
|
||||||
|
field(:summary, :string)
|
||||||
|
field(:content, :string)
|
||||||
|
|
||||||
|
field(:context, :string)
|
||||||
|
# short identifier for PleromaFE to group statuses by context
|
||||||
|
field(:context_id, :integer)
|
||||||
|
|
||||||
|
# TODO: Remove actor on objects
|
||||||
|
field(:actor, ObjectValidators.ObjectID)
|
||||||
|
|
||||||
|
field(:attributedTo, ObjectValidators.ObjectID)
|
||||||
|
field(:published, ObjectValidators.DateTime)
|
||||||
|
# TODO: Write type
|
||||||
|
field(:emoji, :map, default: %{})
|
||||||
|
field(:sensitive, :boolean, default: false)
|
||||||
|
embeds_many(:attachment, AttachmentValidator)
|
||||||
|
field(:replies_count, :integer, default: 0)
|
||||||
|
field(:like_count, :integer, default: 0)
|
||||||
|
field(:announcement_count, :integer, default: 0)
|
||||||
|
field(:inReplyTo, ObjectValidators.ObjectID)
|
||||||
|
field(:url, ObjectValidators.Uri)
|
||||||
|
|
||||||
|
field(:likes, {:array, ObjectValidators.ObjectID}, default: [])
|
||||||
|
field(:announcements, {:array, ObjectValidators.ObjectID}, default: [])
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_apply(data) do
|
||||||
|
data
|
||||||
|
|> cast_data
|
||||||
|
|> apply_action(:insert)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_validate(data) do
|
||||||
|
data
|
||||||
|
|> cast_data()
|
||||||
|
|> validate_data()
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_data(data) do
|
||||||
|
%__MODULE__{}
|
||||||
|
|> changeset(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp fix(data) do
|
||||||
|
data
|
||||||
|
|> CommonFixes.fix_defaults()
|
||||||
|
|> CommonFixes.fix_attribution()
|
||||||
|
end
|
||||||
|
|
||||||
|
def changeset(struct, data) do
|
||||||
|
data = fix(data)
|
||||||
|
|
||||||
|
struct
|
||||||
|
|> cast(data, __schema__(:fields) -- [:attachment])
|
||||||
|
|> cast_embed(:attachment)
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_data(data_cng) do
|
||||||
|
data_cng
|
||||||
|
|> validate_inclusion(:type, ["Event"])
|
||||||
|
|> validate_required([:id, :actor, :attributedTo, :type, :context, :context_id])
|
||||||
|
|> CommonValidations.validate_any_presence([:cc, :to])
|
||||||
|
|> CommonValidations.validate_fields_match([:actor, :attributedTo])
|
||||||
|
|> CommonValidations.validate_actor_presence()
|
||||||
|
|> CommonValidations.validate_host_match()
|
||||||
|
end
|
||||||
|
end
|
|
@ -13,18 +13,24 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.NoteValidator do
|
||||||
|
|
||||||
embedded_schema do
|
embedded_schema do
|
||||||
field(:id, ObjectValidators.ObjectID, primary_key: true)
|
field(:id, ObjectValidators.ObjectID, primary_key: true)
|
||||||
field(:to, {:array, :string}, default: [])
|
field(:to, ObjectValidators.Recipients, default: [])
|
||||||
field(:cc, {:array, :string}, default: [])
|
field(:cc, ObjectValidators.Recipients, default: [])
|
||||||
field(:bto, {:array, :string}, default: [])
|
field(:bto, ObjectValidators.Recipients, default: [])
|
||||||
field(:bcc, {:array, :string}, default: [])
|
field(:bcc, ObjectValidators.Recipients, default: [])
|
||||||
# TODO: Write type
|
# TODO: Write type
|
||||||
field(:tag, {:array, :map}, default: [])
|
field(:tag, {:array, :map}, default: [])
|
||||||
field(:type, :string)
|
field(:type, :string)
|
||||||
|
|
||||||
|
field(:name, :string)
|
||||||
|
field(:summary, :string)
|
||||||
field(:content, :string)
|
field(:content, :string)
|
||||||
|
|
||||||
field(:context, :string)
|
field(:context, :string)
|
||||||
|
# short identifier for PleromaFE to group statuses by context
|
||||||
|
field(:context_id, :integer)
|
||||||
|
|
||||||
field(:actor, ObjectValidators.ObjectID)
|
field(:actor, ObjectValidators.ObjectID)
|
||||||
field(:attributedTo, ObjectValidators.ObjectID)
|
field(:attributedTo, ObjectValidators.ObjectID)
|
||||||
field(:summary, :string)
|
|
||||||
field(:published, ObjectValidators.DateTime)
|
field(:published, ObjectValidators.DateTime)
|
||||||
# TODO: Write type
|
# TODO: Write type
|
||||||
field(:emoji, :map, default: %{})
|
field(:emoji, :map, default: %{})
|
||||||
|
@ -34,14 +40,11 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.NoteValidator do
|
||||||
field(:replies_count, :integer, default: 0)
|
field(:replies_count, :integer, default: 0)
|
||||||
field(:like_count, :integer, default: 0)
|
field(:like_count, :integer, default: 0)
|
||||||
field(:announcement_count, :integer, default: 0)
|
field(:announcement_count, :integer, default: 0)
|
||||||
field(:inRepyTo, :string)
|
field(:inReplyTo, ObjectValidators.ObjectID)
|
||||||
field(:uri, ObjectValidators.Uri)
|
field(:url, ObjectValidators.Uri)
|
||||||
|
|
||||||
field(:likes, {:array, :string}, default: [])
|
field(:likes, {:array, :string}, default: [])
|
||||||
field(:announcements, {:array, :string}, default: [])
|
field(:announcements, {:array, :string}, default: [])
|
||||||
|
|
||||||
# see if needed
|
|
||||||
field(:context_id, :string)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def cast_and_validate(data) do
|
def cast_and_validate(data) do
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionOptionsValidator do
|
||||||
|
use Ecto.Schema
|
||||||
|
|
||||||
|
import Ecto.Changeset
|
||||||
|
|
||||||
|
@primary_key false
|
||||||
|
|
||||||
|
embedded_schema do
|
||||||
|
field(:name, :string)
|
||||||
|
|
||||||
|
embeds_one :replies, Replies, primary_key: false do
|
||||||
|
field(:totalItems, :integer)
|
||||||
|
field(:type, :string)
|
||||||
|
end
|
||||||
|
|
||||||
|
field(:type, :string)
|
||||||
|
end
|
||||||
|
|
||||||
|
def changeset(struct, data) do
|
||||||
|
struct
|
||||||
|
|> cast(data, [:name, :type])
|
||||||
|
|> cast_embed(:replies, with: &replies_changeset/2)
|
||||||
|
|> validate_inclusion(:type, ["Note"])
|
||||||
|
|> validate_required([:name, :type])
|
||||||
|
end
|
||||||
|
|
||||||
|
def replies_changeset(struct, data) do
|
||||||
|
struct
|
||||||
|
|> cast(data, [:totalItems, :type])
|
||||||
|
|> validate_inclusion(:type, ["Collection"])
|
||||||
|
|> validate_required([:type])
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,111 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionValidator do
|
||||||
|
use Ecto.Schema
|
||||||
|
|
||||||
|
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonFixes
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.CommonValidations
|
||||||
|
alias Pleroma.Web.ActivityPub.ObjectValidators.QuestionOptionsValidator
|
||||||
|
|
||||||
|
import Ecto.Changeset
|
||||||
|
|
||||||
|
@primary_key false
|
||||||
|
@derive Jason.Encoder
|
||||||
|
|
||||||
|
# Extends from NoteValidator
|
||||||
|
embedded_schema do
|
||||||
|
field(:id, ObjectValidators.ObjectID, primary_key: true)
|
||||||
|
field(:to, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:cc, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:bto, ObjectValidators.Recipients, default: [])
|
||||||
|
field(:bcc, ObjectValidators.Recipients, default: [])
|
||||||
|
# TODO: Write type
|
||||||
|
field(:tag, {:array, :map}, default: [])
|
||||||
|
field(:type, :string)
|
||||||
|
field(:content, :string)
|
||||||
|
field(:context, :string)
|
||||||
|
|
||||||
|
# TODO: Remove actor on objects
|
||||||
|
field(:actor, ObjectValidators.ObjectID)
|
||||||
|
|
||||||
|
field(:attributedTo, ObjectValidators.ObjectID)
|
||||||
|
field(:summary, :string)
|
||||||
|
field(:published, ObjectValidators.DateTime)
|
||||||
|
# TODO: Write type
|
||||||
|
field(:emoji, :map, default: %{})
|
||||||
|
field(:sensitive, :boolean, default: false)
|
||||||
|
embeds_many(:attachment, AttachmentValidator)
|
||||||
|
field(:replies_count, :integer, default: 0)
|
||||||
|
field(:like_count, :integer, default: 0)
|
||||||
|
field(:announcement_count, :integer, default: 0)
|
||||||
|
field(:inReplyTo, ObjectValidators.ObjectID)
|
||||||
|
field(:url, ObjectValidators.Uri)
|
||||||
|
# short identifier for PleromaFE to group statuses by context
|
||||||
|
field(:context_id, :integer)
|
||||||
|
|
||||||
|
field(:likes, {:array, :string}, default: [])
|
||||||
|
field(:announcements, {:array, :string}, default: [])
|
||||||
|
|
||||||
|
field(:closed, ObjectValidators.DateTime)
|
||||||
|
field(:voters, {:array, ObjectValidators.ObjectID}, default: [])
|
||||||
|
embeds_many(:anyOf, QuestionOptionsValidator)
|
||||||
|
embeds_many(:oneOf, QuestionOptionsValidator)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_apply(data) do
|
||||||
|
data
|
||||||
|
|> cast_data
|
||||||
|
|> apply_action(:insert)
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_and_validate(data) do
|
||||||
|
data
|
||||||
|
|> cast_data()
|
||||||
|
|> validate_data()
|
||||||
|
end
|
||||||
|
|
||||||
|
def cast_data(data) do
|
||||||
|
%__MODULE__{}
|
||||||
|
|> changeset(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp fix_closed(data) do
|
||||||
|
cond do
|
||||||
|
is_binary(data["closed"]) -> data
|
||||||
|
is_binary(data["endTime"]) -> Map.put(data, "closed", data["endTime"])
|
||||||
|
true -> Map.drop(data, ["closed"])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp fix(data) do
|
||||||
|
data
|
||||||
|
|> CommonFixes.fix_defaults()
|
||||||
|
|> CommonFixes.fix_attribution()
|
||||||
|
|> fix_closed()
|
||||||
|
end
|
||||||
|
|
||||||
|
def changeset(struct, data) do
|
||||||
|
data = fix(data)
|
||||||
|
|
||||||
|
struct
|
||||||
|
|> cast(data, __schema__(:fields) -- [:anyOf, :oneOf, :attachment])
|
||||||
|
|> cast_embed(:attachment)
|
||||||
|
|> cast_embed(:anyOf)
|
||||||
|
|> cast_embed(:oneOf)
|
||||||
|
end
|
||||||
|
|
||||||
|
def validate_data(data_cng) do
|
||||||
|
data_cng
|
||||||
|
|> validate_inclusion(:type, ["Question"])
|
||||||
|
|> validate_required([:id, :actor, :attributedTo, :type, :context, :context_id])
|
||||||
|
|> CommonValidations.validate_any_presence([:cc, :to])
|
||||||
|
|> CommonValidations.validate_fields_match([:actor, :attributedTo])
|
||||||
|
|> CommonValidations.validate_actor_presence()
|
||||||
|
|> CommonValidations.validate_any_presence([:oneOf, :anyOf])
|
||||||
|
|> CommonValidations.validate_host_match()
|
||||||
|
end
|
||||||
|
end
|
|
@ -18,8 +18,8 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UndoValidator do
|
||||||
field(:type, :string)
|
field(:type, :string)
|
||||||
field(:object, ObjectValidators.ObjectID)
|
field(:object, ObjectValidators.ObjectID)
|
||||||
field(:actor, ObjectValidators.ObjectID)
|
field(:actor, ObjectValidators.ObjectID)
|
||||||
field(:to, {:array, :string}, default: [])
|
field(:to, ObjectValidators.Recipients, default: [])
|
||||||
field(:cc, {:array, :string}, default: [])
|
field(:cc, ObjectValidators.Recipients, default: [])
|
||||||
end
|
end
|
||||||
|
|
||||||
def cast_and_validate(data) do
|
def cast_and_validate(data) do
|
||||||
|
|
|
@ -13,7 +13,7 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.UrlObjectValidator do
|
||||||
embedded_schema do
|
embedded_schema do
|
||||||
field(:type, :string)
|
field(:type, :string)
|
||||||
field(:href, ObjectValidators.Uri)
|
field(:href, ObjectValidators.Uri)
|
||||||
field(:mediaType, :string)
|
field(:mediaType, :string, default: "application/octet-stream")
|
||||||
end
|
end
|
||||||
|
|
||||||
def changeset(struct, data) do
|
def changeset(struct, data) do
|
||||||
|
|
|
@ -10,19 +10,13 @@ defmodule Pleroma.Web.ActivityPub.Relay do
|
||||||
alias Pleroma.Web.CommonAPI
|
alias Pleroma.Web.CommonAPI
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
@relay_nickname "relay"
|
@nickname "relay"
|
||||||
|
|
||||||
def get_actor do
|
@spec ap_id() :: String.t()
|
||||||
actor =
|
def ap_id, do: "#{Pleroma.Web.Endpoint.url()}/#{@nickname}"
|
||||||
relay_ap_id()
|
|
||||||
|> User.get_or_create_service_actor_by_ap_id(@relay_nickname)
|
|
||||||
|
|
||||||
actor
|
@spec get_actor() :: User.t() | nil
|
||||||
end
|
def get_actor, do: User.get_or_create_service_actor_by_ap_id(ap_id(), @nickname)
|
||||||
|
|
||||||
def relay_ap_id do
|
|
||||||
"#{Pleroma.Web.Endpoint.url()}/relay"
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec follow(String.t()) :: {:ok, Activity.t()} | {:error, any()}
|
@spec follow(String.t()) :: {:ok, Activity.t()} | {:error, any()}
|
||||||
def follow(target_instance) do
|
def follow(target_instance) do
|
||||||
|
@ -61,34 +55,38 @@ def publish(%Activity{data: %{"type" => "Create"}} = activity) do
|
||||||
|
|
||||||
def publish(_), do: {:error, "Not implemented"}
|
def publish(_), do: {:error, "Not implemented"}
|
||||||
|
|
||||||
@spec list(boolean()) :: {:ok, [String.t()]} | {:error, any()}
|
@spec list() :: {:ok, [%{actor: String.t(), followed_back: boolean()}]} | {:error, any()}
|
||||||
def list(with_not_accepted \\ false) do
|
def list do
|
||||||
with %User{} = user <- get_actor() do
|
with %User{} = user <- get_actor() do
|
||||||
accepted =
|
accepted =
|
||||||
user
|
user
|
||||||
|> User.following()
|
|> following()
|
||||||
|> Enum.map(fn entry -> URI.parse(entry).host end)
|
|> Enum.map(fn actor -> %{actor: actor, followed_back: true} end)
|
||||||
|> Enum.uniq()
|
|
||||||
|
|
||||||
list =
|
|
||||||
if with_not_accepted do
|
|
||||||
without_accept =
|
without_accept =
|
||||||
user
|
user
|
||||||
|> Pleroma.Activity.following_requests_for_actor()
|
|> Pleroma.Activity.following_requests_for_actor()
|
||||||
|> Enum.map(fn a -> URI.parse(a.data["object"]).host <> " (no Accept received)" end)
|
|> Enum.map(fn activity -> %{actor: activity.data["object"], followed_back: false} end)
|
||||||
|> Enum.uniq()
|
|> Enum.uniq()
|
||||||
|
|
||||||
accepted ++ without_accept
|
{:ok, accepted ++ without_accept}
|
||||||
else
|
|
||||||
accepted
|
|
||||||
end
|
|
||||||
|
|
||||||
{:ok, list}
|
|
||||||
else
|
else
|
||||||
error -> format_error(error)
|
error -> format_error(error)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec following() :: [String.t()]
|
||||||
|
def following do
|
||||||
|
get_actor()
|
||||||
|
|> following()
|
||||||
|
end
|
||||||
|
|
||||||
|
defp following(user) do
|
||||||
|
user
|
||||||
|
|> User.following_ap_ids()
|
||||||
|
|> Enum.uniq()
|
||||||
|
end
|
||||||
|
|
||||||
defp format_error({:error, error}), do: format_error(error)
|
defp format_error({:error, error}), do: format_error(error)
|
||||||
|
|
||||||
defp format_error(error) do
|
defp format_error(error) do
|
||||||
|
|
|
@ -7,6 +7,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
||||||
"""
|
"""
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
alias Pleroma.Activity.Ir.Topics
|
alias Pleroma.Activity.Ir.Topics
|
||||||
|
alias Pleroma.ActivityExpiration
|
||||||
alias Pleroma.Chat
|
alias Pleroma.Chat
|
||||||
alias Pleroma.Chat.MessageReference
|
alias Pleroma.Chat.MessageReference
|
||||||
alias Pleroma.FollowingRelationship
|
alias Pleroma.FollowingRelationship
|
||||||
|
@ -15,13 +16,70 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
|
alias Pleroma.Web.ActivityPub.Builder
|
||||||
alias Pleroma.Web.ActivityPub.Pipeline
|
alias Pleroma.Web.ActivityPub.Pipeline
|
||||||
alias Pleroma.Web.ActivityPub.Utils
|
alias Pleroma.Web.ActivityPub.Utils
|
||||||
alias Pleroma.Web.Push
|
alias Pleroma.Web.Push
|
||||||
alias Pleroma.Web.Streamer
|
alias Pleroma.Web.Streamer
|
||||||
|
alias Pleroma.Workers.BackgroundWorker
|
||||||
|
|
||||||
|
require Logger
|
||||||
|
|
||||||
def handle(object, meta \\ [])
|
def handle(object, meta \\ [])
|
||||||
|
|
||||||
|
# Task this handles
|
||||||
|
# - Follows
|
||||||
|
# - Sends a notification
|
||||||
|
def handle(
|
||||||
|
%{
|
||||||
|
data: %{
|
||||||
|
"actor" => actor,
|
||||||
|
"type" => "Accept",
|
||||||
|
"object" => follow_activity_id
|
||||||
|
}
|
||||||
|
} = object,
|
||||||
|
meta
|
||||||
|
) do
|
||||||
|
with %Activity{actor: follower_id} = follow_activity <-
|
||||||
|
Activity.get_by_ap_id(follow_activity_id),
|
||||||
|
%User{} = followed <- User.get_cached_by_ap_id(actor),
|
||||||
|
%User{} = follower <- User.get_cached_by_ap_id(follower_id),
|
||||||
|
{:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "accept"),
|
||||||
|
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_accept) do
|
||||||
|
Notification.update_notification_type(followed, follow_activity)
|
||||||
|
User.update_follower_count(followed)
|
||||||
|
User.update_following_count(follower)
|
||||||
|
end
|
||||||
|
|
||||||
|
{:ok, object, meta}
|
||||||
|
end
|
||||||
|
|
||||||
|
# Task this handles
|
||||||
|
# - Rejects all existing follow activities for this person
|
||||||
|
# - Updates the follow state
|
||||||
|
# - Dismisses notification
|
||||||
|
def handle(
|
||||||
|
%{
|
||||||
|
data: %{
|
||||||
|
"actor" => actor,
|
||||||
|
"type" => "Reject",
|
||||||
|
"object" => follow_activity_id
|
||||||
|
}
|
||||||
|
} = object,
|
||||||
|
meta
|
||||||
|
) do
|
||||||
|
with %Activity{actor: follower_id} = follow_activity <-
|
||||||
|
Activity.get_by_ap_id(follow_activity_id),
|
||||||
|
%User{} = followed <- User.get_cached_by_ap_id(actor),
|
||||||
|
%User{} = follower <- User.get_cached_by_ap_id(follower_id),
|
||||||
|
{:ok, _follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "reject") do
|
||||||
|
FollowingRelationship.update(follower, followed, :follow_reject)
|
||||||
|
Notification.dismiss(follow_activity)
|
||||||
|
end
|
||||||
|
|
||||||
|
{:ok, object, meta}
|
||||||
|
end
|
||||||
|
|
||||||
# Tasks this handle
|
# Tasks this handle
|
||||||
# - Follows if possible
|
# - Follows if possible
|
||||||
# - Sends a notification
|
# - Sends a notification
|
||||||
|
@ -42,33 +100,13 @@ def handle(
|
||||||
{_, {:ok, _}, _, _} <-
|
{_, {:ok, _}, _, _} <-
|
||||||
{:following, User.follow(follower, followed, :follow_pending), follower, followed} do
|
{:following, User.follow(follower, followed, :follow_pending), follower, followed} do
|
||||||
if followed.local && !followed.locked do
|
if followed.local && !followed.locked do
|
||||||
Utils.update_follow_state_for_all(object, "accept")
|
{:ok, accept_data, _} = Builder.accept(followed, object)
|
||||||
FollowingRelationship.update(follower, followed, :follow_accept)
|
{:ok, _activity, _} = Pipeline.common_pipeline(accept_data, local: true)
|
||||||
User.update_follower_count(followed)
|
|
||||||
User.update_following_count(follower)
|
|
||||||
|
|
||||||
%{
|
|
||||||
to: [following_user],
|
|
||||||
actor: followed,
|
|
||||||
object: follow_id,
|
|
||||||
local: true
|
|
||||||
}
|
|
||||||
|> ActivityPub.accept()
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{:following, {:error, _}, follower, followed} ->
|
{:following, {:error, _}, _follower, followed} ->
|
||||||
Utils.update_follow_state_for_all(object, "reject")
|
{:ok, reject_data, _} = Builder.reject(followed, object)
|
||||||
FollowingRelationship.update(follower, followed, :follow_reject)
|
{:ok, _activity, _} = Pipeline.common_pipeline(reject_data, local: true)
|
||||||
|
|
||||||
if followed.local do
|
|
||||||
%{
|
|
||||||
to: [follower.ap_id],
|
|
||||||
actor: followed,
|
|
||||||
object: follow_id,
|
|
||||||
local: true
|
|
||||||
}
|
|
||||||
|> ActivityPub.reject()
|
|
||||||
end
|
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
nil
|
nil
|
||||||
|
@ -135,10 +173,26 @@ def handle(%{data: %{"type" => "Like"}} = object, meta) do
|
||||||
# Tasks this handles
|
# Tasks this handles
|
||||||
# - Actually create object
|
# - Actually create object
|
||||||
# - Rollback if we couldn't create it
|
# - Rollback if we couldn't create it
|
||||||
|
# - Increase the user note count
|
||||||
|
# - Increase the reply count
|
||||||
|
# - Increase replies count
|
||||||
|
# - Set up ActivityExpiration
|
||||||
# - Set up notifications
|
# - Set up notifications
|
||||||
def handle(%{data: %{"type" => "Create"}} = activity, meta) do
|
def handle(%{data: %{"type" => "Create"}} = activity, meta) do
|
||||||
with {:ok, _object, meta} <- handle_object_creation(meta[:object_data], meta) do
|
with {:ok, object, meta} <- handle_object_creation(meta[:object_data], meta),
|
||||||
|
%User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
|
||||||
{:ok, notifications} = Notification.create_notifications(activity, do_send: false)
|
{:ok, notifications} = Notification.create_notifications(activity, do_send: false)
|
||||||
|
{:ok, _user} = ActivityPub.increase_note_count_if_public(user, object)
|
||||||
|
|
||||||
|
if in_reply_to = object.data["inReplyTo"] do
|
||||||
|
Object.increase_replies_count(in_reply_to)
|
||||||
|
end
|
||||||
|
|
||||||
|
if expires_at = activity.data["expires_at"] do
|
||||||
|
ActivityExpiration.create(activity, expires_at)
|
||||||
|
end
|
||||||
|
|
||||||
|
BackgroundWorker.enqueue("fetch_data_for_activity", %{"activity_id" => activity.id})
|
||||||
|
|
||||||
meta =
|
meta =
|
||||||
meta
|
meta
|
||||||
|
@ -199,13 +253,15 @@ def handle(%{data: %{"type" => "EmojiReact"}} = object, meta) do
|
||||||
# - Stream out the activity
|
# - Stream out the activity
|
||||||
def handle(%{data: %{"type" => "Delete", "object" => deleted_object}} = object, meta) do
|
def handle(%{data: %{"type" => "Delete", "object" => deleted_object}} = object, meta) do
|
||||||
deleted_object =
|
deleted_object =
|
||||||
Object.normalize(deleted_object, false) || User.get_cached_by_ap_id(deleted_object)
|
Object.normalize(deleted_object, false) ||
|
||||||
|
User.get_cached_by_ap_id(deleted_object)
|
||||||
|
|
||||||
result =
|
result =
|
||||||
case deleted_object do
|
case deleted_object do
|
||||||
%Object{} ->
|
%Object{} ->
|
||||||
with {:ok, deleted_object, activity} <- Object.delete(deleted_object),
|
with {:ok, deleted_object, activity} <- Object.delete(deleted_object),
|
||||||
%User{} = user <- User.get_cached_by_ap_id(deleted_object.data["actor"]) do
|
{_, actor} when is_binary(actor) <- {:actor, deleted_object.data["actor"]},
|
||||||
|
%User{} = user <- User.get_cached_by_ap_id(actor) do
|
||||||
User.remove_pinnned_activity(user, activity)
|
User.remove_pinnned_activity(user, activity)
|
||||||
|
|
||||||
{:ok, user} = ActivityPub.decrease_note_count_if_public(user, deleted_object)
|
{:ok, user} = ActivityPub.decrease_note_count_if_public(user, deleted_object)
|
||||||
|
@ -219,6 +275,10 @@ def handle(%{data: %{"type" => "Delete", "object" => deleted_object}} = object,
|
||||||
ActivityPub.stream_out(object)
|
ActivityPub.stream_out(object)
|
||||||
ActivityPub.stream_out_participations(deleted_object, user)
|
ActivityPub.stream_out_participations(deleted_object, user)
|
||||||
:ok
|
:ok
|
||||||
|
else
|
||||||
|
{:actor, _} ->
|
||||||
|
Logger.error("The object doesn't have an actor: #{inspect(deleted_object)}")
|
||||||
|
:no_object_actor
|
||||||
end
|
end
|
||||||
|
|
||||||
%User{} ->
|
%User{} ->
|
||||||
|
@ -268,9 +328,28 @@ def handle_object_creation(%{"type" => "ChatMessage"} = object, meta) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def handle_object_creation(%{"type" => "Answer"} = object_map, meta) do
|
||||||
|
with {:ok, object, meta} <- Pipeline.common_pipeline(object_map, meta) do
|
||||||
|
Object.increase_vote_count(
|
||||||
|
object.data["inReplyTo"],
|
||||||
|
object.data["name"],
|
||||||
|
object.data["actor"]
|
||||||
|
)
|
||||||
|
|
||||||
|
{:ok, object, meta}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def handle_object_creation(%{"type" => objtype} = object, meta)
|
||||||
|
when objtype in ~w[Audio Question Event] do
|
||||||
|
with {:ok, object, meta} <- Pipeline.common_pipeline(object, meta) do
|
||||||
|
{:ok, object, meta}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Nothing to do
|
# Nothing to do
|
||||||
def handle_object_creation(object) do
|
def handle_object_creation(object, meta) do
|
||||||
{:ok, object}
|
{:ok, object, meta}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp undo_like(nil, object), do: delete_object(object)
|
defp undo_like(nil, object), do: delete_object(object)
|
||||||
|
|
|
@ -9,9 +9,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
alias Pleroma.EarmarkRenderer
|
alias Pleroma.EarmarkRenderer
|
||||||
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
alias Pleroma.EctoType.ActivityPub.ObjectValidators
|
||||||
alias Pleroma.FollowingRelationship
|
|
||||||
alias Pleroma.Maps
|
alias Pleroma.Maps
|
||||||
alias Pleroma.Notification
|
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.Object.Containment
|
alias Pleroma.Object.Containment
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
|
@ -157,7 +155,12 @@ def fix_addressing(object) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_actor(%{"attributedTo" => actor} = object) do
|
def fix_actor(%{"attributedTo" => actor} = object) do
|
||||||
Map.put(object, "actor", Containment.get_actor(%{"actor" => actor}))
|
actor = Containment.get_actor(%{"actor" => actor})
|
||||||
|
|
||||||
|
# TODO: Remove actor field for Objects
|
||||||
|
object
|
||||||
|
|> Map.put("actor", actor)
|
||||||
|
|> Map.put("attributedTo", actor)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_in_reply_to(object, options \\ [])
|
def fix_in_reply_to(object, options \\ [])
|
||||||
|
@ -240,13 +243,17 @@ def fix_attachments(%{"attachment" => attachment} = object) when is_list(attachm
|
||||||
|
|
||||||
if href do
|
if href do
|
||||||
attachment_url =
|
attachment_url =
|
||||||
%{"href" => href}
|
%{
|
||||||
|
"href" => href,
|
||||||
|
"type" => Map.get(url || %{}, "type", "Link")
|
||||||
|
}
|
||||||
|> Maps.put_if_present("mediaType", media_type)
|
|> Maps.put_if_present("mediaType", media_type)
|
||||||
|> Maps.put_if_present("type", Map.get(url || %{}, "type"))
|
|
||||||
|
|
||||||
%{"url" => [attachment_url]}
|
%{
|
||||||
|
"url" => [attachment_url],
|
||||||
|
"type" => data["type"] || "Document"
|
||||||
|
}
|
||||||
|> Maps.put_if_present("mediaType", media_type)
|
|> Maps.put_if_present("mediaType", media_type)
|
||||||
|> Maps.put_if_present("type", data["type"])
|
|
||||||
|> Maps.put_if_present("name", data["name"])
|
|> Maps.put_if_present("name", data["name"])
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
|
@ -269,13 +276,12 @@ def fix_url(%{"url" => url} = object) when is_map(url) do
|
||||||
Map.put(object, "url", url["href"])
|
Map.put(object, "url", url["href"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_url(%{"type" => object_type, "url" => url} = object)
|
def fix_url(%{"type" => "Video", "url" => url} = object) when is_list(url) do
|
||||||
when object_type in ["Video", "Audio"] and is_list(url) do
|
|
||||||
attachment =
|
attachment =
|
||||||
Enum.find(url, fn x ->
|
Enum.find(url, fn x ->
|
||||||
media_type = x["mediaType"] || x["mimeType"] || ""
|
media_type = x["mediaType"] || x["mimeType"] || ""
|
||||||
|
|
||||||
is_map(x) and String.starts_with?(media_type, ["audio/", "video/"])
|
is_map(x) and String.starts_with?(media_type, "video/")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
link_element =
|
link_element =
|
||||||
|
@ -382,32 +388,6 @@ defp fix_content(%{"mediaType" => "text/markdown", "content" => content} = objec
|
||||||
|
|
||||||
defp fix_content(object), do: object
|
defp fix_content(object), do: object
|
||||||
|
|
||||||
defp mastodon_follow_hack(%{"id" => id, "actor" => follower_id}, followed) do
|
|
||||||
with true <- id =~ "follows",
|
|
||||||
%User{local: true} = follower <- User.get_cached_by_ap_id(follower_id),
|
|
||||||
%Activity{} = activity <- Utils.fetch_latest_follow(follower, followed) do
|
|
||||||
{:ok, activity}
|
|
||||||
else
|
|
||||||
_ -> {:error, nil}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp mastodon_follow_hack(_, _), do: {:error, nil}
|
|
||||||
|
|
||||||
defp get_follow_activity(follow_object, followed) do
|
|
||||||
with object_id when not is_nil(object_id) <- Utils.get_ap_id(follow_object),
|
|
||||||
{_, %Activity{} = activity} <- {:activity, Activity.get_by_ap_id(object_id)} do
|
|
||||||
{:ok, activity}
|
|
||||||
else
|
|
||||||
# Can't find the activity. This might a Mastodon 2.3 "Accept"
|
|
||||||
{:activity, nil} ->
|
|
||||||
mastodon_follow_hack(follow_object, followed)
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
{:error, nil}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Reduce the object list to find the reported user.
|
# Reduce the object list to find the reported user.
|
||||||
defp get_reported(objects) do
|
defp get_reported(objects) do
|
||||||
Enum.reduce_while(objects, nil, fn ap_id, _ ->
|
Enum.reduce_while(objects, nil, fn ap_id, _ ->
|
||||||
|
@ -419,6 +399,29 @@ defp get_reported(objects) do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Compatibility wrapper for Mastodon votes
|
||||||
|
defp handle_create(%{"object" => %{"type" => "Answer"}} = data, _user) do
|
||||||
|
handle_incoming(data)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp handle_create(%{"object" => object} = data, user) do
|
||||||
|
%{
|
||||||
|
to: data["to"],
|
||||||
|
object: object,
|
||||||
|
actor: user,
|
||||||
|
context: object["context"],
|
||||||
|
local: false,
|
||||||
|
published: data["published"],
|
||||||
|
additional:
|
||||||
|
Map.take(data, [
|
||||||
|
"cc",
|
||||||
|
"directMessage",
|
||||||
|
"id"
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|> ActivityPub.create()
|
||||||
|
end
|
||||||
|
|
||||||
def handle_incoming(data, options \\ [])
|
def handle_incoming(data, options \\ [])
|
||||||
|
|
||||||
# Flag objects are placed ahead of the ID check because Mastodon 2.8 and earlier send them
|
# Flag objects are placed ahead of the ID check because Mastodon 2.8 and earlier send them
|
||||||
|
@ -457,30 +460,18 @@ def handle_incoming(
|
||||||
%{"type" => "Create", "object" => %{"type" => objtype} = object} = data,
|
%{"type" => "Create", "object" => %{"type" => objtype} = object} = data,
|
||||||
options
|
options
|
||||||
)
|
)
|
||||||
when objtype in ["Article", "Event", "Note", "Video", "Page", "Question", "Answer", "Audio"] do
|
when objtype in ~w{Article Note Video Page} do
|
||||||
actor = Containment.get_actor(data)
|
actor = Containment.get_actor(data)
|
||||||
|
|
||||||
with nil <- Activity.get_create_by_object_ap_id(object["id"]),
|
with nil <- Activity.get_create_by_object_ap_id(object["id"]),
|
||||||
{:ok, %User{} = user} <- User.get_or_fetch_by_ap_id(actor),
|
{:ok, %User{} = user} <- User.get_or_fetch_by_ap_id(actor) do
|
||||||
data <- Map.put(data, "actor", actor) |> fix_addressing() do
|
data =
|
||||||
object = fix_object(object, options)
|
data
|
||||||
|
|> Map.put("object", fix_object(object, options))
|
||||||
|
|> Map.put("actor", actor)
|
||||||
|
|> fix_addressing()
|
||||||
|
|
||||||
params = %{
|
with {:ok, created_activity} <- handle_create(data, user) do
|
||||||
to: data["to"],
|
|
||||||
object: object,
|
|
||||||
actor: user,
|
|
||||||
context: object["context"],
|
|
||||||
local: false,
|
|
||||||
published: data["published"],
|
|
||||||
additional:
|
|
||||||
Map.take(data, [
|
|
||||||
"cc",
|
|
||||||
"directMessage",
|
|
||||||
"id"
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
with {:ok, created_activity} <- ActivityPub.create(params) do
|
|
||||||
reply_depth = (options[:depth] || 0) + 1
|
reply_depth = (options[:depth] || 0) + 1
|
||||||
|
|
||||||
if Federator.allowed_thread_distance?(reply_depth) do
|
if Federator.allowed_thread_distance?(reply_depth) do
|
||||||
|
@ -531,60 +522,6 @@ def handle_incoming(
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_incoming(
|
|
||||||
%{"type" => "Accept", "object" => follow_object, "actor" => _actor, "id" => id} = data,
|
|
||||||
_options
|
|
||||||
) do
|
|
||||||
with actor <- Containment.get_actor(data),
|
|
||||||
{:ok, %User{} = followed} <- User.get_or_fetch_by_ap_id(actor),
|
|
||||||
{:ok, follow_activity} <- get_follow_activity(follow_object, followed),
|
|
||||||
{:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "accept"),
|
|
||||||
%User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity.data["actor"]),
|
|
||||||
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_accept) do
|
|
||||||
User.update_follower_count(followed)
|
|
||||||
User.update_following_count(follower)
|
|
||||||
|
|
||||||
Notification.update_notification_type(followed, follow_activity)
|
|
||||||
|
|
||||||
ActivityPub.accept(%{
|
|
||||||
to: follow_activity.data["to"],
|
|
||||||
type: "Accept",
|
|
||||||
actor: followed,
|
|
||||||
object: follow_activity.data["id"],
|
|
||||||
local: false,
|
|
||||||
activity_id: id
|
|
||||||
})
|
|
||||||
else
|
|
||||||
_e ->
|
|
||||||
:error
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def handle_incoming(
|
|
||||||
%{"type" => "Reject", "object" => follow_object, "actor" => _actor, "id" => id} = data,
|
|
||||||
_options
|
|
||||||
) do
|
|
||||||
with actor <- Containment.get_actor(data),
|
|
||||||
{:ok, %User{} = followed} <- User.get_or_fetch_by_ap_id(actor),
|
|
||||||
{:ok, follow_activity} <- get_follow_activity(follow_object, followed),
|
|
||||||
{:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "reject"),
|
|
||||||
%User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity.data["actor"]),
|
|
||||||
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_reject),
|
|
||||||
{:ok, activity} <-
|
|
||||||
ActivityPub.reject(%{
|
|
||||||
to: follow_activity.data["to"],
|
|
||||||
type: "Reject",
|
|
||||||
actor: followed,
|
|
||||||
object: follow_activity.data["id"],
|
|
||||||
local: false,
|
|
||||||
activity_id: id
|
|
||||||
}) do
|
|
||||||
{:ok, activity}
|
|
||||||
else
|
|
||||||
_e -> :error
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@misskey_reactions %{
|
@misskey_reactions %{
|
||||||
"like" => "👍",
|
"like" => "👍",
|
||||||
"love" => "❤️",
|
"love" => "❤️",
|
||||||
|
@ -614,9 +551,10 @@ def handle_incoming(
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_incoming(
|
def handle_incoming(
|
||||||
%{"type" => "Create", "object" => %{"type" => "ChatMessage"}} = data,
|
%{"type" => "Create", "object" => %{"type" => objtype}} = data,
|
||||||
_options
|
_options
|
||||||
) do
|
)
|
||||||
|
when objtype in ~w{Question Answer ChatMessage Audio Event} do
|
||||||
with {:ok, %User{}} <- ObjectValidator.fetch_actor(data),
|
with {:ok, %User{}} <- ObjectValidator.fetch_actor(data),
|
||||||
{:ok, activity, _} <- Pipeline.common_pipeline(data, local: false) do
|
{:ok, activity, _} <- Pipeline.common_pipeline(data, local: false) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
|
@ -638,9 +576,10 @@ def handle_incoming(
|
||||||
%{"type" => type} = data,
|
%{"type" => type} = data,
|
||||||
_options
|
_options
|
||||||
)
|
)
|
||||||
when type in ~w{Update Block Follow} do
|
when type in ~w{Update Block Follow Accept Reject} do
|
||||||
with {:ok, %User{}} <- ObjectValidator.fetch_actor(data),
|
with {:ok, %User{}} <- ObjectValidator.fetch_actor(data),
|
||||||
{:ok, activity, _} <- Pipeline.common_pipeline(data, local: false) do
|
{:ok, activity, _} <-
|
||||||
|
Pipeline.common_pipeline(data, local: false) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -649,7 +588,8 @@ def handle_incoming(
|
||||||
%{"type" => "Delete"} = data,
|
%{"type" => "Delete"} = data,
|
||||||
_options
|
_options
|
||||||
) do
|
) do
|
||||||
with {:ok, activity, _} <- Pipeline.common_pipeline(data, local: false) do
|
with {:ok, activity, _} <-
|
||||||
|
Pipeline.common_pipeline(data, local: false) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
{:error, {:validate_object, _}} = e ->
|
{:error, {:validate_object, _}} = e ->
|
||||||
|
|
|
@ -59,12 +59,9 @@ def visible_for_user?(%{data: %{"listMessage" => list_ap_id}} = activity, %User{
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_for_user?(%{local: local} = activity, nil) do
|
def visible_for_user?(%{local: local} = activity, nil) do
|
||||||
cfg_key =
|
cfg_key = if local, do: :local, else: :remote
|
||||||
if local,
|
|
||||||
do: :local,
|
|
||||||
else: :remote
|
|
||||||
|
|
||||||
if Pleroma.Config.get([:restrict_unauthenticated, :activities, cfg_key]),
|
if Pleroma.Config.restrict_unauthenticated_access?(:activities, cfg_key),
|
||||||
do: false,
|
do: false,
|
||||||
else: is_public?(activity)
|
else: is_public?(activity)
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,29 +26,40 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheController do
|
||||||
defdelegate open_api_operation(action), to: Spec.MediaProxyCacheOperation
|
defdelegate open_api_operation(action), to: Spec.MediaProxyCacheOperation
|
||||||
|
|
||||||
def index(%{assigns: %{user: _}} = conn, params) do
|
def index(%{assigns: %{user: _}} = conn, params) do
|
||||||
cursor =
|
entries = fetch_entries(params)
|
||||||
:banned_urls_cache
|
urls = paginate_entries(entries, params.page, params.page_size)
|
||||||
|> :ets.table([{:traverse, {:select, Cachex.Query.create(true, :key)}}])
|
|
||||||
|> :qlc.cursor()
|
|
||||||
|
|
||||||
urls =
|
render(conn, "index.json",
|
||||||
case params.page do
|
urls: urls,
|
||||||
1 ->
|
page_size: params.page_size,
|
||||||
:qlc.next_answers(cursor, params.page_size)
|
count: length(entries)
|
||||||
|
)
|
||||||
_ ->
|
|
||||||
:qlc.next_answers(cursor, (params.page - 1) * params.page_size)
|
|
||||||
:qlc.next_answers(cursor, params.page_size)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
:qlc.delete_cursor(cursor)
|
defp fetch_entries(params) do
|
||||||
|
MediaProxy.cache_table()
|
||||||
|
|> Cachex.stream!(Cachex.Query.create(true, :key))
|
||||||
|
|> filter_entries(params[:query])
|
||||||
|
end
|
||||||
|
|
||||||
render(conn, "index.json", urls: urls)
|
defp filter_entries(stream, query) when is_binary(query) do
|
||||||
|
regex = ~r/#{query}/i
|
||||||
|
|
||||||
|
stream
|
||||||
|
|> Enum.filter(fn url -> String.match?(url, regex) end)
|
||||||
|
|> Enum.to_list()
|
||||||
|
end
|
||||||
|
|
||||||
|
defp filter_entries(stream, _), do: Enum.to_list(stream)
|
||||||
|
|
||||||
|
defp paginate_entries(entries, page, page_size) do
|
||||||
|
offset = page_size * (page - 1)
|
||||||
|
Enum.slice(entries, offset, page_size)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete(%{assigns: %{user: _}, body_params: %{urls: urls}} = conn, _) do
|
def delete(%{assigns: %{user: _}, body_params: %{urls: urls}} = conn, _) do
|
||||||
MediaProxy.remove_from_banned_urls(urls)
|
MediaProxy.remove_from_banned_urls(urls)
|
||||||
render(conn, "index.json", urls: urls)
|
json(conn, %{})
|
||||||
end
|
end
|
||||||
|
|
||||||
def purge(%{assigns: %{user: _}, body_params: %{urls: urls, ban: ban}} = conn, _) do
|
def purge(%{assigns: %{user: _}, body_params: %{urls: urls, ban: ban}} = conn, _) do
|
||||||
|
@ -58,6 +69,6 @@ def purge(%{assigns: %{user: _}, body_params: %{urls: urls, ban: ban}} = conn, _
|
||||||
MediaProxy.put_in_banned_urls(urls)
|
MediaProxy.put_in_banned_urls(urls)
|
||||||
end
|
end
|
||||||
|
|
||||||
render(conn, "index.json", urls: urls)
|
json(conn, %{})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,7 +39,7 @@ def follow(%{assigns: %{user: admin}, body_params: %{relay_url: target}} = conn,
|
||||||
target: target
|
target: target
|
||||||
})
|
})
|
||||||
|
|
||||||
json(conn, target)
|
json(conn, %{actor: target, followed_back: target in Relay.following()})
|
||||||
else
|
else
|
||||||
_ ->
|
_ ->
|
||||||
conn
|
conn
|
||||||
|
|
|
@ -79,7 +79,8 @@ def render("show.json", %{user: user}) do
|
||||||
"confirmation_pending" => user.confirmation_pending,
|
"confirmation_pending" => user.confirmation_pending,
|
||||||
"approval_pending" => user.approval_pending,
|
"approval_pending" => user.approval_pending,
|
||||||
"url" => user.uri || user.ap_id,
|
"url" => user.uri || user.ap_id,
|
||||||
"registration_reason" => user.registration_reason
|
"registration_reason" => user.registration_reason,
|
||||||
|
"actor_type" => user.actor_type
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,11 @@
|
||||||
defmodule Pleroma.Web.AdminAPI.MediaProxyCacheView do
|
defmodule Pleroma.Web.AdminAPI.MediaProxyCacheView do
|
||||||
use Pleroma.Web, :view
|
use Pleroma.Web, :view
|
||||||
|
|
||||||
def render("index.json", %{urls: urls}) do
|
def render("index.json", %{urls: urls, page_size: page_size, count: count}) do
|
||||||
%{urls: urls}
|
%{
|
||||||
|
urls: urls,
|
||||||
|
count: count,
|
||||||
|
page_size: page_size
|
||||||
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,6 +21,12 @@ def index_operation do
|
||||||
operationId: "AdminAPI.MediaProxyCacheController.index",
|
operationId: "AdminAPI.MediaProxyCacheController.index",
|
||||||
security: [%{"oAuth" => ["read:media_proxy_caches"]}],
|
security: [%{"oAuth" => ["read:media_proxy_caches"]}],
|
||||||
parameters: [
|
parameters: [
|
||||||
|
Operation.parameter(
|
||||||
|
:query,
|
||||||
|
:query,
|
||||||
|
%Schema{type: :string, default: nil},
|
||||||
|
"Page"
|
||||||
|
),
|
||||||
Operation.parameter(
|
Operation.parameter(
|
||||||
:page,
|
:page,
|
||||||
:query,
|
:query,
|
||||||
|
@ -36,7 +42,26 @@ def index_operation do
|
||||||
| admin_api_params()
|
| admin_api_params()
|
||||||
],
|
],
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => success_response()
|
200 =>
|
||||||
|
Operation.response(
|
||||||
|
"Array of banned MediaProxy URLs in Cachex",
|
||||||
|
"application/json",
|
||||||
|
%Schema{
|
||||||
|
type: :object,
|
||||||
|
properties: %{
|
||||||
|
count: %Schema{type: :integer},
|
||||||
|
page_size: %Schema{type: :integer},
|
||||||
|
urls: %Schema{
|
||||||
|
type: :array,
|
||||||
|
items: %Schema{
|
||||||
|
type: :string,
|
||||||
|
format: :uri,
|
||||||
|
description: "MediaProxy URLs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -61,7 +86,7 @@ def delete_operation do
|
||||||
required: true
|
required: true
|
||||||
),
|
),
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => success_response(),
|
200 => empty_object_response(),
|
||||||
400 => Operation.response("Error", "application/json", ApiError)
|
400 => Operation.response("Error", "application/json", ApiError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,25 +113,9 @@ def purge_operation do
|
||||||
required: true
|
required: true
|
||||||
),
|
),
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => success_response(),
|
200 => empty_object_response(),
|
||||||
400 => Operation.response("Error", "application/json", ApiError)
|
400 => Operation.response("Error", "application/json", ApiError)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
defp success_response do
|
|
||||||
Operation.response("Array of banned MediaProxy URLs in Cachex", "application/json", %Schema{
|
|
||||||
type: :object,
|
|
||||||
properties: %{
|
|
||||||
urls: %Schema{
|
|
||||||
type: :array,
|
|
||||||
items: %Schema{
|
|
||||||
type: :string,
|
|
||||||
format: :uri,
|
|
||||||
description: "MediaProxy URLs"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,8 +27,7 @@ def index_operation do
|
||||||
properties: %{
|
properties: %{
|
||||||
relays: %Schema{
|
relays: %Schema{
|
||||||
type: :array,
|
type: :array,
|
||||||
items: %Schema{type: :string},
|
items: relay()
|
||||||
example: ["lain.com", "mstdn.io"]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -43,19 +42,9 @@ def follow_operation do
|
||||||
operationId: "AdminAPI.RelayController.follow",
|
operationId: "AdminAPI.RelayController.follow",
|
||||||
security: [%{"oAuth" => ["write:follows"]}],
|
security: [%{"oAuth" => ["write:follows"]}],
|
||||||
parameters: admin_api_params(),
|
parameters: admin_api_params(),
|
||||||
requestBody:
|
requestBody: request_body("Parameters", relay_url()),
|
||||||
request_body("Parameters", %Schema{
|
|
||||||
type: :object,
|
|
||||||
properties: %{
|
|
||||||
relay_url: %Schema{type: :string, format: :uri}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
responses: %{
|
responses: %{
|
||||||
200 =>
|
200 => Operation.response("Status", "application/json", relay())
|
||||||
Operation.response("Status", "application/json", %Schema{
|
|
||||||
type: :string,
|
|
||||||
example: "http://mastodon.example.org/users/admin"
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -67,13 +56,7 @@ def unfollow_operation do
|
||||||
operationId: "AdminAPI.RelayController.unfollow",
|
operationId: "AdminAPI.RelayController.unfollow",
|
||||||
security: [%{"oAuth" => ["write:follows"]}],
|
security: [%{"oAuth" => ["write:follows"]}],
|
||||||
parameters: admin_api_params(),
|
parameters: admin_api_params(),
|
||||||
requestBody:
|
requestBody: request_body("Parameters", relay_url()),
|
||||||
request_body("Parameters", %Schema{
|
|
||||||
type: :object,
|
|
||||||
properties: %{
|
|
||||||
relay_url: %Schema{type: :string, format: :uri}
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
responses: %{
|
responses: %{
|
||||||
200 =>
|
200 =>
|
||||||
Operation.response("Status", "application/json", %Schema{
|
Operation.response("Status", "application/json", %Schema{
|
||||||
|
@ -83,4 +66,29 @@ def unfollow_operation do
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp relay do
|
||||||
|
%Schema{
|
||||||
|
type: :object,
|
||||||
|
properties: %{
|
||||||
|
actor: %Schema{
|
||||||
|
type: :string,
|
||||||
|
example: "https://example.com/relay"
|
||||||
|
},
|
||||||
|
followed_back: %Schema{
|
||||||
|
type: :boolean,
|
||||||
|
description: "Is relay followed back by this actor?"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp relay_url do
|
||||||
|
%Schema{
|
||||||
|
type: :object,
|
||||||
|
properties: %{
|
||||||
|
relay_url: %Schema{type: :string, format: :uri}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,10 +28,6 @@ def get_user(%Plug.Conn{} = conn) do
|
||||||
%User{} = user <- ldap_user(name, password) do
|
%User{} = user <- ldap_user(name, password) do
|
||||||
{:ok, user}
|
{:ok, user}
|
||||||
else
|
else
|
||||||
{:error, {:ldap_connection_error, _}} ->
|
|
||||||
# When LDAP is unavailable, try default authenticator
|
|
||||||
@base.get_user(conn)
|
|
||||||
|
|
||||||
{:ldap, _} ->
|
{:ldap, _} ->
|
||||||
@base.get_user(conn)
|
@base.get_user(conn)
|
||||||
|
|
||||||
|
@ -92,7 +88,7 @@ defp bind_user(connection, ldap, name, password) do
|
||||||
user
|
user
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
register_user(connection, base, uid, name, password)
|
register_user(connection, base, uid, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
error ->
|
error ->
|
||||||
|
@ -100,35 +96,32 @@ defp bind_user(connection, ldap, name, password) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp register_user(connection, base, uid, name, password) do
|
defp register_user(connection, base, uid, name) do
|
||||||
case :eldap.search(connection, [
|
case :eldap.search(connection, [
|
||||||
{:base, to_charlist(base)},
|
{:base, to_charlist(base)},
|
||||||
{:filter, :eldap.equalityMatch(to_charlist(uid), to_charlist(name))},
|
{:filter, :eldap.equalityMatch(to_charlist(uid), to_charlist(name))},
|
||||||
{:scope, :eldap.wholeSubtree()},
|
{:scope, :eldap.wholeSubtree()},
|
||||||
{:attributes, ['mail', 'email']},
|
|
||||||
{:timeout, @search_timeout}
|
{:timeout, @search_timeout}
|
||||||
]) do
|
]) do
|
||||||
{:ok, {:eldap_search_result, [{:eldap_entry, _, attributes}], _}} ->
|
{:ok, {:eldap_search_result, [{:eldap_entry, _, attributes}], _}} ->
|
||||||
with {_, [mail]} <- List.keyfind(attributes, 'mail', 0) do
|
|
||||||
params = %{
|
params = %{
|
||||||
email: :erlang.list_to_binary(mail),
|
|
||||||
name: name,
|
name: name,
|
||||||
nickname: name,
|
nickname: name,
|
||||||
password: password,
|
password: nil
|
||||||
password_confirmation: password
|
|
||||||
}
|
}
|
||||||
|
|
||||||
changeset = User.register_changeset(%User{}, params)
|
params =
|
||||||
|
case List.keyfind(attributes, 'mail', 0) do
|
||||||
|
{_, [mail]} -> Map.put_new(params, :email, :erlang.list_to_binary(mail))
|
||||||
|
_ -> params
|
||||||
|
end
|
||||||
|
|
||||||
|
changeset = User.register_changeset_ldap(%User{}, params)
|
||||||
|
|
||||||
case User.register(changeset) do
|
case User.register(changeset) do
|
||||||
{:ok, user} -> user
|
{:ok, user} -> user
|
||||||
error -> error
|
error -> error
|
||||||
end
|
end
|
||||||
else
|
|
||||||
_ ->
|
|
||||||
Logger.error("Could not find LDAP attribute mail: #{inspect(attributes)}")
|
|
||||||
{:error, :ldap_registration_missing_attributes}
|
|
||||||
end
|
|
||||||
|
|
||||||
error ->
|
error ->
|
||||||
error
|
error
|
||||||
|
|
|
@ -6,9 +6,7 @@ defmodule Pleroma.Web.CommonAPI do
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
alias Pleroma.ActivityExpiration
|
alias Pleroma.ActivityExpiration
|
||||||
alias Pleroma.Conversation.Participation
|
alias Pleroma.Conversation.Participation
|
||||||
alias Pleroma.FollowingRelationship
|
|
||||||
alias Pleroma.Formatter
|
alias Pleroma.Formatter
|
||||||
alias Pleroma.Notification
|
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.ThreadMute
|
alias Pleroma.ThreadMute
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
@ -122,33 +120,16 @@ def unfollow(follower, unfollowed) do
|
||||||
|
|
||||||
def accept_follow_request(follower, followed) do
|
def accept_follow_request(follower, followed) do
|
||||||
with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
||||||
{:ok, follower} <- User.follow(follower, followed),
|
{:ok, accept_data, _} <- Builder.accept(followed, follow_activity),
|
||||||
{:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "accept"),
|
{:ok, _activity, _} <- Pipeline.common_pipeline(accept_data, local: true) do
|
||||||
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_accept),
|
|
||||||
{:ok, _activity} <-
|
|
||||||
ActivityPub.accept(%{
|
|
||||||
to: [follower.ap_id],
|
|
||||||
actor: followed,
|
|
||||||
object: follow_activity.data["id"],
|
|
||||||
type: "Accept"
|
|
||||||
}) do
|
|
||||||
Notification.update_notification_type(followed, follow_activity)
|
|
||||||
{:ok, follower}
|
{:ok, follower}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def reject_follow_request(follower, followed) do
|
def reject_follow_request(follower, followed) do
|
||||||
with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
||||||
{:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "reject"),
|
{:ok, reject_data, _} <- Builder.reject(followed, follow_activity),
|
||||||
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_reject),
|
{:ok, _activity, _} <- Pipeline.common_pipeline(reject_data, local: true) do
|
||||||
{:ok, _notifications} <- Notification.dismiss(follow_activity),
|
|
||||||
{:ok, _activity} <-
|
|
||||||
ActivityPub.reject(%{
|
|
||||||
to: [follower.ap_id],
|
|
||||||
actor: followed,
|
|
||||||
object: follow_activity.data["id"],
|
|
||||||
type: "Reject"
|
|
||||||
}) do
|
|
||||||
{:ok, follower}
|
{:ok, follower}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -308,18 +289,19 @@ def vote(user, %{data: %{"type" => "Question"}} = object, choices) do
|
||||||
{:ok, options, choices} <- normalize_and_validate_choices(choices, object) do
|
{:ok, options, choices} <- normalize_and_validate_choices(choices, object) do
|
||||||
answer_activities =
|
answer_activities =
|
||||||
Enum.map(choices, fn index ->
|
Enum.map(choices, fn index ->
|
||||||
answer_data = make_answer_data(user, object, Enum.at(options, index)["name"])
|
{:ok, answer_object, _meta} =
|
||||||
|
Builder.answer(user, object, Enum.at(options, index)["name"])
|
||||||
|
|
||||||
{:ok, activity} =
|
{:ok, activity_data, _meta} = Builder.create(user, answer_object, [])
|
||||||
ActivityPub.create(%{
|
|
||||||
to: answer_data["to"],
|
|
||||||
actor: user,
|
|
||||||
context: object.data["context"],
|
|
||||||
object: answer_data,
|
|
||||||
additional: %{"cc" => answer_data["cc"]}
|
|
||||||
})
|
|
||||||
|
|
||||||
activity
|
{:ok, activity, _meta} =
|
||||||
|
activity_data
|
||||||
|
|> Map.put("cc", answer_object["cc"])
|
||||||
|
|> Map.put("context", answer_object["context"])
|
||||||
|
|> Pipeline.common_pipeline(local: true)
|
||||||
|
|
||||||
|
# TODO: Do preload of Pleroma.Object in Pipeline
|
||||||
|
Activity.normalize(activity.data)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
object = Object.get_cached_by_ap_id(object.data["id"])
|
object = Object.get_cached_by_ap_id(object.data["id"])
|
||||||
|
@ -340,8 +322,13 @@ defp validate_existing_votes(%{ap_id: ap_id}, object) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_options_and_max_count(%{data: %{"anyOf" => any_of}}), do: {any_of, Enum.count(any_of)}
|
defp get_options_and_max_count(%{data: %{"anyOf" => any_of}})
|
||||||
defp get_options_and_max_count(%{data: %{"oneOf" => one_of}}), do: {one_of, 1}
|
when is_list(any_of) and any_of != [],
|
||||||
|
do: {any_of, Enum.count(any_of)}
|
||||||
|
|
||||||
|
defp get_options_and_max_count(%{data: %{"oneOf" => one_of}})
|
||||||
|
when is_list(one_of) and one_of != [],
|
||||||
|
do: {one_of, 1}
|
||||||
|
|
||||||
defp normalize_and_validate_choices(choices, object) do
|
defp normalize_and_validate_choices(choices, object) do
|
||||||
choices = Enum.map(choices, fn i -> if is_binary(i), do: String.to_integer(i), else: i end)
|
choices = Enum.map(choices, fn i -> if is_binary(i), do: String.to_integer(i), else: i end)
|
||||||
|
|
|
@ -548,17 +548,6 @@ def conversation_id_to_context(id) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def make_answer_data(%User{ap_id: ap_id}, object, name) do
|
|
||||||
%{
|
|
||||||
"type" => "Answer",
|
|
||||||
"actor" => ap_id,
|
|
||||||
"cc" => [object.data["actor"]],
|
|
||||||
"to" => [],
|
|
||||||
"name" => name,
|
|
||||||
"inReplyTo" => object.data["id"]
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def validate_character_limit("" = _full_payload, [] = _attachments) do
|
def validate_character_limit("" = _full_payload, [] = _attachments) do
|
||||||
{:error, dgettext("errors", "Cannot post an empty status without attachments")}
|
{:error, dgettext("errors", "Cannot post an empty status without attachments")}
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,6 +18,12 @@ def falsy_param?(value),
|
||||||
|
|
||||||
def truthy_param?(value), do: not falsy_param?(value)
|
def truthy_param?(value), do: not falsy_param?(value)
|
||||||
|
|
||||||
|
def json_response(conn, status, _) when status in [204, :no_content] do
|
||||||
|
conn
|
||||||
|
|> put_resp_header("content-type", "application/json")
|
||||||
|
|> send_resp(status, "")
|
||||||
|
end
|
||||||
|
|
||||||
def json_response(conn, status, json) do
|
def json_response(conn, status, json) do
|
||||||
conn
|
conn
|
||||||
|> put_status(status)
|
|> put_status(status)
|
||||||
|
|
|
@ -226,7 +226,7 @@ def update_credentials(%{assigns: %{user: user}, body_params: params} = conn, _p
|
||||||
with changeset <- User.update_changeset(user, user_params),
|
with changeset <- User.update_changeset(user, user_params),
|
||||||
{:ok, unpersisted_user} <- Ecto.Changeset.apply_action(changeset, :update),
|
{:ok, unpersisted_user} <- Ecto.Changeset.apply_action(changeset, :update),
|
||||||
updated_object <-
|
updated_object <-
|
||||||
Pleroma.Web.ActivityPub.UserView.render("user.json", user: user)
|
Pleroma.Web.ActivityPub.UserView.render("user.json", user: unpersisted_user)
|
||||||
|> Map.delete("@context"),
|
|> Map.delete("@context"),
|
||||||
{:ok, update_data, []} <- Builder.update(user, updated_object),
|
{:ok, update_data, []} <- Builder.update(user, updated_object),
|
||||||
{:ok, _update, _} <-
|
{:ok, _update, _} <-
|
||||||
|
|
|
@ -8,6 +8,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineController do
|
||||||
import Pleroma.Web.ControllerHelper,
|
import Pleroma.Web.ControllerHelper,
|
||||||
only: [add_link_headers: 2, add_link_headers: 3]
|
only: [add_link_headers: 2, add_link_headers: 3]
|
||||||
|
|
||||||
|
alias Pleroma.Config
|
||||||
alias Pleroma.Pagination
|
alias Pleroma.Pagination
|
||||||
alias Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug
|
alias Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug
|
||||||
alias Pleroma.Plugs.OAuthScopesPlug
|
alias Pleroma.Plugs.OAuthScopesPlug
|
||||||
|
@ -89,11 +90,11 @@ def direct(%{assigns: %{user: user}} = conn, params) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp restrict_unauthenticated?(true = _local_only) do
|
defp restrict_unauthenticated?(true = _local_only) do
|
||||||
Pleroma.Config.get([:restrict_unauthenticated, :timelines, :local])
|
Config.restrict_unauthenticated_access?(:timelines, :local)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp restrict_unauthenticated?(_) do
|
defp restrict_unauthenticated?(_) do
|
||||||
Pleroma.Config.get([:restrict_unauthenticated, :timelines, :federated])
|
Config.restrict_unauthenticated_access?(:timelines, :federated)
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /api/v1/timelines/public
|
# GET /api/v1/timelines/public
|
||||||
|
|
|
@ -28,10 +28,10 @@ def render("show.json", %{object: object, multiple: multiple, options: options}
|
||||||
|
|
||||||
def render("show.json", %{object: object} = params) do
|
def render("show.json", %{object: object} = params) do
|
||||||
case object.data do
|
case object.data do
|
||||||
%{"anyOf" => options} when is_list(options) ->
|
%{"anyOf" => [_ | _] = options} ->
|
||||||
render(__MODULE__, "show.json", Map.merge(params, %{multiple: true, options: options}))
|
render(__MODULE__, "show.json", Map.merge(params, %{multiple: true, options: options}))
|
||||||
|
|
||||||
%{"oneOf" => options} when is_list(options) ->
|
%{"oneOf" => [_ | _] = options} ->
|
||||||
render(__MODULE__, "show.json", Map.merge(params, %{multiple: false, options: options}))
|
render(__MODULE__, "show.json", Map.merge(params, %{multiple: false, options: options}))
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -40,14 +40,12 @@ def render("show.json", %{object: object} = params) do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp end_time_and_expired(object) do
|
defp end_time_and_expired(object) do
|
||||||
case object.data["closed"] || object.data["endTime"] do
|
if object.data["closed"] do
|
||||||
end_time when is_binary(end_time) ->
|
end_time = NaiveDateTime.from_iso8601!(object.data["closed"])
|
||||||
end_time = NaiveDateTime.from_iso8601!(end_time)
|
|
||||||
expired = NaiveDateTime.compare(end_time, NaiveDateTime.utc_now()) == :lt
|
expired = NaiveDateTime.compare(end_time, NaiveDateTime.utc_now()) == :lt
|
||||||
|
|
||||||
{Utils.to_masto_date(end_time), expired}
|
{Utils.to_masto_date(end_time), expired}
|
||||||
|
else
|
||||||
_ ->
|
|
||||||
{nil, false}
|
{nil, false}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -473,23 +473,10 @@ def get_reply_to(%{data: %{"object" => _object}} = activity, _) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_content(%{data: %{"type" => object_type}} = object)
|
def render_content(%{data: %{"name" => name}} = object) when not is_nil(name) and name != "" do
|
||||||
when object_type in ["Video", "Event", "Audio"] do
|
url = object.data["url"] || object.data["id"]
|
||||||
with name when not is_nil(name) and name != "" <- object.data["name"] do
|
|
||||||
"<p><a href=\"#{object.data["id"]}\">#{name}</a></p>#{object.data["content"]}"
|
|
||||||
else
|
|
||||||
_ -> object.data["content"] || ""
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def render_content(%{data: %{"type" => object_type}} = object)
|
"<p><a href=\"#{url}\">#{name}</a></p>#{object.data["content"]}"
|
||||||
when object_type in ["Article", "Page"] do
|
|
||||||
with summary when not is_nil(summary) and summary != "" <- object.data["name"],
|
|
||||||
url when is_bitstring(url) <- object.data["url"] do
|
|
||||||
"<p><a href=\"#{url}\">#{summary}</a></p>#{object.data["content"]}"
|
|
||||||
else
|
|
||||||
_ -> object.data["content"] || ""
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_content(object), do: object.data["content"] || ""
|
def render_content(object), do: object.data["content"] || ""
|
||||||
|
|
|
@ -9,28 +9,31 @@ defmodule Pleroma.Web.MediaProxy do
|
||||||
alias Pleroma.Web.MediaProxy.Invalidation
|
alias Pleroma.Web.MediaProxy.Invalidation
|
||||||
|
|
||||||
@base64_opts [padding: false]
|
@base64_opts [padding: false]
|
||||||
|
@cache_table :banned_urls_cache
|
||||||
|
|
||||||
|
def cache_table, do: @cache_table
|
||||||
|
|
||||||
@spec in_banned_urls(String.t()) :: boolean()
|
@spec in_banned_urls(String.t()) :: boolean()
|
||||||
def in_banned_urls(url), do: elem(Cachex.exists?(:banned_urls_cache, url(url)), 1)
|
def in_banned_urls(url), do: elem(Cachex.exists?(@cache_table, url(url)), 1)
|
||||||
|
|
||||||
def remove_from_banned_urls(urls) when is_list(urls) do
|
def remove_from_banned_urls(urls) when is_list(urls) do
|
||||||
Cachex.execute!(:banned_urls_cache, fn cache ->
|
Cachex.execute!(@cache_table, fn cache ->
|
||||||
Enum.each(Invalidation.prepare_urls(urls), &Cachex.del(cache, &1))
|
Enum.each(Invalidation.prepare_urls(urls), &Cachex.del(cache, &1))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_from_banned_urls(url) when is_binary(url) do
|
def remove_from_banned_urls(url) when is_binary(url) do
|
||||||
Cachex.del(:banned_urls_cache, url(url))
|
Cachex.del(@cache_table, url(url))
|
||||||
end
|
end
|
||||||
|
|
||||||
def put_in_banned_urls(urls) when is_list(urls) do
|
def put_in_banned_urls(urls) when is_list(urls) do
|
||||||
Cachex.execute!(:banned_urls_cache, fn cache ->
|
Cachex.execute!(@cache_table, fn cache ->
|
||||||
Enum.each(Invalidation.prepare_urls(urls), &Cachex.put(cache, &1, true))
|
Enum.each(Invalidation.prepare_urls(urls), &Cachex.put(cache, &1, true))
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
def put_in_banned_urls(url) when is_binary(url) do
|
def put_in_banned_urls(url) when is_binary(url) do
|
||||||
Cachex.put(:banned_urls_cache, url(url), true)
|
Cachex.put(@cache_table, url(url), true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def url(url) when is_nil(url) or url == "", do: nil
|
def url(url) when is_nil(url) or url == "", do: nil
|
||||||
|
|
|
@ -76,6 +76,13 @@ defp do_authorize(%Plug.Conn{} = conn, params) do
|
||||||
available_scopes = (app && app.scopes) || []
|
available_scopes = (app && app.scopes) || []
|
||||||
scopes = Scopes.fetch_scopes(params, available_scopes)
|
scopes = Scopes.fetch_scopes(params, available_scopes)
|
||||||
|
|
||||||
|
scopes =
|
||||||
|
if scopes == [] do
|
||||||
|
available_scopes
|
||||||
|
else
|
||||||
|
scopes
|
||||||
|
end
|
||||||
|
|
||||||
# Note: `params` might differ from `conn.params`; use `@params` not `@conn.params` in template
|
# Note: `params` might differ from `conn.params`; use `@params` not `@conn.params` in template
|
||||||
render(conn, Authenticator.auth_template(), %{
|
render(conn, Authenticator.auth_template(), %{
|
||||||
response_type: params["response_type"],
|
response_type: params["response_type"],
|
||||||
|
|
|
@ -16,7 +16,7 @@ def generate_terms(params) do
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_public_tag(acc, params) do
|
def build_public_tag(acc, params) do
|
||||||
if Pleroma.Config.get([:restrict_unauthenticated, :timelines, :federated], true) do
|
if Pleroma.Config.restrict_unauthenticated_access?(:timelines, :federated) do
|
||||||
acc
|
acc
|
||||||
else
|
else
|
||||||
Map.put(acc, @public_url, public_timeline(params))
|
Map.put(acc, @public_url, public_timeline(params))
|
||||||
|
|
|
@ -16,8 +16,8 @@ defmodule Pleroma.Workers.Cron.ClearOauthTokenWorker do
|
||||||
def perform(_job) do
|
def perform(_job) do
|
||||||
if Config.get([:oauth2, :clean_expired_tokens], false) do
|
if Config.get([:oauth2, :clean_expired_tokens], false) do
|
||||||
Token.delete_expired_tokens()
|
Token.delete_expired_tokens()
|
||||||
else
|
end
|
||||||
|
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,9 +37,9 @@ def perform(_job) do
|
||||||
)
|
)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|> send_emails
|
|> send_emails
|
||||||
else
|
|
||||||
:ok
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_emails(users) do
|
def send_emails(users) do
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue