forked from AkkomaGang/akkoma
Merge remote-tracking branch 'origin/develop' into notice-routes
This commit is contained in:
commit
db2bf55e9b
4319 changed files with 9654 additions and 13355 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -28,6 +28,7 @@ erl_crash.dump
|
|||
# variables.
|
||||
/config/*.secret.exs
|
||||
/config/generated_config.exs
|
||||
/config/runtime.exs
|
||||
/config/*.env
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ stages:
|
|||
- docker
|
||||
|
||||
before_script:
|
||||
- echo $MIX_ENV
|
||||
- rm -rf _build/*/lib/pleroma
|
||||
- apt-get update && apt-get install -y cmake
|
||||
- mix local.hex --force
|
||||
|
@ -37,11 +38,20 @@ after_script:
|
|||
|
||||
build:
|
||||
stage: build
|
||||
only:
|
||||
changes:
|
||||
- "**/*.ex"
|
||||
- "**/*.exs"
|
||||
- "mix.lock"
|
||||
script:
|
||||
- mix compile --force
|
||||
|
||||
spec-build:
|
||||
stage: test
|
||||
only:
|
||||
changes:
|
||||
- "lib/pleroma/web/api_spec/**/*.ex"
|
||||
- "lib/pleroma/web/api_spec.ex"
|
||||
artifacts:
|
||||
paths:
|
||||
- spec.json
|
||||
|
@ -64,6 +74,11 @@ benchmark:
|
|||
|
||||
unit-testing:
|
||||
stage: test
|
||||
only:
|
||||
changes:
|
||||
- "**/*.ex"
|
||||
- "**/*.exs"
|
||||
- "mix.lock"
|
||||
retry: 2
|
||||
cache: &testing_cache_policy
|
||||
<<: *global_cache_policy
|
||||
|
@ -97,6 +112,11 @@ unit-testing:
|
|||
|
||||
unit-testing-rum:
|
||||
stage: test
|
||||
only:
|
||||
changes:
|
||||
- "**/*.ex"
|
||||
- "**/*.exs"
|
||||
- "mix.lock"
|
||||
retry: 2
|
||||
cache: *testing_cache_policy
|
||||
services:
|
||||
|
@ -114,17 +134,42 @@ unit-testing-rum:
|
|||
- mix test --preload-modules
|
||||
|
||||
lint:
|
||||
image: elixir:1.12
|
||||
stage: test
|
||||
only:
|
||||
changes:
|
||||
- "**/*.ex"
|
||||
- "**/*.exs"
|
||||
- "mix.lock"
|
||||
cache: *testing_cache_policy
|
||||
script:
|
||||
- mix format --check-formatted
|
||||
|
||||
analysis:
|
||||
stage: test
|
||||
only:
|
||||
changes:
|
||||
- "**/*.ex"
|
||||
- "**/*.exs"
|
||||
- "mix.lock"
|
||||
cache: *testing_cache_policy
|
||||
script:
|
||||
- mix credo --strict --only=warnings,todo,fixme,consistency,readability
|
||||
|
||||
cycles:
|
||||
stage: test
|
||||
image: elixir:1.11
|
||||
only:
|
||||
changes:
|
||||
- "**/*.ex"
|
||||
- "**/*.exs"
|
||||
- "mix.lock"
|
||||
cache: {}
|
||||
script:
|
||||
- mix deps.get
|
||||
- mix compile
|
||||
- mix xref graph --format cycles --label compile | awk '{print $0} END{exit ($0 != "No cycles found")}'
|
||||
|
||||
docs-deploy:
|
||||
stage: deploy
|
||||
cache: *testing_cache_policy
|
||||
|
@ -199,7 +244,7 @@ stop_review_app:
|
|||
|
||||
amd64:
|
||||
stage: release
|
||||
image: elixir:1.10.3
|
||||
image: elixir:1.10.4
|
||||
only: &release-only
|
||||
- stable@pleroma/pleroma
|
||||
- develop@pleroma/pleroma
|
||||
|
@ -237,7 +282,7 @@ amd64-musl:
|
|||
stage: release
|
||||
artifacts: *release-artifacts
|
||||
only: *release-only
|
||||
image: elixir:1.10.3-alpine
|
||||
image: elixir:1.10.4-alpine
|
||||
cache: *release-cache
|
||||
variables: *release-variables
|
||||
before_script: &before-release-musl
|
||||
|
@ -253,7 +298,7 @@ arm:
|
|||
only: *release-only
|
||||
tags:
|
||||
- arm32-specified
|
||||
image: arm32v7/elixir:1.10.3
|
||||
image: arm32v7/elixir:1.10.4
|
||||
cache: *release-cache
|
||||
variables: *release-variables
|
||||
before_script: *before-release
|
||||
|
@ -265,7 +310,7 @@ arm-musl:
|
|||
only: *release-only
|
||||
tags:
|
||||
- arm32-specified
|
||||
image: arm32v7/elixir:1.10.3-alpine
|
||||
image: arm32v7/elixir:1.10.4-alpine
|
||||
cache: *release-cache
|
||||
variables: *release-variables
|
||||
before_script: *before-release-musl
|
||||
|
@ -277,7 +322,7 @@ arm64:
|
|||
only: *release-only
|
||||
tags:
|
||||
- arm
|
||||
image: arm64v8/elixir:1.10.3
|
||||
image: arm64v8/elixir:1.10.4
|
||||
cache: *release-cache
|
||||
variables: *release-variables
|
||||
before_script: *before-release
|
||||
|
@ -289,7 +334,7 @@ arm64-musl:
|
|||
only: *release-only
|
||||
tags:
|
||||
- arm
|
||||
image: arm64v8/elixir:1.10.3-alpine
|
||||
image: arm64v8/elixir:1.10.4-alpine
|
||||
cache: *release-cache
|
||||
variables: *release-variables
|
||||
before_script: *before-release-musl
|
||||
|
@ -307,8 +352,8 @@ docker:
|
|||
IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||
IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
|
||||
IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
|
||||
DOCKER_BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64
|
||||
DOCKER_BUILDX_HASH: 71a7d01439aa8c165a25b59c44d3f016fddbd98b
|
||||
DOCKER_BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.6.3/buildx-v0.6.3.linux-amd64
|
||||
DOCKER_BUILDX_HASH: 980e6b9655f971991fbbb5fd6cd19f1672386195
|
||||
before_script: &before-docker
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- docker pull $IMAGE_TAG_SLUG || true
|
||||
|
|
75
CHANGELOG.md
75
CHANGELOG.md
|
@ -6,32 +6,90 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
|
||||
## Unreleased
|
||||
|
||||
### Removed
|
||||
|
||||
- MastoFE
|
||||
|
||||
### Changed
|
||||
- Allow users to remove their emails if instance does not need email to register
|
||||
|
||||
### Added
|
||||
- `activeMonth` and `activeHalfyear` fields in NodeInfo usage.users object
|
||||
|
||||
### Fixed
|
||||
- Subscription(Bell) Notifications: Don't create from Pipeline Ingested replies
|
||||
- Handle Reject for already-accepted Follows properly
|
||||
- Display OpenGraph data on alternative notice routes.
|
||||
|
||||
### Removed
|
||||
|
||||
## 2.4.1 - 2021-08-29
|
||||
|
||||
### Changed
|
||||
- Make `mix pleroma.database set_text_search_config` run concurrently and indefinitely
|
||||
|
||||
### Added
|
||||
- AdminAPI: Missing configuration description for StealEmojiPolicy
|
||||
|
||||
### Fixed
|
||||
- MastodonAPI: Stream out Create activities
|
||||
- MRF ObjectAgePolicy: Fix pattern matching on "published"
|
||||
- TwitterAPI: Make `change_password` and `change_email` require params on body instead of query
|
||||
- Subscription(Bell) Notifications: Don't create from Pipeline Ingested replies
|
||||
- AdminAPI: Fix rendering reports containing a `nil` object
|
||||
- Mastodon API: Activity Search fallbacks on status fetching after a DB Timeout/Error
|
||||
- Mastodon API: Fix crash in Streamer related to reblogging
|
||||
- AdminAPI: List available frontends when `static/frontends` folder is missing
|
||||
- Make activity search properly use language-aware GIN indexes
|
||||
- AdminAPI: Fix suggestions for MRF Policies
|
||||
|
||||
## 2.4.0 - 2021-08-08
|
||||
|
||||
### Changed
|
||||
|
||||
- **Breaking:** Configuration: `:chat, enabled` moved to `:shout, enabled` and `:instance, chat_limit` moved to `:shout, limit`
|
||||
- **Breaking** Entries for simple_policy, transparency_exclusions and quarantined_instances now list both the instance and a reason.
|
||||
- Support for Erlang/OTP 24
|
||||
- The `application` metadata returned with statuses is no longer hardcoded. Apps that want to display these details will now have valid data for new posts after this change.
|
||||
- HTTPSecurityPlug now sends a response header to opt out of Google's FLoC (Federated Learning of Cohorts) targeted advertising.
|
||||
- Email address is now returned if requesting user is the owner of the user account so it can be exposed in client and FE user settings UIs.
|
||||
- Improved Twittercard and OpenGraph meta tag generation including thumbnails and image dimension metadata when available.
|
||||
- AdminAPI: sort users so the newest are at the top.
|
||||
- ActivityPub Client-to-Server(C2S): Limitation on the type of Activity/Object are lifted as they are now passed through ObjectValidators
|
||||
|
||||
### Added
|
||||
|
||||
- MRF (`FollowBotPolicy`): New MRF Policy which makes a designated local Bot account attempt to follow all users in public Notes received by your instance. Users who require approving follower requests or have #nobot in their profile are excluded.
|
||||
- Return OAuth token `id` (primary key) in POST `/oauth/token`.
|
||||
- AdminAPI: return `created_at` date with users.
|
||||
- AdminAPI: add DELETE `/api/v1/pleroma/admin/instances/:instance` to delete all content from a remote instance.
|
||||
- `AnalyzeMetadata` upload filter for extracting image/video attachment dimensions and generating blurhashes for images. Blurhashes for videos are not generated at this time.
|
||||
- Attachment dimensions and blurhashes are federated when available.
|
||||
- Mastodon API: support `poll` notification.
|
||||
- Pinned posts federation
|
||||
- AdminAPI: allow moderators to manage reports, users, invites, and custom emojis
|
||||
|
||||
### Fixed
|
||||
- Don't crash so hard when email settings are invalid.
|
||||
- Display OpenGraph data on alternative notice routes.
|
||||
|
||||
## Unreleased (Patch)
|
||||
|
||||
### Fixed
|
||||
|
||||
- Checking activated Upload Filters for required commands.
|
||||
- Remote users can no longer reappear after being deleted.
|
||||
- Deactivated users may now be deleted.
|
||||
- Deleting an activity with a lot of likes/boosts no longer causes a database timeout.
|
||||
- Mix task `pleroma.database prune_objects`
|
||||
- Fixed rendering of JSON errors on ActivityPub endpoints.
|
||||
- Linkify: Parsing crash with URLs ending in unbalanced closed paren, no path separator, and no query parameters
|
||||
- Try to save exported ConfigDB settings (migrate_from_db) in the system temp directory if default location is not writable.
|
||||
- Uploading custom instance thumbnail via AdminAPI/AdminFE generated invalid URL to the image
|
||||
- Applying ConcurrentLimiter settings via AdminAPI
|
||||
- User login failures if their `notification_settings` were in a NULL state.
|
||||
- Mix task `pleroma.user delete_activities` query transaction timeout is now :infinity
|
||||
- MRF (`SimplePolicy`): Embedded objects are now checked. If any embedded object would be rejected, its parent is rejected. This fixes Announces leaking posts from blocked domains.
|
||||
- Fixed some Markdown issues, including trailing slash in links.
|
||||
|
||||
## [2.3.0] - 2020-03-01
|
||||
### Removed
|
||||
- **Breaking**: Remove deprecated `/api/qvitter/statuses/notifications/read` (replaced by `/api/v1/pleroma/notifications/read`)
|
||||
|
||||
## [2.3.0] - 2021-03-01
|
||||
|
||||
### Security
|
||||
|
||||
|
@ -81,6 +139,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Support pagination of blocks and mutes.
|
||||
- Account backup.
|
||||
- Configuration: Add `:instance, autofollowing_nicknames` setting to provide a way to make accounts automatically follow new users that register on the local Pleroma instance.
|
||||
- `[:activitypub, :blockers_visible]` config to control visibility of blockers.
|
||||
- Ability to view remote timelines, with ex. `/api/v1/timelines/public?instance=lain.com` and streams `public:remote` and `public:remote:media`.
|
||||
- The site title is now injected as a `title` tag like preloads or metadata.
|
||||
- Password reset tokens now are not accepted after a certain age.
|
||||
|
@ -132,7 +191,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Mastodon API: Support for expires_in/expires_at in the Filters.
|
||||
</details>
|
||||
|
||||
## [2.2.2] - 2020-01-18
|
||||
## [2.2.2] - 2021-01-18
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ RUN apk add git gcc g++ musl-dev make cmake file-dev &&\
|
|||
mkdir release &&\
|
||||
mix release --path release
|
||||
|
||||
FROM alpine:3.11
|
||||
FROM alpine:3.14
|
||||
|
||||
ARG BUILD_DATE
|
||||
ARG VCS_REF
|
||||
|
@ -31,9 +31,8 @@ LABEL maintainer="ops@pleroma.social" \
|
|||
ARG HOME=/opt/pleroma
|
||||
ARG DATA=/var/lib/pleroma
|
||||
|
||||
RUN echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories &&\
|
||||
apk update &&\
|
||||
apk add exiftool imagemagick libmagic ncurses postgresql-client &&\
|
||||
RUN apk update &&\
|
||||
apk add exiftool ffmpeg imagemagick libmagic ncurses postgresql-client &&\
|
||||
adduser --system --shell /bin/false --home ${HOME} pleroma &&\
|
||||
mkdir -p ${DATA}/uploads &&\
|
||||
mkdir -p ${DATA}/static &&\
|
||||
|
|
|
@ -30,11 +30,14 @@ If your platform is not supported, or you just want to be able to edit the sourc
|
|||
- [OpenBSD (fi)](https://docs-develop.pleroma.social/backend/installation/openbsd_fi/)
|
||||
|
||||
### OS/Distro packages
|
||||
Currently Pleroma is not packaged by any OS/Distros, but if you want to package it for one, we can guide you through the process on our [community channels](#community-channels). If you want to change default options in your Pleroma package, please **discuss it with us first**.
|
||||
Currently Pleroma is packaged for [YunoHost](https://yunohost.org). If you want to package Pleroma for any OS/Distros, we can guide you through the process on our [community channels](#community-channels). If you want to change default options in your Pleroma package, please **discuss it with us first**.
|
||||
|
||||
### Docker
|
||||
While we don’t provide docker files, other people have written very good ones. Take a look at <https://github.com/angristan/docker-pleroma> or <https://glitch.sh/sn0w/pleroma-docker>.
|
||||
|
||||
### Raspberry Pi
|
||||
Community maintained Raspberry Pi image that you can flash and run Pleroma on your Raspberry Pi. Available here <https://github.com/guysoft/PleromaPi>.
|
||||
|
||||
### Compilation Troubleshooting
|
||||
If you ever encounter compilation issues during the updating of Pleroma, you can try these commands and see if they fix things:
|
||||
|
||||
|
@ -50,5 +53,5 @@ If you are not developing Pleroma, it is better to use the OTP release, which co
|
|||
- Latest Git revision: <https://docs-develop.pleroma.social>
|
||||
|
||||
## Community Channels
|
||||
* IRC: **#pleroma** and **#pleroma-dev** on freenode, webchat is available at <https://irc.pleroma.social>
|
||||
* Matrix: <https://matrix.to/#/#freenode_#pleroma:matrix.org> and <https://matrix.to/#/#freenode_#pleroma-dev:matrix.org>
|
||||
* IRC: **#pleroma** and **#pleroma-dev** on libera.chat, webchat is available at <https://irc.pleroma.social>
|
||||
* Matrix: [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) and [#pleroma-dev:libera.chat](https://matrix.to/#/#pleroma-dev:libera.chat)
|
||||
|
|
|
@ -299,7 +299,7 @@ defp insert_activity(:attachment, visibility, group, users, _opts) do
|
|||
"url" => [
|
||||
%{
|
||||
"href" =>
|
||||
"#{Pleroma.Web.base_url()}/media/b1b873552422a07bf53af01f3c231c841db4dfc42c35efde681abaf0f2a4eab7.jpg",
|
||||
"#{Pleroma.Web.Endpoint.url()}/media/b1b873552422a07bf53af01f3c231c841db4dfc42c35efde681abaf0f2a4eab7.jpg",
|
||||
"mediaType" => "image/jpeg",
|
||||
"type" => "Link"
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ defp get_actor(group, users), do: Enum.random(users[group])
|
|||
|
||||
defp other_data(actor, content) do
|
||||
%{host: host} = URI.parse(actor.ap_id)
|
||||
datetime = DateTime.utc_now()
|
||||
datetime = DateTime.utc_now() |> to_string()
|
||||
context_id = "https://#{host}/contexts/#{UUID.generate()}"
|
||||
activity_id = "https://#{host}/activities/#{UUID.generate()}"
|
||||
object_id = "https://#{host}/objects/#{UUID.generate()}"
|
||||
|
|
|
@ -99,15 +99,16 @@ defp hashtag_fetching(params, user, local_only) do
|
|||
|> Enum.map(&String.downcase(&1))
|
||||
|
||||
_activities =
|
||||
params
|
||||
|> Map.put(:type, "Create")
|
||||
|> Map.put(:local_only, local_only)
|
||||
|> Map.put(:blocking_user, user)
|
||||
|> Map.put(:muting_user, user)
|
||||
|> Map.put(:user, user)
|
||||
|> Map.put(:tag, tags)
|
||||
|> Map.put(:tag_all, tag_all)
|
||||
|> Map.put(:tag_reject, tag_reject)
|
||||
%{
|
||||
type: "Create",
|
||||
local_only: local_only,
|
||||
blocking_user: user,
|
||||
muting_user: user,
|
||||
user: user,
|
||||
tag: tags,
|
||||
tag_all: tag_all,
|
||||
tag_reject: tag_reject,
|
||||
}
|
||||
|> Pleroma.Web.ActivityPub.ActivityPub.fetch_public_activities()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,14 +17,14 @@ def run(_args) do
|
|||
# Let the user make 100 posts
|
||||
|
||||
1..100
|
||||
|> Enum.each(fn i -> CommonAPI.post(user, %{"status" => to_string(i)}) end)
|
||||
|> Enum.each(fn i -> CommonAPI.post(user, %{status: to_string(i)}) end)
|
||||
|
||||
# Let 10 random users post
|
||||
posts =
|
||||
users
|
||||
|> Enum.take_random(10)
|
||||
|> Enum.map(fn {:ok, random_user} ->
|
||||
{:ok, activity} = CommonAPI.post(random_user, %{"status" => "."})
|
||||
{:ok, activity} = CommonAPI.post(random_user, %{status: "."})
|
||||
activity
|
||||
end)
|
||||
|
||||
|
@ -42,7 +42,7 @@ def run(_args) do
|
|||
|> Conn.assign(:user, reading_user)
|
||||
|> Conn.assign(:skip_link_headers, true)
|
||||
|
||||
Pleroma.Web.MastodonAPI.AccountController.statuses(conn, %{"id" => user.id})
|
||||
Pleroma.Web.MastodonAPI.AccountController.statuses(conn, %{id: user.id})
|
||||
end
|
||||
},
|
||||
inputs: %{"user" => user, "no user" => nil},
|
||||
|
@ -50,7 +50,7 @@ def run(_args) do
|
|||
)
|
||||
|
||||
users
|
||||
|> Enum.each(fn {:ok, follower, user} -> Pleroma.User.follow(follower, user) end)
|
||||
|> Enum.each(fn {:ok, follower} -> Pleroma.User.follow(follower, user) end)
|
||||
|
||||
Benchee.run(
|
||||
%{
|
||||
|
@ -60,7 +60,7 @@ def run(_args) do
|
|||
|> Conn.assign(:user, reading_user)
|
||||
|> Conn.assign(:skip_link_headers, true)
|
||||
|
||||
Pleroma.Web.MastodonAPI.AccountController.statuses(conn, %{"id" => user.id})
|
||||
Pleroma.Web.MastodonAPI.AccountController.statuses(conn, %{id: user.id})
|
||||
end
|
||||
},
|
||||
inputs: %{"user" => user, "no user" => nil},
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
use Mix.Config
|
||||
import Config
|
||||
|
||||
# We don't run a server during test. If one is required,
|
||||
# you can enable the server option below.
|
||||
config :pleroma, Pleroma.Web.Endpoint,
|
||||
http: [port: 4001],
|
||||
url: [port: 4001],
|
||||
server: true
|
||||
url: [port: 4001]
|
||||
|
||||
# Disable captha for tests
|
||||
config :pleroma, Pleroma.Captcha,
|
||||
|
@ -44,7 +43,7 @@
|
|||
pool_size: 10
|
||||
|
||||
# Reduce hash rounds for testing
|
||||
config :pbkdf2_elixir, rounds: 1
|
||||
config :pleroma, :password, iterations: 1
|
||||
|
||||
config :tesla, adapter: Tesla.Mock
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#
|
||||
# This configuration file is loaded before any dependency and
|
||||
# is restricted to this project.
|
||||
use Mix.Config
|
||||
import Config
|
||||
|
||||
# General application configuration
|
||||
config :pleroma, ecto_repos: [Pleroma.Repo]
|
||||
|
@ -139,6 +139,7 @@
|
|||
],
|
||||
protocol: "https",
|
||||
secret_key_base: "aK4Abxf29xU9TTDKre9coZPUgevcVCFQJe/5xP/7Lt4BEif6idBIbjupVbOrbKxl",
|
||||
live_view: [signing_salt: "U5ELgdEwTD3n1+D5s0rY0AMg8/y1STxZ3Zvsl3bWh+oBcGrYdil0rXqPMRd3Glcq"],
|
||||
signing_salt: "CqaoopA2",
|
||||
render_errors: [view: Pleroma.Web.ErrorView, accepts: ~w(json)],
|
||||
pubsub_server: Pleroma.PubSub,
|
||||
|
@ -190,7 +191,6 @@
|
|||
instance_thumbnail: "/instance/thumbnail.jpeg",
|
||||
limit: 5_000,
|
||||
description_limit: 5_000,
|
||||
chat_limit: 5_000,
|
||||
remote_limit: 100_000,
|
||||
upload_limit: 16_000_000,
|
||||
avatar_upload_limit: 2_000_000,
|
||||
|
@ -322,9 +322,6 @@
|
|||
subjectLineBehavior: "email",
|
||||
theme: "pleroma-dark",
|
||||
webPushNotifications: false
|
||||
},
|
||||
masto_fe: %{
|
||||
showInstanceSpecificPanel: true
|
||||
}
|
||||
|
||||
config :pleroma, :assets,
|
||||
|
@ -353,6 +350,7 @@
|
|||
config :pleroma, :activitypub,
|
||||
unfollow_blocked: true,
|
||||
outgoing_blocks: true,
|
||||
blockers_visible: true,
|
||||
follow_handshake_timeout: 500,
|
||||
note_replies_output_limit: 5,
|
||||
sign_object_fetches: true,
|
||||
|
@ -457,9 +455,11 @@
|
|||
image_quality: 85,
|
||||
min_content_length: 100 * 1024
|
||||
|
||||
config :pleroma, :chat, enabled: true
|
||||
config :pleroma, :shout,
|
||||
enabled: true,
|
||||
limit: 5_000
|
||||
|
||||
config :phoenix, :format_encoders, json: Jason
|
||||
config :phoenix, :format_encoders, json: Jason, "activity+json": Jason
|
||||
|
||||
config :phoenix, :json_library, Jason
|
||||
|
||||
|
@ -559,6 +559,7 @@
|
|||
mailer: 10,
|
||||
transmogrifier: 20,
|
||||
scheduled_activities: 10,
|
||||
poll_notifications: 10,
|
||||
background: 5,
|
||||
remote_fetcher: 2,
|
||||
attachments_cleanup: 1,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use Mix.Config
|
||||
import Config
|
||||
|
||||
websocket_config = [
|
||||
path: "/websocket",
|
||||
|
@ -544,14 +544,6 @@
|
|||
5_000
|
||||
]
|
||||
},
|
||||
%{
|
||||
key: :chat_limit,
|
||||
type: :integer,
|
||||
description: "Character limit of the instance chat messages",
|
||||
suggestions: [
|
||||
5_000
|
||||
]
|
||||
},
|
||||
%{
|
||||
key: :remote_limit,
|
||||
type: :integer,
|
||||
|
@ -682,7 +674,8 @@
|
|||
%{
|
||||
key: :allow_relay,
|
||||
type: :boolean,
|
||||
description: "Enable Pleroma's Relay, which makes it possible to follow a whole instance"
|
||||
description:
|
||||
"Permits remote instances to subscribe to all public posts of your instance. (Important!) This may increase the visibility of your instance."
|
||||
},
|
||||
%{
|
||||
key: :public,
|
||||
|
@ -694,12 +687,14 @@
|
|||
},
|
||||
%{
|
||||
key: :quarantined_instances,
|
||||
type: {:list, :string},
|
||||
type: {:list, :tuple},
|
||||
key_placeholder: "instance",
|
||||
value_placeholder: "reason",
|
||||
description:
|
||||
"List of ActivityPub instances where private (DMs, followers-only) activities will not be sent",
|
||||
"List of ActivityPub instances where private (DMs, followers-only) activities will not be sent and the reason for doing so",
|
||||
suggestions: [
|
||||
"quarantined.com",
|
||||
"*.quarantined.com"
|
||||
{"quarantined.com", "Reason"},
|
||||
{"*.quarantined.com", "Reason"}
|
||||
]
|
||||
},
|
||||
%{
|
||||
|
@ -1169,7 +1164,7 @@
|
|||
type: :group,
|
||||
description:
|
||||
"This form can be used to configure a keyword list that keeps the configuration data for any " <>
|
||||
"kind of frontend. By default, settings for pleroma_fe and masto_fe are configured. If you want to " <>
|
||||
"kind of frontend. By default, settings for pleroma_fe are configured. If you want to " <>
|
||||
"add your own configuration your settings all fields must be complete.",
|
||||
children: [
|
||||
%{
|
||||
|
@ -1182,7 +1177,6 @@
|
|||
alwaysShowSubjectInput: true,
|
||||
background: "/static/aurora_borealis.jpg",
|
||||
collapseMessageWithSubject: false,
|
||||
disableChat: false,
|
||||
greentext: false,
|
||||
hideFilteredStatuses: false,
|
||||
hideMutedPosts: false,
|
||||
|
@ -1229,12 +1223,6 @@
|
|||
description:
|
||||
"When a message has a subject (aka Content Warning), collapse it by default"
|
||||
},
|
||||
%{
|
||||
key: :disableChat,
|
||||
label: "PleromaFE Chat",
|
||||
type: :boolean,
|
||||
description: "Disables PleromaFE Chat component"
|
||||
},
|
||||
%{
|
||||
key: :greentext,
|
||||
label: "Greentext",
|
||||
|
@ -1376,25 +1364,6 @@
|
|||
suggestions: ["pleroma-dark"]
|
||||
}
|
||||
]
|
||||
},
|
||||
%{
|
||||
key: :masto_fe,
|
||||
label: "Masto FE",
|
||||
type: :map,
|
||||
description: "Settings for Masto FE",
|
||||
suggestions: [
|
||||
%{
|
||||
showInstanceSpecificPanel: true
|
||||
}
|
||||
],
|
||||
children: [
|
||||
%{
|
||||
key: :showInstanceSpecificPanel,
|
||||
label: "Show instance specific panel",
|
||||
type: :boolean,
|
||||
description: "Whenether to show the instance's specific panel"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1701,6 +1670,11 @@
|
|||
type: :boolean,
|
||||
description: "Whether to federate blocks to other instances"
|
||||
},
|
||||
%{
|
||||
key: :blockers_visible,
|
||||
type: :boolean,
|
||||
description: "Whether a user can see someone who has blocked them"
|
||||
},
|
||||
%{
|
||||
key: :sign_object_fetches,
|
||||
type: :boolean,
|
||||
|
@ -2652,13 +2626,22 @@
|
|||
},
|
||||
%{
|
||||
group: :pleroma,
|
||||
key: :chat,
|
||||
key: :shout,
|
||||
type: :group,
|
||||
description: "Pleroma chat settings",
|
||||
description: "Pleroma shout settings",
|
||||
children: [
|
||||
%{
|
||||
key: :enabled,
|
||||
type: :boolean
|
||||
type: :boolean,
|
||||
description: "Enables the backend Shoutbox chat feature."
|
||||
},
|
||||
%{
|
||||
key: :limit,
|
||||
type: :integer,
|
||||
description: "Shout message character limit.",
|
||||
suggestions: [
|
||||
5_000
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use Mix.Config
|
||||
import Config
|
||||
|
||||
# For development, we disable any cache and enable
|
||||
# debugging and code reloading.
|
||||
|
@ -54,10 +54,15 @@
|
|||
|
||||
config :pleroma, Pleroma.Web.ApiSpec.CastAndValidate, strict: true
|
||||
|
||||
# Reduce recompilation time
|
||||
# https://dashbit.co/blog/speeding-up-re-compilation-of-elixir-projects
|
||||
config :phoenix, :plug_init_mode, :runtime
|
||||
|
||||
if File.exists?("./config/dev.secret.exs") do
|
||||
import_config "dev.secret.exs"
|
||||
else
|
||||
IO.puts(
|
||||
:stderr,
|
||||
"!!! RUNNING IN LOCALHOST DEV MODE! !!!\nFEDERATION WON'T WORK UNTIL YOU CONFIGURE A dev.secret.exs"
|
||||
)
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use Mix.Config
|
||||
import Config
|
||||
|
||||
config :pleroma, Pleroma.Web.Endpoint,
|
||||
http: [
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use Mix.Config
|
||||
import Config
|
||||
|
||||
# For production, we often load configuration from external
|
||||
# sources, such as your system environment. For this reason,
|
||||
|
@ -63,7 +63,12 @@
|
|||
|
||||
# Finally import the config/prod.secret.exs
|
||||
# which should be versioned separately.
|
||||
import_config "prod.secret.exs"
|
||||
if File.exists?("./config/prod.secret.exs") do
|
||||
import_config "prod.secret.exs"
|
||||
else
|
||||
"`config/prod.secret.exs` not found. You may want to create one by running `mix pleroma.instance gen`"
|
||||
|> IO.warn([])
|
||||
end
|
||||
|
||||
if File.exists?("./config/prod.exported_from_db.secret.exs"),
|
||||
do: import_config("prod.exported_from_db.secret.exs")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use Mix.Config
|
||||
import Config
|
||||
|
||||
# We don't run a server during test. If one is required,
|
||||
# you can enable the server option below.
|
||||
|
@ -133,6 +133,10 @@
|
|||
ap_streamer: Pleroma.Web.ActivityPub.ActivityPubMock,
|
||||
logger: Pleroma.LoggerMock
|
||||
|
||||
# Reduce recompilation time
|
||||
# https://dashbit.co/blog/speeding-up-re-compilation-of-elixir-projects
|
||||
config :phoenix, :plug_init_mode, :runtime
|
||||
|
||||
if File.exists?("./config/test.secret.exs") do
|
||||
import_config "test.secret.exs"
|
||||
else
|
||||
|
|
|
@ -8,9 +8,10 @@ For from source installations Pleroma configuration works by first importing the
|
|||
|
||||
To add configuration to your config file, you can copy it from the base config. The latest version of it can be viewed [here](https://git.pleroma.social/pleroma/pleroma/blob/develop/config/config.exs). You can also use this file if you don't know how an option is supposed to be formatted.
|
||||
|
||||
## :chat
|
||||
## :shout
|
||||
|
||||
* `enabled` - Enables the backend chat. Defaults to `true`.
|
||||
* `enabled` - Enables the backend Shoutbox chat feature. Defaults to `true`.
|
||||
* `limit` - Shout character limit. Defaults to `5_000`
|
||||
|
||||
## :instance
|
||||
* `name`: The instance’s name.
|
||||
|
@ -19,7 +20,6 @@ To add configuration to your config file, you can copy it from the base config.
|
|||
* `description`: The instance’s description, can be seen in nodeinfo and ``/api/v1/instance``.
|
||||
* `limit`: Posts character limit (CW/Subject included in the counter).
|
||||
* `description_limit`: The character limit for image descriptions.
|
||||
* `chat_limit`: Character limit of the instance chat messages.
|
||||
* `remote_limit`: Hard character limit beyond which remote posts will be dropped.
|
||||
* `upload_limit`: File size limit of uploads (except for avatar, background, banner).
|
||||
* `avatar_upload_limit`: File size limit of user’s profile avatars.
|
||||
|
@ -37,9 +37,9 @@ To add configuration to your config file, you can copy it from the base config.
|
|||
* `federating`: Enable federation with other instances.
|
||||
* `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.
|
||||
* `allow_relay`: Enable Pleroma’s Relay, which makes it possible to follow a whole instance.
|
||||
* `allow_relay`: Permits remote instances to subscribe to all public posts of your instance. This may increase the visibility of your 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. 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`: ActivityPub instances where private (DMs, followers-only) activities will not be send.
|
||||
* `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
|
||||
older software for theses nicknames.
|
||||
|
@ -135,15 +135,16 @@ To add configuration to your config file, you can copy it from the base config.
|
|||
Configuring MRF policies is not enough for them to take effect. You have to enable them by specifying their module in `policies` under [:mrf](#mrf) section.
|
||||
|
||||
#### :mrf_simple
|
||||
* `media_removal`: List of instances to remove media from.
|
||||
* `media_nsfw`: List of instances to put media as NSFW(sensitive) from.
|
||||
* `federated_timeline_removal`: List of instances to remove from Federated (aka The Whole Known Network) Timeline.
|
||||
* `reject`: List of instances to reject any activities from.
|
||||
* `accept`: List of instances to accept any activities from.
|
||||
* `followers_only`: List of instances to decrease post visibility to only the followers, including for DM mentions.
|
||||
* `report_removal`: List of instances to reject reports from.
|
||||
* `avatar_removal`: List of instances to strip avatars from.
|
||||
* `banner_removal`: List of instances to strip banners from.
|
||||
* `media_removal`: List of instances to strip media attachments from and the reason for doing so.
|
||||
* `media_nsfw`: List of instances to tag all media as NSFW (sensitive) from and the reason for doing so.
|
||||
* `federated_timeline_removal`: List of instances to remove from the Federated Timeline (aka The Whole Known Network) and the reason for doing so.
|
||||
* `reject`: List of instances to reject activities (except deletes) from and the reason for doing so.
|
||||
* `accept`: List of instances to only accept activities (except deletes) from and the reason for doing so.
|
||||
* `followers_only`: Force posts from the given instances to be visible by followers only and the reason for doing so.
|
||||
* `report_removal`: List of instances to reject reports from and the reason for doing so.
|
||||
* `avatar_removal`: List of instances to strip avatars from and the reason for doing so.
|
||||
* `banner_removal`: List of instances to strip banners from and the reason for doing so.
|
||||
* `reject_deletes`: List of instances to reject deletions from and the reason for doing so.
|
||||
|
||||
#### :mrf_subchain
|
||||
This policy processes messages through an alternate pipeline when a given message matches certain criteria.
|
||||
|
@ -229,6 +230,7 @@ Notes:
|
|||
### :activitypub
|
||||
* `unfollow_blocked`: Whether blocks result in people getting unfollowed
|
||||
* `outgoing_blocks`: Whether to federate blocks to other instances
|
||||
* `blockers_visible`: Whether a user can see the posts of users who blocked them
|
||||
* `deny_follow_blocked`: Whether to disallow following an account that has blocked the user in question
|
||||
* `sign_object_fetches`: Sign object fetches with HTTP signatures
|
||||
* `authorized_fetch_mode`: Require HTTP signatures for AP fetches
|
||||
|
@ -246,7 +248,7 @@ Notes:
|
|||
|
||||
### :frontend_configurations
|
||||
|
||||
This can be used to configure a keyword list that keeps the configuration data for any kind of frontend. By default, settings for `pleroma_fe` and `masto_fe` are configured. You can find the documentation for `pleroma_fe` configuration into [Pleroma-FE configuration and customization for instance administrators](/frontend/CONFIGURATION/#options).
|
||||
This can be used to configure a keyword list that keeps the configuration data for any kind of frontend. By default, settings for `pleroma_fe` are configured. You can find the documentation for `pleroma_fe` configuration into [Pleroma-FE configuration and customization for instance administrators](/frontend/CONFIGURATION/#options).
|
||||
|
||||
Frontends can access these settings at `/api/v1/pleroma/frontend_configurations`
|
||||
|
||||
|
@ -257,10 +259,7 @@ config :pleroma, :frontend_configurations,
|
|||
pleroma_fe: %{
|
||||
theme: "pleroma-dark",
|
||||
# ... see /priv/static/static/config.json for the available keys.
|
||||
},
|
||||
masto_fe: %{
|
||||
showInstanceSpecificPanel: true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
These settings **need to be complete**, they will override the defaults.
|
||||
|
|
|
@ -5,7 +5,7 @@ Pleroma's full text search feature is powered by PostgreSQL's native [text searc
|
|||
|
||||
## Setup and test the new search config
|
||||
|
||||
In most cases, you would need an extension installed to support parsing CJK text. Here are a few extension you may choose from, or you are more than welcome to share additional ones you found working for you with the rest of Pleroma community.
|
||||
In most cases, you would need an extension installed to support parsing CJK text. Here are a few extensions you may choose from, or you are more than welcome to share additional ones you found working for you with the rest of Pleroma community.
|
||||
|
||||
* [a generic n-gram parser](https://github.com/huangjimmy/pg_cjk_parser) supports Simplifed/Traditional Chinese, Japanese, and Korean
|
||||
* [a Korean parser](https://github.com/i0seph/textsearch_ko) based on mecab
|
||||
|
@ -34,7 +34,7 @@ Check output of the query, and see if it matches your expectation.
|
|||
mix pleroma.database set_text_search_config YOUR.CONFIG
|
||||
```
|
||||
|
||||
Note: index update may take a while.
|
||||
Note: index update may take a while, and it can be done while the instance is up and running, so you may restart db connection as soon as you see `Recreate index` in task output.
|
||||
|
||||
## Restart database connection
|
||||
Since some changes above will only apply with a new database connection, you will have to restart either Pleroma or PostgreSQL process, or use `pg_terminate_backend` SQL command without restarting either.
|
||||
|
|
|
@ -55,18 +55,18 @@ Servers should be configured as lists.
|
|||
|
||||
### Example
|
||||
|
||||
This example will enable `SimplePolicy`, block media from `illegalporn.biz`, mark media as NSFW from `porn.biz` and `porn.business`, reject messages from `spam.com`, remove messages from `spam.university` from the federated timeline and block reports (flags) from `whiny.whiner`:
|
||||
This example will enable `SimplePolicy`, block media from `illegalporn.biz`, mark media as NSFW from `porn.biz` and `porn.business`, reject messages from `spam.com`, remove messages from `spam.university` from the federated timeline and block reports (flags) from `whiny.whiner`. We also give a reason why the moderation was done:
|
||||
|
||||
```elixir
|
||||
config :pleroma, :mrf,
|
||||
policies: [Pleroma.Web.ActivityPub.MRF.SimplePolicy]
|
||||
|
||||
config :pleroma, :mrf_simple,
|
||||
media_removal: ["illegalporn.biz"],
|
||||
media_nsfw: ["porn.biz", "porn.business"],
|
||||
reject: ["spam.com"],
|
||||
federated_timeline_removal: ["spam.university"],
|
||||
report_removal: ["whiny.whiner"]
|
||||
media_removal: [{"illegalporn.biz", "Media can contain illegal contant"}],
|
||||
media_nsfw: [{"porn.biz", "unmarked nsfw media"}, {"porn.business", "A lot of unmarked nsfw media"}],
|
||||
reject: [{"spam.com", "They keep spamming our users"}],
|
||||
federated_timeline_removal: [{"spam.university", "Annoying low-quality posts who otherwise fill up TWKN"}],
|
||||
report_removal: [{"whiny.whiner", "Keep spamming us with irrelevant reports"}]
|
||||
```
|
||||
|
||||
### Use with Care
|
||||
|
@ -82,7 +82,7 @@ For example, here is a sample policy module which rewrites all messages to "new
|
|||
```elixir
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.RewritePolicy do
|
||||
@moduledoc "MRF policy which rewrites all Notes to have 'new message content'."
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|
||||
# Catch messages which contain Note objects with actual data to filter.
|
||||
# Capture the object as `object`, the message content as `content` and the
|
||||
|
|
|
@ -261,6 +261,46 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
|||
}
|
||||
```
|
||||
|
||||
## `PATCH /api/v1/pleroma/admin/users/suggest`
|
||||
|
||||
### Suggest a user
|
||||
|
||||
Adds the user(s) to follower recommendations.
|
||||
|
||||
- Params:
|
||||
- `nicknames`: nicknames array
|
||||
- Response:
|
||||
|
||||
```json
|
||||
{
|
||||
users: [
|
||||
{
|
||||
// user object
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## `PATCH /api/v1/pleroma/admin/users/unsuggest`
|
||||
|
||||
### Unsuggest a user
|
||||
|
||||
Removes the user(s) from follower recommendations.
|
||||
|
||||
- Params:
|
||||
- `nicknames`: nicknames array
|
||||
- Response:
|
||||
|
||||
```json
|
||||
{
|
||||
users: [
|
||||
{
|
||||
// user object
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## `GET /api/v1/pleroma/admin/users/:nickname_or_id`
|
||||
|
||||
### Retrive the details of a user
|
||||
|
@ -319,6 +359,22 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
|||
}
|
||||
```
|
||||
|
||||
## `DELETE /api/v1/pleroma/admin/instances/:instance`
|
||||
|
||||
### Delete all users and activities from a remote instance
|
||||
|
||||
Note: this will trigger a job to remove instance content in the background.
|
||||
It may take some time.
|
||||
|
||||
- Params:
|
||||
- `instance`: remote instance host
|
||||
- Response:
|
||||
- The `instance` name as a string
|
||||
|
||||
```json
|
||||
"lain.com"
|
||||
```
|
||||
|
||||
## `GET /api/v1/pleroma/admin/statuses`
|
||||
|
||||
### Retrives all latest statuses
|
||||
|
|
347
docs/development/API/nodeinfo.md
Normal file
347
docs/development/API/nodeinfo.md
Normal file
|
@ -0,0 +1,347 @@
|
|||
# Nodeinfo
|
||||
|
||||
See also [the Nodeinfo standard](https://nodeinfo.diaspora.software/).
|
||||
|
||||
## `/.well-known/nodeinfo`
|
||||
### The well-known path
|
||||
* Method: `GET`
|
||||
* Authentication: not required
|
||||
* Params: none
|
||||
* Response: JSON
|
||||
* Example response:
|
||||
```json
|
||||
{
|
||||
"links":[
|
||||
{
|
||||
"href":"https://example.com/nodeinfo/2.0.json",
|
||||
"rel":"http://nodeinfo.diaspora.software/ns/schema/2.0"
|
||||
},
|
||||
{
|
||||
"href":"https://example.com/nodeinfo/2.1.json",
|
||||
"rel":"http://nodeinfo.diaspora.software/ns/schema/2.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## `/nodeinfo/2.0.json`
|
||||
### Nodeinfo 2.0
|
||||
* Method: `GET`
|
||||
* Authentication: not required
|
||||
* Params: none
|
||||
* Response: JSON
|
||||
* Example response:
|
||||
```json
|
||||
{
|
||||
"metadata":{
|
||||
"accountActivationRequired":false,
|
||||
"features":[
|
||||
"pleroma_api",
|
||||
"mastodon_api",
|
||||
"mastodon_api_streaming",
|
||||
"polls",
|
||||
"pleroma_explicit_addressing",
|
||||
"shareable_emoji_packs",
|
||||
"multifetch",
|
||||
"pleroma:api/v1/notifications:include_types_filter",
|
||||
"chat",
|
||||
"shout",
|
||||
"relay",
|
||||
"pleroma_emoji_reactions",
|
||||
"pleroma_chat_messages"
|
||||
],
|
||||
"federation":{
|
||||
"enabled":true,
|
||||
"exclusions":false,
|
||||
"mrf_hashtag":{
|
||||
"federated_timeline_removal":[
|
||||
|
||||
],
|
||||
"reject":[
|
||||
|
||||
],
|
||||
"sensitive":[
|
||||
"nsfw"
|
||||
]
|
||||
},
|
||||
"mrf_object_age":{
|
||||
"actions":[
|
||||
"delist",
|
||||
"strip_followers"
|
||||
],
|
||||
"threshold":604800
|
||||
},
|
||||
"mrf_policies":[
|
||||
"ObjectAgePolicy",
|
||||
"TagPolicy",
|
||||
"HashtagPolicy"
|
||||
],
|
||||
"quarantined_instances":[
|
||||
|
||||
]
|
||||
},
|
||||
"fieldsLimits":{
|
||||
"maxFields":10,
|
||||
"maxRemoteFields":20,
|
||||
"nameLength":512,
|
||||
"valueLength":2048
|
||||
},
|
||||
"invitesEnabled":false,
|
||||
"mailerEnabled":false,
|
||||
"nodeDescription":"Pleroma: An efficient and flexible fediverse server",
|
||||
"nodeName":"Example",
|
||||
"pollLimits":{
|
||||
"max_expiration":31536000,
|
||||
"max_option_chars":200,
|
||||
"max_options":20,
|
||||
"min_expiration":0
|
||||
},
|
||||
"postFormats":[
|
||||
"text/plain",
|
||||
"text/html",
|
||||
"text/markdown",
|
||||
"text/bbcode"
|
||||
],
|
||||
"private":false,
|
||||
"restrictedNicknames":[
|
||||
".well-known",
|
||||
"~",
|
||||
"about",
|
||||
"activities",
|
||||
"api",
|
||||
"auth",
|
||||
"check_password",
|
||||
"dev",
|
||||
"friend-requests",
|
||||
"inbox",
|
||||
"internal",
|
||||
"main",
|
||||
"media",
|
||||
"nodeinfo",
|
||||
"notice",
|
||||
"oauth",
|
||||
"objects",
|
||||
"ostatus_subscribe",
|
||||
"pleroma",
|
||||
"proxy",
|
||||
"push",
|
||||
"registration",
|
||||
"relay",
|
||||
"settings",
|
||||
"status",
|
||||
"tag",
|
||||
"user-search",
|
||||
"user_exists",
|
||||
"users",
|
||||
"web",
|
||||
"verify_credentials",
|
||||
"update_credentials",
|
||||
"relationships",
|
||||
"search",
|
||||
"confirmation_resend",
|
||||
"mfa"
|
||||
],
|
||||
"skipThreadContainment":true,
|
||||
"staffAccounts":[
|
||||
"https://example.com/users/admin",
|
||||
"https://example.com/users/staff"
|
||||
],
|
||||
"suggestions":{
|
||||
"enabled":false
|
||||
},
|
||||
"uploadLimits":{
|
||||
"avatar":2000000,
|
||||
"background":4000000,
|
||||
"banner":4000000,
|
||||
"general":16000000
|
||||
}
|
||||
},
|
||||
"openRegistrations":true,
|
||||
"protocols":[
|
||||
"activitypub"
|
||||
],
|
||||
"services":{
|
||||
"inbound":[
|
||||
|
||||
],
|
||||
"outbound":[
|
||||
|
||||
]
|
||||
},
|
||||
"software":{
|
||||
"name":"pleroma",
|
||||
"version":"2.4.1"
|
||||
},
|
||||
"usage":{
|
||||
"localPosts":27,
|
||||
"users":{
|
||||
"activeHalfyear":129,
|
||||
"activeMonth":70,
|
||||
"total":235
|
||||
}
|
||||
},
|
||||
"version":"2.0"
|
||||
}
|
||||
```
|
||||
|
||||
## `/nodeinfo/2.1.json`
|
||||
### Nodeinfo 2.1
|
||||
* Method: `GET`
|
||||
* Authentication: not required
|
||||
* Params: none
|
||||
* Response: JSON
|
||||
* Example response:
|
||||
```json
|
||||
{
|
||||
"metadata":{
|
||||
"accountActivationRequired":false,
|
||||
"features":[
|
||||
"pleroma_api",
|
||||
"mastodon_api",
|
||||
"mastodon_api_streaming",
|
||||
"polls",
|
||||
"pleroma_explicit_addressing",
|
||||
"shareable_emoji_packs",
|
||||
"multifetch",
|
||||
"pleroma:api/v1/notifications:include_types_filter",
|
||||
"chat",
|
||||
"shout",
|
||||
"relay",
|
||||
"pleroma_emoji_reactions",
|
||||
"pleroma_chat_messages"
|
||||
],
|
||||
"federation":{
|
||||
"enabled":true,
|
||||
"exclusions":false,
|
||||
"mrf_hashtag":{
|
||||
"federated_timeline_removal":[
|
||||
|
||||
],
|
||||
"reject":[
|
||||
|
||||
],
|
||||
"sensitive":[
|
||||
"nsfw"
|
||||
]
|
||||
},
|
||||
"mrf_object_age":{
|
||||
"actions":[
|
||||
"delist",
|
||||
"strip_followers"
|
||||
],
|
||||
"threshold":604800
|
||||
},
|
||||
"mrf_policies":[
|
||||
"ObjectAgePolicy",
|
||||
"TagPolicy",
|
||||
"HashtagPolicy"
|
||||
],
|
||||
"quarantined_instances":[
|
||||
|
||||
]
|
||||
},
|
||||
"fieldsLimits":{
|
||||
"maxFields":10,
|
||||
"maxRemoteFields":20,
|
||||
"nameLength":512,
|
||||
"valueLength":2048
|
||||
},
|
||||
"invitesEnabled":false,
|
||||
"mailerEnabled":false,
|
||||
"nodeDescription":"Pleroma: An efficient and flexible fediverse server",
|
||||
"nodeName":"Example",
|
||||
"pollLimits":{
|
||||
"max_expiration":31536000,
|
||||
"max_option_chars":200,
|
||||
"max_options":20,
|
||||
"min_expiration":0
|
||||
},
|
||||
"postFormats":[
|
||||
"text/plain",
|
||||
"text/html",
|
||||
"text/markdown",
|
||||
"text/bbcode"
|
||||
],
|
||||
"private":false,
|
||||
"restrictedNicknames":[
|
||||
".well-known",
|
||||
"~",
|
||||
"about",
|
||||
"activities",
|
||||
"api",
|
||||
"auth",
|
||||
"check_password",
|
||||
"dev",
|
||||
"friend-requests",
|
||||
"inbox",
|
||||
"internal",
|
||||
"main",
|
||||
"media",
|
||||
"nodeinfo",
|
||||
"notice",
|
||||
"oauth",
|
||||
"objects",
|
||||
"ostatus_subscribe",
|
||||
"pleroma",
|
||||
"proxy",
|
||||
"push",
|
||||
"registration",
|
||||
"relay",
|
||||
"settings",
|
||||
"status",
|
||||
"tag",
|
||||
"user-search",
|
||||
"user_exists",
|
||||
"users",
|
||||
"web",
|
||||
"verify_credentials",
|
||||
"update_credentials",
|
||||
"relationships",
|
||||
"search",
|
||||
"confirmation_resend",
|
||||
"mfa"
|
||||
],
|
||||
"skipThreadContainment":true,
|
||||
"staffAccounts":[
|
||||
"https://example.com/users/admin",
|
||||
"https://example.com/users/staff"
|
||||
],
|
||||
"suggestions":{
|
||||
"enabled":false
|
||||
},
|
||||
"uploadLimits":{
|
||||
"avatar":2000000,
|
||||
"background":4000000,
|
||||
"banner":4000000,
|
||||
"general":16000000
|
||||
}
|
||||
},
|
||||
"openRegistrations":true,
|
||||
"protocols":[
|
||||
"activitypub"
|
||||
],
|
||||
"services":{
|
||||
"inbound":[
|
||||
|
||||
],
|
||||
"outbound":[
|
||||
|
||||
]
|
||||
},
|
||||
"software":{
|
||||
"name":"pleroma",
|
||||
"repository":"https://git.pleroma.social/pleroma/pleroma",
|
||||
"version":"2.4.1"
|
||||
},
|
||||
"usage":{
|
||||
"localPosts":27,
|
||||
"users":{
|
||||
"activeHalfyear":129,
|
||||
"activeMonth":70,
|
||||
"total":235
|
||||
}
|
||||
},
|
||||
"version":"2.1"
|
||||
}
|
||||
```
|
||||
|
|
@ -159,10 +159,12 @@ See [Admin-API](admin_api.md)
|
|||
"muting": false,
|
||||
"muting_notifications": false,
|
||||
"subscribing": true,
|
||||
"notifying": true,
|
||||
"requested": false,
|
||||
"domain_blocking": false,
|
||||
"showing_reblogs": true,
|
||||
"endorsed": false
|
||||
"endorsed": false,
|
||||
"note": ""
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -183,10 +185,12 @@ See [Admin-API](admin_api.md)
|
|||
"muting": false,
|
||||
"muting_notifications": false,
|
||||
"subscribing": false,
|
||||
"notifying": false,
|
||||
"requested": false,
|
||||
"domain_blocking": false,
|
||||
"showing_reblogs": true,
|
||||
"endorsed": false
|
||||
"endorsed": false,
|
||||
"note": ""
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -300,7 +304,7 @@ See [Admin-API](admin_api.md)
|
|||
* Note: Behaves exactly the same as `POST /api/v1/upload`.
|
||||
Can only accept images - any attempt to upload non-image files will be met with `HTTP 415 Unsupported Media Type`.
|
||||
|
||||
## `/api/v1/pleroma/notification_settings`
|
||||
## `/api/pleroma/notification_settings`
|
||||
### Updates user notification settings
|
||||
* Method `PUT`
|
||||
* Authentication: required
|
||||
|
|
|
@ -17,10 +17,3 @@ Great! Now you can explore the fediverse! Open the login page for your Pleroma i
|
|||
|
||||
### Pleroma-FE
|
||||
The default front-end used by Pleroma is Pleroma-FE. You can find more information on what it is and how to use it in the [Introduction to Pleroma-FE](../frontend).
|
||||
|
||||
### Mastodon interface
|
||||
If the Pleroma interface isn't your thing, or you're just trying something new but you want to keep using the familiar Mastodon interface, we got that too!
|
||||
Just add a "/web" after your instance url (e.g. <https://pleroma.soykaf.com/web>) and you'll end on the Mastodon web interface, but with a Pleroma backend! MAGIC!
|
||||
The Mastodon interface is from the Glitch-soc fork. For more information on the Mastodon interface you can check the [Mastodon](https://docs.joinmastodon.org/) and [Glitch-soc](https://glitch-soc.github.io/docs/) documentation.
|
||||
|
||||
Remember, what you see is only the frontend part of Mastodon, the backend is still Pleroma.
|
||||
|
|
|
@ -1,29 +1,14 @@
|
|||
# Installing on Alpine Linux
|
||||
|
||||
{! backend/installation/otp_vs_from_source_source.include !}
|
||||
|
||||
## Installation
|
||||
|
||||
This guide is a step-by-step installation guide for Alpine Linux. The instructions were verified against Alpine v3.10 standard image. You might miss additional dependencies if you use `netboot` instead.
|
||||
|
||||
It assumes that you have administrative rights, either as root or a user with [sudo permissions](https://www.linode.com/docs/tools-reference/custom-kernels-distros/install-alpine-linux-on-your-linode/#configuration). If you want to run this guide with root, ignore the `sudo` at the beginning of the lines, unless it calls a user like `sudo -Hu pleroma`; in this case, use `su -l <username> -s $SHELL -c 'command'` instead.
|
||||
|
||||
### Required packages
|
||||
|
||||
* `postgresql`
|
||||
* `elixir`
|
||||
* `erlang`
|
||||
* `erlang-parsetools`
|
||||
* `erlang-xmerl`
|
||||
* `git`
|
||||
* `file-dev`
|
||||
* Development Tools
|
||||
* `cmake`
|
||||
|
||||
#### Optional packages used in this guide
|
||||
|
||||
* `nginx` (preferred, example configs for other reverse proxies can be found in the repo)
|
||||
* `certbot` (or any other ACME client for Let’s Encrypt certificates)
|
||||
* `ImageMagick`
|
||||
* `ffmpeg`
|
||||
* `exiftool`
|
||||
{! backend/installation/generic_dependencies.include !}
|
||||
|
||||
### Prepare the system
|
||||
|
||||
|
@ -117,7 +102,7 @@ cd /opt/pleroma
|
|||
sudo -Hu pleroma mix deps.get
|
||||
```
|
||||
|
||||
* Generate the configuration: `sudo -Hu pleroma mix pleroma.instance gen`
|
||||
* Generate the configuration: `sudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen`
|
||||
* Answer with `yes` if it asks you to install `rebar3`.
|
||||
* This may take some time, because parts of pleroma get compiled first.
|
||||
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
||||
|
@ -240,4 +225,4 @@ sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress
|
|||
|
||||
## 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:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
# Installing on Arch Linux
|
||||
|
||||
{! backend/installation/otp_vs_from_source_source.include !}
|
||||
|
||||
## Installation
|
||||
|
||||
This guide will assume that you have administrative rights, either as root or a user with [sudo permissions](https://wiki.archlinux.org/index.php/Sudo). If you want to run this guide with root, ignore the `sudo` at the beginning of the lines, unless it calls a user like `sudo -Hu pleroma`; in this case, use `su <username> -s $SHELL -c 'command'` instead.
|
||||
|
@ -92,7 +95,7 @@ cd /opt/pleroma
|
|||
sudo -Hu pleroma mix deps.get
|
||||
```
|
||||
|
||||
* Generate the configuration: `sudo -Hu pleroma mix pleroma.instance gen`
|
||||
* Generate the configuration: `sudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen`
|
||||
* Answer with `yes` if it asks you to install `rebar3`.
|
||||
* This may take some time, because parts of pleroma get compiled first.
|
||||
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
||||
|
@ -215,4 +218,4 @@ sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress
|
|||
|
||||
## 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:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||
|
|
|
@ -1,27 +1,12 @@
|
|||
# Installing on Debian Based Distributions
|
||||
|
||||
{! backend/installation/otp_vs_from_source_source.include !}
|
||||
|
||||
## Installation
|
||||
|
||||
This guide will assume you are on Debian Stretch. This guide should also work with Ubuntu 16.04 and 18.04. It also assumes that you have administrative rights, either as root or a user with [sudo permissions](https://www.digitalocean.com/community/tutorials/how-to-add-delete-and-grant-sudo-privileges-to-users-on-a-debian-vps). If you want to run this guide with root, ignore the `sudo` at the beginning of the lines, unless it calls a user like `sudo -Hu pleroma`; in this case, use `su <username> -s $SHELL -c 'command'` instead.
|
||||
This guide will assume you are on Debian 11 (“bullseye”) or later. This guide should also work with Ubuntu 18.04 (“Bionic Beaver”) and later. It also assumes that you have administrative rights, either as root or a user with [sudo permissions](https://www.digitalocean.com/community/tutorials/how-to-add-delete-and-grant-sudo-privileges-to-users-on-a-debian-vps). If you want to run this guide with root, ignore the `sudo` at the beginning of the lines, unless it calls a user like `sudo -Hu pleroma`; in this case, use `su <username> -s $SHELL -c 'command'` instead.
|
||||
|
||||
### Required packages
|
||||
|
||||
* `postgresql` (9.6+, Ubuntu 16.04 comes with 9.5, you can get a newer version from [here](https://www.postgresql.org/download/linux/ubuntu/))
|
||||
* `postgresql-contrib` (9.6+, same situtation as above)
|
||||
* `elixir` (1.8+, Follow the guide to install from the Erlang Solutions repo or use [asdf](https://github.com/asdf-vm/asdf) as the pleroma user)
|
||||
* `erlang-dev`
|
||||
* `erlang-nox`
|
||||
* `libmagic-dev`
|
||||
* `git`
|
||||
* `build-essential`
|
||||
* `cmake`
|
||||
|
||||
#### Optional packages used in this guide
|
||||
|
||||
* `nginx` (preferred, example configs for other reverse proxies can be found in the repo)
|
||||
* `certbot` (or any other ACME client for Let’s Encrypt certificates)
|
||||
* `ImageMagick`
|
||||
* `ffmpeg`
|
||||
* `exiftool`
|
||||
{! backend/installation/generic_dependencies.include !}
|
||||
|
||||
### Prepare the system
|
||||
|
||||
|
@ -40,20 +25,14 @@ sudo apt install git build-essential postgresql postgresql-contrib cmake libmagi
|
|||
|
||||
### Install Elixir and Erlang
|
||||
|
||||
* Download and add the Erlang repository:
|
||||
|
||||
```shell
|
||||
wget -P /tmp/ https://packages.erlang-solutions.com/erlang-solutions_2.0_all.deb
|
||||
sudo dpkg -i /tmp/erlang-solutions_2.0_all.deb
|
||||
```
|
||||
|
||||
* Install Elixir and Erlang:
|
||||
* Install Elixir and Erlang (you might need to use backports or [asdf](https://github.com/asdf-vm/asdf) on old systems):
|
||||
|
||||
```shell
|
||||
sudo apt update
|
||||
sudo apt install elixir erlang-dev erlang-nox
|
||||
```
|
||||
|
||||
|
||||
### Optional packages: [`docs/installation/optional/media_graphics_packages.md`](../installation/optional/media_graphics_packages.md)
|
||||
|
||||
```shell
|
||||
|
@ -90,7 +69,7 @@ cd /opt/pleroma
|
|||
sudo -Hu pleroma mix deps.get
|
||||
```
|
||||
|
||||
* Generate the configuration: `sudo -Hu pleroma mix pleroma.instance gen`
|
||||
* Generate the configuration: `sudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen`
|
||||
* Answer with `yes` if it asks you to install `rebar3`.
|
||||
* This may take some time, because parts of pleroma get compiled first.
|
||||
* After that it will ask you a few questions about your instance and generates a configuration file in `config/generated_config.exs`.
|
||||
|
@ -202,4 +181,4 @@ sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress
|
|||
|
||||
## 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:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||
|
|
|
@ -89,7 +89,7 @@ sudo -Hu pleroma mix deps.get
|
|||
|
||||
* コンフィギュレーションを生成します。
|
||||
```
|
||||
sudo -Hu pleroma mix pleroma.instance gen
|
||||
sudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen
|
||||
```
|
||||
* rebar3をインストールしてもよいか聞かれたら、yesを入力してください。
|
||||
* このときにpleromaの一部がコンパイルされるため、この処理には時間がかかります。
|
||||
|
@ -103,7 +103,7 @@ sudo -Hu pleroma mv config/{generated_config.exs,prod.secret.exs}
|
|||
|
||||
* 先程のコマンドで、すでに `config/setup_db.psql` というファイルが作られています。このファイルをもとに、データベースを作成します。
|
||||
```
|
||||
sudo -Hu pleroma mix pleroma.instance gen
|
||||
sudo -Hu pleroma MIX_ENV=prod mix pleroma.instance gen
|
||||
```
|
||||
|
||||
* そして、データベースのマイグレーションを実行します。
|
||||
|
@ -191,5 +191,5 @@ sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress
|
|||
|
||||
インストールについて質問がある、もしくは、うまくいかないときは、以下のところで質問できます。
|
||||
|
||||
* [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org)
|
||||
* **Freenode** の **#pleroma** IRCチャンネル
|
||||
* [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat)
|
||||
* **libera.chat** の **#pleroma** IRCチャンネル
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
This document was written for FreeBSD 12.1, but should be work on future releases.
|
||||
|
||||
## Required software
|
||||
{! backend/installation/generic_dependencies.include !}
|
||||
|
||||
## Installing software used in this guide
|
||||
|
||||
This assumes the target system has `pkg(8)`.
|
||||
|
||||
|
@ -54,7 +56,7 @@ 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.
|
||||
$ MIX_ENV=prod mix pleroma.instance gen # You will be asked a few questions here.
|
||||
$ cp config/generated_config.exs config/prod.secret.exs
|
||||
```
|
||||
|
||||
|
@ -213,4 +215,4 @@ 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**.
|
||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||
|
|
16
docs/installation/generic_dependencies.include
Normal file
16
docs/installation/generic_dependencies.include
Normal file
|
@ -0,0 +1,16 @@
|
|||
## Required dependencies
|
||||
|
||||
* PostgreSQL 9.6+
|
||||
* Elixir 1.9+
|
||||
* Erlang OTP 22.2+
|
||||
* git
|
||||
* file / libmagic
|
||||
* gcc (clang might also work)
|
||||
* GNU make
|
||||
* CMake
|
||||
|
||||
## Optional dependencies
|
||||
|
||||
* ImageMagick
|
||||
* FFmpeg
|
||||
* exiftool
|
|
@ -1,11 +1,12 @@
|
|||
# Installing on Gentoo GNU/Linux
|
||||
|
||||
{! backend/installation/otp_vs_from_source_source.include !}
|
||||
|
||||
## Installation
|
||||
|
||||
This guide will assume that you have administrative rights, either as root or a user with [sudo permissions](https://wiki.gentoo.org/wiki/Sudo). Lines that begin with `#` indicate that they should be run as the superuser. Lines using `$` should be run as the indicated user, e.g. `pleroma$` should be run as the `pleroma` user.
|
||||
|
||||
### Configuring your hostname (optional)
|
||||
|
||||
If you would like your prompt to permanently include your host/domain, change `/etc/conf.d/hostname` to your hostname. You can reboot or use the `hostname` command to make immediate changes.
|
||||
{! backend/installation/generic_dependencies.include !}
|
||||
|
||||
### Your make.conf, package.use, and USE flags
|
||||
|
||||
|
@ -135,7 +136,7 @@ pleroma$ mix deps.get
|
|||
* Generate the configuration:
|
||||
|
||||
```shell
|
||||
pleroma$ mix pleroma.instance gen
|
||||
pleroma$ MIX_ENV=prod mix pleroma.instance gen
|
||||
```
|
||||
|
||||
* Answer with `yes` if it asks you to install `rebar3`.
|
||||
|
@ -298,4 +299,4 @@ If you opted to allow sudo for the `pleroma` user but would like to remove the a
|
|||
|
||||
## 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:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# Switching a from-source install to OTP releases
|
||||
|
||||
## What are OTP releases?
|
||||
OTP releases are as close as you can get to binary releases with Erlang/Elixir. The release is self-contained, and provides everything needed to boot it, it is easily administered via the provided shell script to open up a remote console, start/stop/restart the release, start in the background, send remote commands, and more.
|
||||
{! backend/installation/otp_vs_from_source.include !}
|
||||
|
||||
In this guide we cover how you can migrate from a from source installation to one using OTP releases.
|
||||
|
||||
## Pre-requisites
|
||||
You will be running commands as root. If you aren't root already, please elevate your priviledges by executing `sudo su`/`su`.
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# Installing on NetBSD
|
||||
|
||||
## Required software
|
||||
{! backend/installation/generic_dependencies.include !}
|
||||
|
||||
## Installing software used in this guide
|
||||
|
||||
pkgin should have been installed by the NetBSD installer if you selected
|
||||
the right options. If it isn't installed, install it using pkg_add.
|
||||
|
@ -71,7 +73,7 @@ Configure Pleroma. Note that you need a domain name at this point:
|
|||
```
|
||||
$ cd /home/pleroma/pleroma
|
||||
$ mix deps.get
|
||||
$ mix pleroma.instance gen # You will be asked a few questions here.
|
||||
$ MIX_ENV=prod mix pleroma.instance gen # You will be asked a few questions here.
|
||||
```
|
||||
|
||||
Since Postgres is configured, we can now initialize the database. There should
|
||||
|
@ -193,8 +195,6 @@ Run `# /etc/rc.d/pleroma start` to start Pleroma.
|
|||
|
||||
Restart nginx with `# /etc/rc.d/nginx restart` and you should be up and running.
|
||||
|
||||
If you need further help, contact niaa on freenode.
|
||||
|
||||
Make sure your time is in sync, or other instances will receive your posts with
|
||||
incorrect timestamps. You should have ntpd running.
|
||||
|
||||
|
@ -208,4 +208,4 @@ 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**.
|
||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||
|
|
|
@ -4,19 +4,11 @@ This guide describes the installation and configuration of pleroma (and the requ
|
|||
|
||||
For any additional information regarding commands and configuration files mentioned here, check the man pages [online](https://man.openbsd.org/) or directly on your server with the man command.
|
||||
|
||||
{! backend/installation/generic_dependencies.include !}
|
||||
|
||||
### Preparing the system
|
||||
#### Required software
|
||||
|
||||
The following packages need to be installed:
|
||||
|
||||
* elixir
|
||||
* gmake
|
||||
* git
|
||||
* postgresql-server
|
||||
* postgresql-contrib
|
||||
* cmake
|
||||
* ffmpeg
|
||||
* ImageMagick
|
||||
|
||||
To install them, run the following command (with doas or as root):
|
||||
|
||||
```
|
||||
|
@ -239,7 +231,7 @@ Enter a shell as \_pleroma (as root `su _pleroma -`) and enter pleroma's install
|
|||
Then follow the main installation guide:
|
||||
|
||||
* run `mix deps.get`
|
||||
* run `mix pleroma.instance gen` and enter your instance's information when asked
|
||||
* run `MIX_ENV=prod mix pleroma.instance gen` and enter your instance's information when asked
|
||||
* copy config/generated\_config.exs to config/prod.secret.exs. The default values should be sufficient but you should edit it and check that everything seems OK.
|
||||
* exit your current shell back to a root one and run `psql -U postgres -f /home/_pleroma/pleroma/config/setup_db.psql` to setup the database.
|
||||
* return to a \_pleroma shell into pleroma's installation directory (`su _pleroma -;cd ~/pleroma`) and run `MIX_ENV=prod mix ecto.migrate`
|
||||
|
@ -264,4 +256,4 @@ LC_ALL=en_US.UTF-8 MIX_ENV=prod mix pleroma.user new <username> <your@emailaddre
|
|||
|
||||
## 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:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
||||
|
|
|
@ -10,8 +10,8 @@ suositeltavaa tehdä komennon `doas` avulla, katso `doas (1)` ja `doas.conf (5)`
|
|||
Tästä eteenpäin oletuksena on, että domain "esimerkki.com" osoittaa
|
||||
serverin IP-osoitteeseen.
|
||||
|
||||
Jos asennuksen kanssa on ongelmia, IRC-kanava #pleroma Freenodessa tai
|
||||
Matrix-kanava #freenode_#pleroma:matrix.org ovat hyviä paikkoja löytää apua
|
||||
Jos asennuksen kanssa on ongelmia, IRC-kanava #pleroma Libera.chat tai
|
||||
Matrix-kanava #pleroma:libera.chat ovat hyviä paikkoja löytää apua
|
||||
(englanniksi), `/msg eal kukkuu` jos haluat välttämättä puhua härmää.
|
||||
|
||||
Asenna tarvittava ohjelmisto:
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Installing on Linux using OTP releases
|
||||
|
||||
{! backend/installation/otp_vs_from_source.include !}
|
||||
|
||||
This guide covers a installation using an OTP release. To install Pleroma from source, please check out the corresponding guide for your distro.
|
||||
|
||||
## Pre-requisites
|
||||
* A machine running Linux with GNU (e.g. Debian, Ubuntu) or musl (e.g. Alpine) libc and `x86_64`, `aarch64` or `armv7l` CPU, you have root access to. If you are not sure if it's compatible see [Detecting flavour section](#detecting-flavour) below
|
||||
* A (sub)domain pointed to the machine
|
||||
|
@ -31,7 +35,7 @@ Other than things bundled in the OTP release Pleroma depends on:
|
|||
|
||||
=== "Alpine"
|
||||
```
|
||||
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
|
||||
awk 'NR==2' /etc/apk/repositories | sed 's/main/community/' | tee -a /etc/apk/repositories
|
||||
apk update
|
||||
apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot file-dev
|
||||
```
|
||||
|
@ -50,7 +54,6 @@ Per [`docs/installation/optional/media_graphics_packages.md`](optional/media_gra
|
|||
|
||||
=== "Alpine"
|
||||
```
|
||||
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
|
||||
apk update
|
||||
apk add imagemagick ffmpeg exiftool
|
||||
```
|
||||
|
@ -232,7 +235,7 @@ At this point if you open your (sub)domain in a browser you should see a 502 err
|
|||
|
||||
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.
|
||||
|
||||
Still doesn't work? Feel free to contact us on [#pleroma on freenode](https://irc.pleroma.social) or via matrix at <https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org>, you can also [file an issue on our Gitlab](https://git.pleroma.social/pleroma/pleroma-support/issues/new)
|
||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC, you can also [file an issue on our Gitlab](https://git.pleroma.social/pleroma/pleroma-support/issues/new).
|
||||
|
||||
## Post installation
|
||||
|
||||
|
@ -301,4 +304,4 @@ This will create an account withe the username of 'joeuser' with the email addre
|
|||
|
||||
## 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:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC, you can also [file an issue on our Gitlab](https://git.pleroma.social/pleroma/pleroma-support/issues/new).
|
||||
|
|
3
docs/installation/otp_vs_from_source.include
Normal file
3
docs/installation/otp_vs_from_source.include
Normal file
|
@ -0,0 +1,3 @@
|
|||
## OTP releases vs from-source installations
|
||||
|
||||
There are two ways to install Pleroma. You can use OTP releases or do a from-source installation. OTP releases are as close as you can get to binary releases with Erlang/Elixir. The release is self-contained, and provides everything needed to boot it, it is easily administered via the provided shell script to open up a remote console, start/stop/restart the release, start in the background, send remote commands, and more. With from source installations you install Pleroma from source, meaning you have to install certain dependencies like Erlang+Elixir and compile Pleroma yourself.
|
3
docs/installation/otp_vs_from_source_source.include
Normal file
3
docs/installation/otp_vs_from_source_source.include
Normal file
|
@ -0,0 +1,3 @@
|
|||
{! backend/installation/otp_vs_from_source.include !}
|
||||
|
||||
This guide covers a from-source installation. To install using OTP releases, please check out [the OTP guide](./otp_en.md).
|
9
docs/installation/yunohost_en.md
Normal file
9
docs/installation/yunohost_en.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Installing on Yunohost
|
||||
|
||||
[YunoHost](https://yunohost.org) is a server operating system aimed at self-hosting. The YunoHost community maintains a package of Pleroma which allows you to install Pleroma on YunoHost. You can install it via the normal way through the admin web interface, or through the CLI. More information can be found at [the repo of the package](https://github.com/YunoHost-Apps/pleroma_ynh).
|
||||
|
||||
## Questions
|
||||
|
||||
Questions and problems related to the YunoHost parts can be done through the [regular YunoHost channels](https://yunohost.org/en/help).
|
||||
|
||||
For questions about Pleroma, ask in [#pleroma:libera.chat](https://matrix.to/#/#pleroma:libera.chat) via Matrix or **#pleroma** on **libera.chat** via IRC.
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
project_id="74"
|
||||
project_branch="rebase/glitch-soc"
|
||||
static_dir="instance/static"
|
||||
# For bundling:
|
||||
# project_branch="pleroma"
|
||||
# static_dir="priv/static"
|
||||
|
||||
if [ ! -d "${static_dir}" ]
|
||||
then
|
||||
echo "Error: ${static_dir} directory is missing, are you sure you are running this script at the root of pleroma’s repository?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
last_modified="$(curl --fail -s -I 'https://git.pleroma.social/api/v4/projects/'${project_id}'/jobs/artifacts/'${project_branch}'/download?job=build' | grep '^Last-Modified:' | cut -d: -f2-)"
|
||||
|
||||
echo "branch:${project_branch}"
|
||||
echo "Last-Modified:${last_modified}"
|
||||
|
||||
artifact="mastofe.zip"
|
||||
|
||||
if [ "${last_modified}x" = "x" ]
|
||||
then
|
||||
echo "ERROR: Couldn't get the modification date of the latest build archive, maybe it expired, exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -e mastofe.timestamp ] && [ "$(cat mastofe.timestamp)" = "${last_modified}" ]
|
||||
then
|
||||
echo "MastoFE is up-to-date, exiting..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
curl --fail -c - "https://git.pleroma.social/api/v4/projects/${project_id}/jobs/artifacts/${project_branch}/download?job=build" -o "${artifact}" || exit
|
||||
|
||||
# TODO: Update the emoji as well
|
||||
rm -fr "${static_dir}/sw.js" "${static_dir}/packs" || exit
|
||||
unzip -q "${artifact}" || exit
|
||||
|
||||
cp public/assets/sw.js "${static_dir}/sw.js" || exit
|
||||
cp -r public/packs "${static_dir}/packs" || exit
|
||||
|
||||
echo "${last_modified}" > mastofe.timestamp
|
||||
rm -fr public
|
||||
rm -i "${artifact}"
|
|
@ -286,9 +286,7 @@ defp migrate_from_db(opts) do
|
|||
file = File.open!(tmp_config_path)
|
||||
|
||||
shell_info(
|
||||
"Saving database configuration settings to #{tmp_config_path}. Copy it to the #{
|
||||
Path.dirname(config_path)
|
||||
} manually."
|
||||
"Saving database configuration settings to #{tmp_config_path}. Copy it to the #{Path.dirname(config_path)} manually."
|
||||
)
|
||||
|
||||
write_config(file, tmp_config_path, opts)
|
||||
|
|
|
@ -96,6 +96,15 @@ def run(["prune_objects" | args]) do
|
|||
)
|
||||
|> Repo.delete_all(timeout: :infinity)
|
||||
|
||||
prune_hashtags_query = """
|
||||
DELETE FROM hashtags AS ht
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM hashtags_objects hto
|
||||
WHERE ht.id = hto.hashtag_id)
|
||||
"""
|
||||
|
||||
Repo.query(prune_hashtags_query)
|
||||
|
||||
if Keyword.get(options, :vacuum) do
|
||||
Maintenance.vacuum("full")
|
||||
end
|
||||
|
@ -200,7 +209,9 @@ def run(["set_text_search_config", tsconfig]) do
|
|||
new.fts_content := to_tsvector(new.data->>'content');
|
||||
RETURN new;
|
||||
END
|
||||
$$ LANGUAGE plpgsql"
|
||||
$$ LANGUAGE plpgsql",
|
||||
[],
|
||||
timeout: :infinity
|
||||
)
|
||||
|
||||
shell_info("Refresh RUM index")
|
||||
|
@ -210,7 +221,9 @@ def run(["set_text_search_config", tsconfig]) do
|
|||
|
||||
Ecto.Adapters.SQL.query!(
|
||||
Pleroma.Repo,
|
||||
"CREATE INDEX objects_fts ON objects USING gin(to_tsvector('#{tsconfig}', data->>'content')); "
|
||||
"CREATE INDEX CONCURRENTLY objects_fts ON objects USING gin(to_tsvector('#{tsconfig}', data->>'content')); ",
|
||||
[],
|
||||
timeout: :infinity
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -199,6 +199,7 @@ def run(["gen" | rest]) do
|
|||
secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||
jwt_secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||
signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)
|
||||
lv_signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)
|
||||
{web_push_public_key, web_push_private_key} = :crypto.generate_key(:ecdh, :prime256v1)
|
||||
template_dir = Application.app_dir(:pleroma, "priv") <> "/templates"
|
||||
|
||||
|
@ -217,6 +218,7 @@ def run(["gen" | rest]) do
|
|||
secret: secret,
|
||||
jwt_secret: jwt_secret,
|
||||
signing_salt: signing_salt,
|
||||
lv_signing_salt: lv_signing_salt,
|
||||
web_push_public_key: Base.url_encode64(web_push_public_key, padding: false),
|
||||
web_push_private_key: Base.url_encode64(web_push_private_key, padding: false),
|
||||
db_configurable?: db_configurable?,
|
||||
|
|
|
@ -51,9 +51,7 @@ def run(["new", nickname, email | rest]) do
|
|||
A user will be created with the following information:
|
||||
- nickname: #{nickname}
|
||||
- email: #{email}
|
||||
- password: #{
|
||||
if(generated_password?, do: "[generated; a reset link will be created]", else: password)
|
||||
}
|
||||
- password: #{if(generated_password?, do: "[generated; a reset link will be created]", else: password)}
|
||||
- name: #{name}
|
||||
- bio: #{bio}
|
||||
- moderator: #{if(moderator?, do: "true", else: "false")}
|
||||
|
@ -114,15 +112,9 @@ def run(["reset_password", nickname]) do
|
|||
{:ok, token} <- Pleroma.PasswordResetToken.create_token(user) do
|
||||
shell_info("Generated password reset token for #{user.nickname}")
|
||||
|
||||
IO.puts(
|
||||
"URL: #{
|
||||
Pleroma.Web.Router.Helpers.reset_password_url(
|
||||
Pleroma.Web.Endpoint,
|
||||
:reset,
|
||||
token.token
|
||||
)
|
||||
}"
|
||||
)
|
||||
IO.puts("URL: #{Pleroma.Web.Router.Helpers.reset_password_url(Pleroma.Web.Endpoint,
|
||||
:reset,
|
||||
token.token)}")
|
||||
else
|
||||
_ ->
|
||||
shell_error("No local user #{nickname}")
|
||||
|
@ -321,9 +313,7 @@ def run(["invites"]) do
|
|||
end
|
||||
|
||||
shell_info(
|
||||
"ID: #{invite.id} | Token: #{invite.token} | Token type: #{invite.invite_type} | Used: #{
|
||||
invite.used
|
||||
}#{expire_info}#{using_info}"
|
||||
"ID: #{invite.id} | Token: #{invite.token} | Token type: #{invite.invite_type} | Used: #{invite.used}#{expire_info}#{using_info}"
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
@ -424,9 +414,7 @@ def run(["list"]) do
|
|||
users
|
||||
|> Enum.each(fn user ->
|
||||
shell_info(
|
||||
"#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
|
||||
user.is_locked
|
||||
}, is_active: #{user.is_active}"
|
||||
"#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{user.is_locked}, is_active: #{user.is_active}"
|
||||
)
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -292,7 +292,8 @@ def get_in_reply_to_activity(%Activity{} = activity) do
|
|||
get_in_reply_to_activity_from_object(Object.normalize(activity, fetch: false))
|
||||
end
|
||||
|
||||
def normalize(obj) when is_map(obj), do: get_by_ap_id_with_object(obj["id"])
|
||||
def normalize(%Activity{data: %{"id" => ap_id}}), do: get_by_ap_id_with_object(ap_id)
|
||||
def normalize(%{"id" => ap_id}), do: get_by_ap_id_with_object(ap_id)
|
||||
def normalize(ap_id) when is_binary(ap_id), do: get_by_ap_id_with_object(ap_id)
|
||||
def normalize(_), do: nil
|
||||
|
||||
|
@ -301,7 +302,7 @@ def delete_all_by_object_ap_id(id) when is_binary(id) do
|
|||
|> Queries.by_object_id()
|
||||
|> Queries.exclude_type("Delete")
|
||||
|> select([u], u)
|
||||
|> Repo.delete_all()
|
||||
|> Repo.delete_all(timeout: :infinity)
|
||||
|> elem(1)
|
||||
|> Enum.find(fn
|
||||
%{data: %{"type" => "Create", "object" => ap_id}} when is_binary(ap_id) -> ap_id == id
|
||||
|
@ -313,13 +314,15 @@ def delete_all_by_object_ap_id(id) when is_binary(id) do
|
|||
|
||||
def delete_all_by_object_ap_id(_), do: nil
|
||||
|
||||
defp purge_web_resp_cache(%Activity{} = activity) do
|
||||
%{path: path} = URI.parse(activity.data["id"])
|
||||
@cachex.del(:web_resp_cache, path)
|
||||
defp purge_web_resp_cache(%Activity{data: %{"id" => id}} = activity) when is_binary(id) do
|
||||
with %{path: path} <- URI.parse(id) do
|
||||
@cachex.del(:web_resp_cache, path)
|
||||
end
|
||||
|
||||
activity
|
||||
end
|
||||
|
||||
defp purge_web_resp_cache(nil), do: nil
|
||||
defp purge_web_resp_cache(activity), do: activity
|
||||
|
||||
def follow_accepted?(
|
||||
%Activity{data: %{"type" => "Follow", "object" => followed_ap_id}} = activity
|
||||
|
@ -359,11 +362,9 @@ def following_requests_for_actor(%User{ap_id: ap_id}) do
|
|||
end
|
||||
|
||||
def restrict_deactivated_users(query) do
|
||||
deactivated_users =
|
||||
from(u in User.Query.build(%{deactivated: true}), select: u.ap_id)
|
||||
|> Repo.all()
|
||||
deactivated_users_query = from(u in User.Query.build(%{deactivated: true}), select: u.ap_id)
|
||||
|
||||
Activity.Queries.exclude_authors(query, deactivated_users)
|
||||
from(activity in query, where: activity.actor not in subquery(deactivated_users_query))
|
||||
end
|
||||
|
||||
defdelegate search(user, query, options \\ []), to: Pleroma.Activity.Search
|
||||
|
|
45
lib/pleroma/activity/html.ex
Normal file
45
lib/pleroma/activity/html.ex
Normal file
|
@ -0,0 +1,45 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Activity.HTML do
|
||||
alias Pleroma.HTML
|
||||
alias Pleroma.Object
|
||||
|
||||
@cachex Pleroma.Config.get([:cachex, :provider], Cachex)
|
||||
|
||||
def get_cached_scrubbed_html_for_activity(
|
||||
content,
|
||||
scrubbers,
|
||||
activity,
|
||||
key \\ "",
|
||||
callback \\ fn x -> x end
|
||||
) do
|
||||
key = "#{key}#{generate_scrubber_signature(scrubbers)}|#{activity.id}"
|
||||
|
||||
@cachex.fetch!(:scrubber_cache, key, fn _key ->
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
HTML.ensure_scrubbed_html(content, scrubbers, object.data["fake"] || false, callback)
|
||||
end)
|
||||
end
|
||||
|
||||
def get_cached_stripped_html_for_activity(content, activity, key) do
|
||||
get_cached_scrubbed_html_for_activity(
|
||||
content,
|
||||
FastSanitize.Sanitizer.StripTags,
|
||||
activity,
|
||||
key,
|
||||
&HtmlEntities.decode/1
|
||||
)
|
||||
end
|
||||
|
||||
defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do
|
||||
generate_scrubber_signature([scrubber])
|
||||
end
|
||||
|
||||
defp generate_scrubber_signature(scrubbers) do
|
||||
Enum.reduce(scrubbers, "", fn scrubber, signature ->
|
||||
"#{signature}#{to_string(scrubber)}"
|
||||
end)
|
||||
end
|
||||
end
|
|
@ -26,19 +26,23 @@ def search(user, search_query, options \\ []) do
|
|||
:plain
|
||||
end
|
||||
|
||||
Activity
|
||||
|> Activity.with_preloaded_object()
|
||||
|> Activity.restrict_deactivated_users()
|
||||
|> restrict_public()
|
||||
|> query_with(index_type, search_query, search_function)
|
||||
|> maybe_restrict_local(user)
|
||||
|> maybe_restrict_author(author)
|
||||
|> maybe_restrict_blocked(user)
|
||||
|> Pagination.fetch_paginated(
|
||||
%{"offset" => offset, "limit" => limit, "skip_order" => index_type == :rum},
|
||||
:offset
|
||||
)
|
||||
|> maybe_fetch(user, search_query)
|
||||
try do
|
||||
Activity
|
||||
|> Activity.with_preloaded_object()
|
||||
|> Activity.restrict_deactivated_users()
|
||||
|> restrict_public()
|
||||
|> query_with(index_type, search_query, search_function)
|
||||
|> maybe_restrict_local(user)
|
||||
|> maybe_restrict_author(author)
|
||||
|> maybe_restrict_blocked(user)
|
||||
|> Pagination.fetch_paginated(
|
||||
%{"offset" => offset, "limit" => limit, "skip_order" => index_type == :rum},
|
||||
:offset
|
||||
)
|
||||
|> maybe_fetch(user, search_query)
|
||||
rescue
|
||||
_ -> maybe_fetch([], user, search_query)
|
||||
end
|
||||
end
|
||||
|
||||
def maybe_restrict_author(query, %User{} = author) do
|
||||
|
@ -61,10 +65,17 @@ defp restrict_public(q) do
|
|||
end
|
||||
|
||||
defp query_with(q, :gin, search_query, :plain) do
|
||||
%{rows: [[tsc]]} =
|
||||
Ecto.Adapters.SQL.query!(
|
||||
Pleroma.Repo,
|
||||
"select current_setting('default_text_search_config')::regconfig::oid;"
|
||||
)
|
||||
|
||||
from([a, o] in q,
|
||||
where:
|
||||
fragment(
|
||||
"to_tsvector(?->>'content') @@ plainto_tsquery(?)",
|
||||
"to_tsvector(?::oid::regconfig, ?->>'content') @@ plainto_tsquery(?)",
|
||||
^tsc,
|
||||
o.data,
|
||||
^search_query
|
||||
)
|
||||
|
@ -72,10 +83,17 @@ defp query_with(q, :gin, search_query, :plain) do
|
|||
end
|
||||
|
||||
defp query_with(q, :gin, search_query, :websearch) do
|
||||
%{rows: [[tsc]]} =
|
||||
Ecto.Adapters.SQL.query!(
|
||||
Pleroma.Repo,
|
||||
"select current_setting('default_text_search_config')::regconfig::oid;"
|
||||
)
|
||||
|
||||
from([a, o] in q,
|
||||
where:
|
||||
fragment(
|
||||
"to_tsvector(?->>'content') @@ websearch_to_tsquery(?)",
|
||||
"to_tsvector(?::oid::regconfig, ?->>'content') @@ websearch_to_tsquery(?)",
|
||||
^tsc,
|
||||
o.data,
|
||||
^search_query
|
||||
)
|
||||
|
|
|
@ -25,7 +25,7 @@ def user_agent do
|
|||
if Process.whereis(Pleroma.Web.Endpoint) do
|
||||
case Config.get([:http, :user_agent], :default) do
|
||||
:default ->
|
||||
info = "#{Pleroma.Web.base_url()} <#{Config.get([:instance, :email], "")}>"
|
||||
info = "#{Pleroma.Web.Endpoint.url()} <#{Config.get([:instance, :email], "")}>"
|
||||
named_version() <> "; " <> info
|
||||
|
||||
custom ->
|
||||
|
@ -102,7 +102,7 @@ def start(_type, _args) do
|
|||
] ++
|
||||
task_children(@mix_env) ++
|
||||
dont_run_in_test(@mix_env) ++
|
||||
chat_child(chat_enabled?()) ++
|
||||
shout_child(shout_enabled?()) ++
|
||||
[Pleroma.Gopher.Server]
|
||||
|
||||
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
|
||||
|
@ -216,7 +216,7 @@ def build_cachex(type, opts),
|
|||
type: :worker
|
||||
}
|
||||
|
||||
defp chat_enabled?, do: Config.get([:chat, :enabled])
|
||||
defp shout_enabled?, do: Config.get([:shout, :enabled])
|
||||
|
||||
defp dont_run_in_test(env) when env in [:test, :benchmark], do: []
|
||||
|
||||
|
@ -237,14 +237,14 @@ defp background_migrators do
|
|||
]
|
||||
end
|
||||
|
||||
defp chat_child(true) do
|
||||
defp shout_child(true) do
|
||||
[
|
||||
Pleroma.Web.ChatChannel.ChatChannelState,
|
||||
Pleroma.Web.ShoutChannel.ShoutChannelState,
|
||||
{Phoenix.PubSub, [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2]}
|
||||
]
|
||||
end
|
||||
|
||||
defp chat_child(_), do: []
|
||||
defp shout_child(_), do: []
|
||||
|
||||
defp task_children(:test) do
|
||||
[
|
||||
|
|
|
@ -164,9 +164,12 @@ defp do_check_rum!(setting, migrate) do
|
|||
|
||||
defp check_system_commands!(:ok) do
|
||||
filter_commands_statuses = [
|
||||
check_filter(Pleroma.Upload.Filters.Exiftool, "exiftool"),
|
||||
check_filter(Pleroma.Upload.Filters.Mogrify, "mogrify"),
|
||||
check_filter(Pleroma.Upload.Filters.Mogrifun, "mogrify")
|
||||
check_filter(Pleroma.Upload.Filter.Exiftool, "exiftool"),
|
||||
check_filter(Pleroma.Upload.Filter.Mogrify, "mogrify"),
|
||||
check_filter(Pleroma.Upload.Filter.Mogrifun, "mogrify"),
|
||||
check_filter(Pleroma.Upload.Filter.AnalyzeMetadata, "mogrify"),
|
||||
check_filter(Pleroma.Upload.Filter.AnalyzeMetadata, "convert"),
|
||||
check_filter(Pleroma.Upload.Filter.AnalyzeMetadata, "ffprobe")
|
||||
]
|
||||
|
||||
preview_proxy_commands_status =
|
||||
|
|
|
@ -19,9 +19,7 @@ def on_shell(username, _pubkey, _ip, _port) do
|
|||
def on_connect(username, ip, port, method) do
|
||||
Logger.debug(fn ->
|
||||
"""
|
||||
Incoming SSH shell #{inspect(self())} requested for #{username} from #{inspect(ip)}:#{
|
||||
inspect(port)
|
||||
} using #{inspect(method)}
|
||||
Incoming SSH shell #{inspect(self())} requested for #{username} from #{inspect(ip)}:#{inspect(port)} using #{inspect(method)}
|
||||
"""
|
||||
end)
|
||||
end
|
||||
|
|
|
@ -20,6 +20,140 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
|||
"\n* `config :pleroma, :instance, mrf_transparency_exclusions` is now `config :pleroma, :mrf, transparency_exclusions`"}
|
||||
]
|
||||
|
||||
def check_simple_policy_tuples do
|
||||
has_strings =
|
||||
Config.get([:mrf_simple])
|
||||
|> Enum.any?(fn {_, v} -> Enum.any?(v, &is_binary/1) end)
|
||||
|
||||
if has_strings do
|
||||
Logger.warn("""
|
||||
!!!DEPRECATION WARNING!!!
|
||||
Your config is using strings in the SimplePolicy configuration instead of tuples. They should work for now, but you are advised to change to the new configuration to prevent possible issues later:
|
||||
|
||||
```
|
||||
config :pleroma, :mrf_simple,
|
||||
media_removal: ["instance.tld"],
|
||||
media_nsfw: ["instance.tld"],
|
||||
federated_timeline_removal: ["instance.tld"],
|
||||
report_removal: ["instance.tld"],
|
||||
reject: ["instance.tld"],
|
||||
followers_only: ["instance.tld"],
|
||||
accept: ["instance.tld"],
|
||||
avatar_removal: ["instance.tld"],
|
||||
banner_removal: ["instance.tld"],
|
||||
reject_deletes: ["instance.tld"]
|
||||
```
|
||||
|
||||
Is now
|
||||
|
||||
|
||||
```
|
||||
config :pleroma, :mrf_simple,
|
||||
media_removal: [{"instance.tld", "Reason for media removal"}],
|
||||
media_nsfw: [{"instance.tld", "Reason for media nsfw"}],
|
||||
federated_timeline_removal: [{"instance.tld", "Reason for federated timeline removal"}],
|
||||
report_removal: [{"instance.tld", "Reason for report removal"}],
|
||||
reject: [{"instance.tld", "Reason for reject"}],
|
||||
followers_only: [{"instance.tld", "Reason for followers only"}],
|
||||
accept: [{"instance.tld", "Reason for accept"}],
|
||||
avatar_removal: [{"instance.tld", "Reason for avatar removal"}],
|
||||
banner_removal: [{"instance.tld", "Reason for banner removal"}],
|
||||
reject_deletes: [{"instance.tld", "Reason for reject deletes"}]
|
||||
```
|
||||
""")
|
||||
|
||||
new_config =
|
||||
Config.get([:mrf_simple])
|
||||
|> Enum.map(fn {k, v} ->
|
||||
{k,
|
||||
Enum.map(v, fn
|
||||
{instance, reason} -> {instance, reason}
|
||||
instance -> {instance, ""}
|
||||
end)}
|
||||
end)
|
||||
|
||||
Config.put([:mrf_simple], new_config)
|
||||
|
||||
:error
|
||||
else
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
def check_quarantined_instances_tuples do
|
||||
has_strings = Config.get([:instance, :quarantined_instances]) |> Enum.any?(&is_binary/1)
|
||||
|
||||
if has_strings do
|
||||
Logger.warn("""
|
||||
!!!DEPRECATION WARNING!!!
|
||||
Your config is using strings in the quarantined_instances configuration instead of tuples. They should work for now, but you are advised to change to the new configuration to prevent possible issues later:
|
||||
|
||||
```
|
||||
config :pleroma, :instance,
|
||||
quarantined_instances: ["instance.tld"]
|
||||
```
|
||||
|
||||
Is now
|
||||
|
||||
|
||||
```
|
||||
config :pleroma, :instance,
|
||||
quarantined_instances: [{"instance.tld", "Reason for quarantine"}]
|
||||
```
|
||||
""")
|
||||
|
||||
new_config =
|
||||
Config.get([:instance, :quarantined_instances])
|
||||
|> Enum.map(fn
|
||||
{instance, reason} -> {instance, reason}
|
||||
instance -> {instance, ""}
|
||||
end)
|
||||
|
||||
Config.put([:instance, :quarantined_instances], new_config)
|
||||
|
||||
:error
|
||||
else
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
def check_transparency_exclusions_tuples do
|
||||
has_strings = Config.get([:mrf, :transparency_exclusions]) |> Enum.any?(&is_binary/1)
|
||||
|
||||
if has_strings do
|
||||
Logger.warn("""
|
||||
!!!DEPRECATION WARNING!!!
|
||||
Your config is using strings in the transparency_exclusions configuration instead of tuples. They should work for now, but you are advised to change to the new configuration to prevent possible issues later:
|
||||
|
||||
```
|
||||
config :pleroma, :mrf,
|
||||
transparency_exclusions: ["instance.tld"]
|
||||
```
|
||||
|
||||
Is now
|
||||
|
||||
|
||||
```
|
||||
config :pleroma, :mrf,
|
||||
transparency_exclusions: [{"instance.tld", "Reason to exlude transparency"}]
|
||||
```
|
||||
""")
|
||||
|
||||
new_config =
|
||||
Config.get([:mrf, :transparency_exclusions])
|
||||
|> Enum.map(fn
|
||||
{instance, reason} -> {instance, reason}
|
||||
instance -> {instance, ""}
|
||||
end)
|
||||
|
||||
Config.put([:mrf, :transparency_exclusions], new_config)
|
||||
|
||||
:error
|
||||
else
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
def check_hellthread_threshold do
|
||||
if Config.get([:mrf_hellthread, :threshold]) do
|
||||
Logger.warn("""
|
||||
|
@ -34,19 +168,24 @@ def check_hellthread_threshold do
|
|||
end
|
||||
|
||||
def warn do
|
||||
with :ok <- check_hellthread_threshold(),
|
||||
:ok <- check_old_mrf_config(),
|
||||
:ok <- check_media_proxy_whitelist_config(),
|
||||
:ok <- check_welcome_message_config(),
|
||||
:ok <- check_gun_pool_options(),
|
||||
:ok <- check_activity_expiration_config(),
|
||||
:ok <- check_remote_ip_plug_name(),
|
||||
:ok <- check_uploders_s3_public_endpoint() do
|
||||
:ok
|
||||
else
|
||||
_ ->
|
||||
:error
|
||||
end
|
||||
[
|
||||
check_hellthread_threshold(),
|
||||
check_old_mrf_config(),
|
||||
check_media_proxy_whitelist_config(),
|
||||
check_welcome_message_config(),
|
||||
check_gun_pool_options(),
|
||||
check_activity_expiration_config(),
|
||||
check_remote_ip_plug_name(),
|
||||
check_uploders_s3_public_endpoint(),
|
||||
check_old_chat_shoutbox(),
|
||||
check_quarantined_instances_tuples(),
|
||||
check_transparency_exclusions_tuples(),
|
||||
check_simple_policy_tuples()
|
||||
]
|
||||
|> Enum.reduce(:ok, fn
|
||||
:ok, :ok -> :ok
|
||||
_, _ -> :error
|
||||
end)
|
||||
end
|
||||
|
||||
def check_welcome_message_config do
|
||||
|
@ -215,4 +354,27 @@ def check_uploders_s3_public_endpoint do
|
|||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
@spec check_old_chat_shoutbox() :: :ok | nil
|
||||
def check_old_chat_shoutbox do
|
||||
instance_config = Pleroma.Config.get([:instance])
|
||||
chat_config = Pleroma.Config.get([:chat]) || []
|
||||
|
||||
use_old_config =
|
||||
Keyword.has_key?(instance_config, :chat_limit) or
|
||||
Keyword.has_key?(chat_config, :enabled)
|
||||
|
||||
if use_old_config do
|
||||
Logger.error("""
|
||||
!!!DEPRECATION WARNING!!!
|
||||
Your config is using the old namespace for the Shoutbox configuration. You need to convert to the new namespace. e.g.,
|
||||
\n* `config :pleroma, :chat, enabled` and `config :pleroma, :instance, chat_limit` are now equal to:
|
||||
\n* `config :pleroma, :shout, enabled` and `config :pleroma, :shout, limit`
|
||||
""")
|
||||
|
||||
:error
|
||||
else
|
||||
:ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Config.Loader do
|
||||
# These modules are only being used as keys here (for equality check),
|
||||
# so it's okay to use `Module.concat/1` to have the compiler ignore them.
|
||||
@reject_keys [
|
||||
Pleroma.Repo,
|
||||
Pleroma.Web.Endpoint,
|
||||
Module.concat(["Pleroma.Repo"]),
|
||||
Module.concat(["Pleroma.Web.Endpoint"]),
|
||||
:env,
|
||||
:configurable_from_database,
|
||||
:database,
|
||||
|
|
|
@ -21,9 +21,7 @@ def warn do
|
|||
"""
|
||||
!!!OBAN CONFIG WARNING!!!
|
||||
You are using old workers in Oban crontab settings, which were removed.
|
||||
Please, remove setting from crontab in your config file (prod.secret.exs): #{
|
||||
inspect(setting)
|
||||
}
|
||||
Please, remove setting from crontab in your config file (prod.secret.exs): #{inspect(setting)}
|
||||
"""
|
||||
|> Logger.warn()
|
||||
|
||||
|
|
|
@ -13,23 +13,25 @@ defmodule Pleroma.Config.TransferTask do
|
|||
|
||||
@type env() :: :test | :benchmark | :dev | :prod
|
||||
|
||||
@reboot_time_keys [
|
||||
{:pleroma, :hackney_pools},
|
||||
{:pleroma, :chat},
|
||||
{:pleroma, Oban},
|
||||
{:pleroma, :rate_limit},
|
||||
{:pleroma, :markup},
|
||||
{:pleroma, :streamer},
|
||||
{:pleroma, :pools},
|
||||
{:pleroma, :connections_pool}
|
||||
]
|
||||
defp reboot_time_keys,
|
||||
do: [
|
||||
{:pleroma, :hackney_pools},
|
||||
{:pleroma, :shout},
|
||||
{:pleroma, Oban},
|
||||
{:pleroma, :rate_limit},
|
||||
{:pleroma, :markup},
|
||||
{:pleroma, :streamer},
|
||||
{:pleroma, :pools},
|
||||
{:pleroma, :connections_pool}
|
||||
]
|
||||
|
||||
@reboot_time_subkeys [
|
||||
{:pleroma, Pleroma.Captcha, [:seconds_valid]},
|
||||
{:pleroma, Pleroma.Upload, [:proxy_remote]},
|
||||
{:pleroma, :instance, [:upload_limit]},
|
||||
{:pleroma, :gopher, [:enabled]}
|
||||
]
|
||||
defp reboot_time_subkeys,
|
||||
do: [
|
||||
{:pleroma, Pleroma.Captcha, [:seconds_valid]},
|
||||
{:pleroma, Pleroma.Upload, [:proxy_remote]},
|
||||
{:pleroma, :instance, [:upload_limit]},
|
||||
{:pleroma, :gopher, [:enabled]}
|
||||
]
|
||||
|
||||
def start_link(restart_pleroma? \\ true) do
|
||||
load_and_update_env([], restart_pleroma?)
|
||||
|
@ -146,9 +148,7 @@ defp update({group, key, value, merged}) do
|
|||
rescue
|
||||
error ->
|
||||
error_msg =
|
||||
"updating env causes error, group: #{inspect(group)}, key: #{inspect(key)}, value: #{
|
||||
inspect(value)
|
||||
} error: #{inspect(error)}"
|
||||
"updating env causes error, group: #{inspect(group)}, key: #{inspect(key)}, value: #{inspect(value)} error: #{inspect(error)}"
|
||||
|
||||
Logger.warn(error_msg)
|
||||
|
||||
|
@ -165,12 +165,12 @@ def pleroma_need_restart?(group, key, value) do
|
|||
end
|
||||
|
||||
defp group_and_key_need_reboot?(group, key) do
|
||||
Enum.any?(@reboot_time_keys, fn {g, k} -> g == group and k == key end)
|
||||
Enum.any?(reboot_time_keys(), fn {g, k} -> g == group and k == key end)
|
||||
end
|
||||
|
||||
defp group_and_subkey_need_reboot?(group, key, value) do
|
||||
Keyword.keyword?(value) and
|
||||
Enum.any?(@reboot_time_subkeys, fn {g, k, subkeys} ->
|
||||
Enum.any?(reboot_time_subkeys(), fn {g, k, subkeys} ->
|
||||
g == group and k == key and
|
||||
Enum.any?(Keyword.keys(value), &(&1 in subkeys))
|
||||
end)
|
||||
|
|
|
@ -27,6 +27,4 @@ defmodule Pleroma.Constants do
|
|||
do:
|
||||
~w(index.html robots.txt static static-fe finmoji emoji packs sounds images instance sw.js sw-pleroma.js favicon.png schemas doc embed.js embed.css)
|
||||
)
|
||||
|
||||
def as_local_public, do: Pleroma.Web.base_url() <> "/#Public"
|
||||
end
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
mute: 2,
|
||||
reblog_mute: 3,
|
||||
notification_mute: 4,
|
||||
inverse_subscription: 5
|
||||
inverse_subscription: 5,
|
||||
suggestion_dismiss: 6
|
||||
)
|
||||
|
||||
defenum(Pleroma.FollowingRelationship.State,
|
||||
|
|
|
@ -13,21 +13,33 @@ def cast(object) when is_binary(object) do
|
|||
cast([object])
|
||||
end
|
||||
|
||||
def cast(data) when is_list(data) do
|
||||
data
|
||||
|> Enum.reduce_while({:ok, []}, fn element, {:ok, list} ->
|
||||
case ObjectID.cast(element) do
|
||||
{:ok, id} ->
|
||||
{:cont, {:ok, [id | list]}}
|
||||
|
||||
_ ->
|
||||
{:halt, :error}
|
||||
end
|
||||
end)
|
||||
def cast(object) when is_map(object) do
|
||||
case ObjectID.cast(object) do
|
||||
{:ok, data} -> {:ok, [data]}
|
||||
_ -> :error
|
||||
end
|
||||
end
|
||||
|
||||
def cast(_) do
|
||||
:error
|
||||
def cast(data) when is_list(data) do
|
||||
data =
|
||||
data
|
||||
|> Enum.reduce_while([], fn element, list ->
|
||||
case ObjectID.cast(element) do
|
||||
{:ok, id} ->
|
||||
{:cont, [id | list]}
|
||||
|
||||
_ ->
|
||||
{:cont, list}
|
||||
end
|
||||
end)
|
||||
|> Enum.sort()
|
||||
|> Enum.uniq()
|
||||
|
||||
{:ok, data}
|
||||
end
|
||||
|
||||
def cast(data) do
|
||||
{:error, data}
|
||||
end
|
||||
|
||||
def dump(data) do
|
||||
|
|
|
@ -73,7 +73,7 @@ def report(to, reporter, account, statuses, comment) do
|
|||
#{comment_html}
|
||||
#{statuses_html}
|
||||
<p>
|
||||
<a href="#{Pleroma.Web.base_url()}/pleroma/admin/#/reports/index">View Reports in AdminFE</a>
|
||||
<a href="#{Pleroma.Web.Endpoint.url()}/pleroma/admin/#/reports/index">View Reports in AdminFE</a>
|
||||
"""
|
||||
|
||||
new()
|
||||
|
@ -87,7 +87,7 @@ def new_unapproved_registration(to, account) do
|
|||
html_body = """
|
||||
<p>New account for review: <a href="#{account.ap_id}">@#{account.nickname}</a></p>
|
||||
<blockquote>#{HTML.strip_tags(account.registration_reason)}</blockquote>
|
||||
<a href="#{Pleroma.Web.base_url()}/pleroma/admin/#/users/#{account.id}/">Visit AdminFE</a>
|
||||
<a href="#{Pleroma.Web.Endpoint.url()}/pleroma/admin/#/users/#{account.id}/">Visit AdminFE</a>
|
||||
"""
|
||||
|
||||
new()
|
||||
|
|
|
@ -5,15 +5,22 @@
|
|||
defmodule Pleroma.Emails.UserEmail do
|
||||
@moduledoc "User emails"
|
||||
|
||||
use Phoenix.Swoosh, view: Pleroma.Web.EmailView, layout: {Pleroma.Web.LayoutView, :email}
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.Endpoint
|
||||
alias Pleroma.Web.Router
|
||||
|
||||
import Swoosh.Email
|
||||
import Phoenix.Swoosh, except: [render_body: 3]
|
||||
import Pleroma.Config.Helpers, only: [instance_name: 0, sender: 0]
|
||||
|
||||
def render_body(email, template, assigns \\ %{}) do
|
||||
email
|
||||
|> put_new_layout({Pleroma.Web.LayoutView, :email})
|
||||
|> put_new_view(Pleroma.Web.EmailView)
|
||||
|> Phoenix.Swoosh.render_body(template, assigns)
|
||||
end
|
||||
|
||||
defp recipient(email, nil), do: email
|
||||
defp recipient(email, name), do: {name, email}
|
||||
defp recipient(%User{} = user), do: recipient(user.email, user.name)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
defmodule Pleroma.Emoji.Formatter do
|
||||
alias Pleroma.Emoji
|
||||
alias Pleroma.HTML
|
||||
alias Pleroma.Web
|
||||
alias Pleroma.Web.Endpoint
|
||||
alias Pleroma.Web.MediaProxy
|
||||
|
||||
def emojify(text) do
|
||||
|
@ -44,7 +44,7 @@ def get_emoji_map(text) when is_binary(text) do
|
|||
Emoji.get_all()
|
||||
|> Enum.filter(fn {emoji, %Emoji{}} -> String.contains?(text, ":#{emoji}:") end)
|
||||
|> Enum.reduce(%{}, fn {name, %Emoji{file: file}}, acc ->
|
||||
Map.put(acc, name, to_string(URI.merge(Web.base_url(), file)))
|
||||
Map.put(acc, name, to_string(URI.merge(Endpoint.url(), file)))
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
|
@ -60,9 +60,7 @@ def load do
|
|||
|
||||
if not Enum.empty?(files) do
|
||||
Logger.warn(
|
||||
"Found files in the emoji folder. These will be ignored, please move them to a subdirectory\nFound files: #{
|
||||
Enum.join(files, ", ")
|
||||
}"
|
||||
"Found files in the emoji folder. These will be ignored, please move them to a subdirectory\nFound files: #{Enum.join(files, ", ")}"
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -105,6 +103,7 @@ defp load_pack(pack_dir, emoji_groups) do
|
|||
pack_file = Path.join(pack_dir, "pack.json")
|
||||
|
||||
if File.exists?(pack_file) do
|
||||
Logger.info("Loading emoji pack from JSON: #{pack_file}")
|
||||
contents = Jason.decode!(File.read!(pack_file))
|
||||
|
||||
contents["files"]
|
||||
|
@ -117,14 +116,13 @@ defp load_pack(pack_dir, emoji_groups) do
|
|||
emoji_txt = Path.join(pack_dir, "emoji.txt")
|
||||
|
||||
if File.exists?(emoji_txt) do
|
||||
Logger.info("Loading emoji pack from emoji.txt: #{emoji_txt}")
|
||||
load_from_file(emoji_txt, emoji_groups)
|
||||
else
|
||||
extensions = Config.get([:emoji, :pack_extensions])
|
||||
|
||||
Logger.info(
|
||||
"No emoji.txt found for pack \"#{pack_name}\", assuming all #{
|
||||
Enum.join(extensions, ", ")
|
||||
} files are emoji"
|
||||
"No emoji.txt found for pack \"#{pack_name}\", assuming all #{Enum.join(extensions, ", ")} files are emoji"
|
||||
)
|
||||
|
||||
make_shortcode_to_file_map(pack_dir, extensions)
|
||||
|
|
|
@ -62,7 +62,7 @@ def mention_handler("@" <> nickname, buffer, opts, acc) do
|
|||
|
||||
def hashtag_handler("#" <> tag = tag_text, _buffer, _opts, acc) do
|
||||
tag = String.downcase(tag)
|
||||
url = "#{Pleroma.Web.base_url()}/tag/#{tag}"
|
||||
url = "#{Pleroma.Web.Endpoint.url()}/tag/#{tag}"
|
||||
|
||||
link =
|
||||
Phoenix.HTML.Tag.content_tag(:a, tag_text,
|
||||
|
|
|
@ -11,9 +11,7 @@ defmodule Pleroma.Gun do
|
|||
@callback await(pid(), reference()) :: {:response, :fin, 200, []}
|
||||
@callback set_owner(pid(), pid()) :: :ok
|
||||
|
||||
@api Pleroma.Config.get([Pleroma.Gun], Pleroma.Gun.API)
|
||||
|
||||
defp api, do: @api
|
||||
defp api, do: Pleroma.Config.get([Pleroma.Gun], Pleroma.Gun.API)
|
||||
|
||||
def open(host, port, opts), do: api().open(host, port, opts)
|
||||
|
||||
|
|
|
@ -57,9 +57,7 @@ defp do_open(uri, %{proxy: {proxy_host, proxy_port}} = opts) do
|
|||
else
|
||||
error ->
|
||||
Logger.warn(
|
||||
"Opening proxied connection to #{compose_uri_log(uri)} failed with error #{
|
||||
inspect(error)
|
||||
}"
|
||||
"Opening proxied connection to #{compose_uri_log(uri)} failed with error #{inspect(error)}"
|
||||
)
|
||||
|
||||
error
|
||||
|
@ -93,9 +91,7 @@ defp do_open(uri, %{proxy: {proxy_type, proxy_host, proxy_port}} = opts) do
|
|||
else
|
||||
error ->
|
||||
Logger.warn(
|
||||
"Opening socks proxied connection to #{compose_uri_log(uri)} failed with error #{
|
||||
inspect(error)
|
||||
}"
|
||||
"Opening socks proxied connection to #{compose_uri_log(uri)} failed with error #{inspect(error)}"
|
||||
)
|
||||
|
||||
error
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
defmodule Pleroma.Gun.ConnectionPool.Reclaimer do
|
||||
use GenServer, restart: :temporary
|
||||
|
||||
@registry Pleroma.Gun.ConnectionPool
|
||||
defp registry, do: Pleroma.Gun.ConnectionPool
|
||||
|
||||
def start_monitor do
|
||||
pid =
|
||||
case :gen_server.start(__MODULE__, [], name: {:via, Registry, {@registry, "reclaimer"}}) do
|
||||
case :gen_server.start(__MODULE__, [], name: {:via, Registry, {registry(), "reclaimer"}}) do
|
||||
{:ok, pid} ->
|
||||
pid
|
||||
|
||||
|
@ -46,7 +46,7 @@ def handle_continue(:reclaim, _) do
|
|||
# {worker_pid, crf, last_reference} end)
|
||||
unused_conns =
|
||||
Registry.select(
|
||||
@registry,
|
||||
registry(),
|
||||
[
|
||||
{{:_, :"$1", {:_, :"$2", :"$3", :"$4"}}, [{:==, :"$2", []}], [{{:"$1", :"$3", :"$4"}}]}
|
||||
]
|
||||
|
|
|
@ -6,10 +6,10 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
|
|||
alias Pleroma.Gun
|
||||
use GenServer, restart: :temporary
|
||||
|
||||
@registry Pleroma.Gun.ConnectionPool
|
||||
defp registry, do: Pleroma.Gun.ConnectionPool
|
||||
|
||||
def start_link([key | _] = opts) do
|
||||
GenServer.start_link(__MODULE__, opts, name: {:via, Registry, {@registry, key}})
|
||||
GenServer.start_link(__MODULE__, opts, name: {:via, Registry, {registry(), key}})
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
@ -24,7 +24,7 @@ def handle_continue({:connect, [key, uri, opts, client_pid]}, _) do
|
|||
time = :erlang.monotonic_time(:millisecond)
|
||||
|
||||
{_, _} =
|
||||
Registry.update_value(@registry, key, fn _ ->
|
||||
Registry.update_value(registry(), key, fn _ ->
|
||||
{conn_pid, [client_pid], 1, time}
|
||||
end)
|
||||
|
||||
|
@ -65,7 +65,7 @@ def handle_call(:add_client, {client_pid, _}, %{key: key, protocol: protocol} =
|
|||
time = :erlang.monotonic_time(:millisecond)
|
||||
|
||||
{{conn_pid, used_by, _, _}, _} =
|
||||
Registry.update_value(@registry, key, fn {conn_pid, used_by, crf, last_reference} ->
|
||||
Registry.update_value(registry(), key, fn {conn_pid, used_by, crf, last_reference} ->
|
||||
{conn_pid, [client_pid | used_by], crf(time - last_reference, crf), time}
|
||||
end)
|
||||
|
||||
|
@ -92,7 +92,7 @@ def handle_call(:add_client, {client_pid, _}, %{key: key, protocol: protocol} =
|
|||
@impl true
|
||||
def handle_call(:remove_client, {client_pid, _}, %{key: key} = state) do
|
||||
{{_conn_pid, used_by, _crf, _last_reference}, _} =
|
||||
Registry.update_value(@registry, key, fn {conn_pid, used_by, crf, last_reference} ->
|
||||
Registry.update_value(registry(), key, fn {conn_pid, used_by, crf, last_reference} ->
|
||||
{conn_pid, List.delete(used_by, client_pid), crf, last_reference}
|
||||
end)
|
||||
|
||||
|
|
|
@ -49,31 +49,6 @@ def filter_tags(html, scrubber) do
|
|||
def filter_tags(html), do: filter_tags(html, nil)
|
||||
def strip_tags(html), do: filter_tags(html, FastSanitize.Sanitizer.StripTags)
|
||||
|
||||
def get_cached_scrubbed_html_for_activity(
|
||||
content,
|
||||
scrubbers,
|
||||
activity,
|
||||
key \\ "",
|
||||
callback \\ fn x -> x end
|
||||
) do
|
||||
key = "#{key}#{generate_scrubber_signature(scrubbers)}|#{activity.id}"
|
||||
|
||||
@cachex.fetch!(:scrubber_cache, key, fn _key ->
|
||||
object = Pleroma.Object.normalize(activity, fetch: false)
|
||||
ensure_scrubbed_html(content, scrubbers, object.data["fake"] || false, callback)
|
||||
end)
|
||||
end
|
||||
|
||||
def get_cached_stripped_html_for_activity(content, activity, key) do
|
||||
get_cached_scrubbed_html_for_activity(
|
||||
content,
|
||||
FastSanitize.Sanitizer.StripTags,
|
||||
activity,
|
||||
key,
|
||||
&HtmlEntities.decode/1
|
||||
)
|
||||
end
|
||||
|
||||
def ensure_scrubbed_html(
|
||||
content,
|
||||
scrubbers,
|
||||
|
@ -92,16 +67,6 @@ def ensure_scrubbed_html(
|
|||
end
|
||||
end
|
||||
|
||||
defp generate_scrubber_signature(scrubber) when is_atom(scrubber) do
|
||||
generate_scrubber_signature([scrubber])
|
||||
end
|
||||
|
||||
defp generate_scrubber_signature(scrubbers) do
|
||||
Enum.reduce(scrubbers, "", fn scrubber, signature ->
|
||||
"#{signature}#{to_string(scrubber)}"
|
||||
end)
|
||||
end
|
||||
|
||||
def extract_first_external_url_from_object(%{data: %{"content" => content}} = object)
|
||||
when is_binary(content) do
|
||||
unless object.data["fake"] do
|
||||
|
|
|
@ -54,8 +54,8 @@ def pool_timeout(pool) do
|
|||
Config.get([:pools, pool, :recv_timeout], default)
|
||||
end
|
||||
|
||||
@prefix Pleroma.Gun.ConnectionPool
|
||||
def limiter_setup do
|
||||
prefix = Pleroma.Gun.ConnectionPool
|
||||
wait = Config.get([:connections_pool, :connection_acquisition_wait])
|
||||
retries = Config.get([:connections_pool, :connection_acquisition_retries])
|
||||
|
||||
|
@ -66,7 +66,7 @@ def limiter_setup do
|
|||
max_waiting = Keyword.get(opts, :max_waiting, 10)
|
||||
|
||||
result =
|
||||
ConcurrentLimiter.new(:"#{@prefix}.#{name}", max_running, max_waiting,
|
||||
ConcurrentLimiter.new(:"#{prefix}.#{name}", max_running, max_waiting,
|
||||
wait: wait,
|
||||
max_retries: retries
|
||||
)
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
defmodule Pleroma.HTTP.WebPush do
|
||||
@moduledoc false
|
||||
|
||||
def post(url, payload, headers) do
|
||||
def post(url, payload, headers, options \\ []) do
|
||||
list_headers = Map.to_list(headers)
|
||||
Pleroma.HTTP.post(url, payload, list_headers)
|
||||
Pleroma.HTTP.post(url, payload, list_headers, options)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,13 +5,18 @@
|
|||
defmodule Pleroma.Instances do
|
||||
@moduledoc "Instances context."
|
||||
|
||||
@adapter Pleroma.Instances.Instance
|
||||
alias Pleroma.Instances.Instance
|
||||
|
||||
defdelegate filter_reachable(urls_or_hosts), to: @adapter
|
||||
defdelegate reachable?(url_or_host), to: @adapter
|
||||
defdelegate set_reachable(url_or_host), to: @adapter
|
||||
defdelegate set_unreachable(url_or_host, unreachable_since \\ nil), to: @adapter
|
||||
defdelegate get_consistently_unreachable(), to: @adapter
|
||||
def filter_reachable(urls_or_hosts), do: Instance.filter_reachable(urls_or_hosts)
|
||||
|
||||
def reachable?(url_or_host), do: Instance.reachable?(url_or_host)
|
||||
|
||||
def set_reachable(url_or_host), do: Instance.set_reachable(url_or_host)
|
||||
|
||||
def set_unreachable(url_or_host, unreachable_since \\ nil),
|
||||
do: Instance.set_unreachable(url_or_host, unreachable_since)
|
||||
|
||||
def get_consistently_unreachable, do: Instance.get_consistently_unreachable()
|
||||
|
||||
def set_consistently_unreachable(url_or_host),
|
||||
do: set_unreachable(url_or_host, reachability_datetime_threshold())
|
||||
|
|
|
@ -8,6 +8,8 @@ defmodule Pleroma.Instances.Instance do
|
|||
alias Pleroma.Instances
|
||||
alias Pleroma.Instances.Instance
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Workers.BackgroundWorker
|
||||
|
||||
use Ecto.Schema
|
||||
|
||||
|
@ -195,4 +197,24 @@ defp scrape_favicon(%URI{} = instance_uri) do
|
|||
nil
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Deletes all users from an instance in a background task, thus also deleting
|
||||
all of those users' activities and notifications.
|
||||
"""
|
||||
def delete_users_and_activities(host) when is_binary(host) do
|
||||
BackgroundWorker.enqueue("delete_instance", %{"host" => host})
|
||||
end
|
||||
|
||||
def perform(:delete_instance, host) when is_binary(host) do
|
||||
User.Query.build(%{nickname: "@#{host}"})
|
||||
|> Repo.chunk_stream(100, :batches)
|
||||
|> Stream.each(fn users ->
|
||||
users
|
||||
|> Enum.each(fn user ->
|
||||
User.perform(:delete, user)
|
||||
end)
|
||||
end)
|
||||
|> Stream.run()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ defmodule Pleroma.Maintenance do
|
|||
def vacuum(args) do
|
||||
case args do
|
||||
"analyze" ->
|
||||
Logger.info("Runnning VACUUM ANALYZE.")
|
||||
Logger.info("Running VACUUM ANALYZE.")
|
||||
|
||||
Repo.query!(
|
||||
"vacuum analyze;",
|
||||
|
@ -18,7 +18,7 @@ def vacuum(args) do
|
|||
)
|
||||
|
||||
"full" ->
|
||||
Logger.info("Runnning VACUUM FULL.")
|
||||
Logger.info("Running VACUUM FULL.")
|
||||
|
||||
Logger.warn(
|
||||
"Re-packing your entire database may take a while and will consume extra disk space during the process."
|
||||
|
|
|
@ -12,4 +12,10 @@ def put_if_present(map, key, value, value_function \\ &{:ok, &1}) when is_map(ma
|
|||
_ -> map
|
||||
end
|
||||
end
|
||||
|
||||
def safe_put_in(data, keys, value) when is_map(data) and is_list(keys) do
|
||||
Kernel.put_in(data, keys, value)
|
||||
rescue
|
||||
_ -> data
|
||||
end
|
||||
end
|
||||
|
|
|
@ -338,6 +338,26 @@ def get_log_entry_message(%ModerationLog{
|
|||
"@#{actor_nickname} approved users: #{users_to_nicknames_string(users)}"
|
||||
end
|
||||
|
||||
def get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "add_suggestion",
|
||||
"subject" => users
|
||||
}
|
||||
}) do
|
||||
"@#{actor_nickname} added suggested users: #{users_to_nicknames_string(users)}"
|
||||
end
|
||||
|
||||
def get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "remove_suggestion",
|
||||
"subject" => users
|
||||
}
|
||||
}) do
|
||||
"@#{actor_nickname} removed suggested users: #{users_to_nicknames_string(users)}"
|
||||
end
|
||||
|
||||
def get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
|
@ -481,9 +501,7 @@ def get_log_entry_message(%ModerationLog{
|
|||
"visibility" => visibility
|
||||
}
|
||||
}) do
|
||||
"@#{actor_nickname} updated status ##{subject_id}, set sensitive: '#{sensitive}', visibility: '#{
|
||||
visibility
|
||||
}'"
|
||||
"@#{actor_nickname} updated status ##{subject_id}, set sensitive: '#{sensitive}', visibility: '#{visibility}'"
|
||||
end
|
||||
|
||||
def get_log_entry_message(%ModerationLog{
|
||||
|
@ -523,9 +541,7 @@ def get_log_entry_message(%ModerationLog{
|
|||
"subject" => subjects
|
||||
}
|
||||
}) do
|
||||
"@#{actor_nickname} re-sent confirmation email for users: #{
|
||||
users_to_nicknames_string(subjects)
|
||||
}"
|
||||
"@#{actor_nickname} re-sent confirmation email for users: #{users_to_nicknames_string(subjects)}"
|
||||
end
|
||||
|
||||
def get_log_entry_message(%ModerationLog{
|
||||
|
|
|
@ -72,6 +72,7 @@ def unread_notifications_count(%User{id: user_id}) do
|
|||
pleroma:emoji_reaction
|
||||
pleroma:report
|
||||
reblog
|
||||
poll
|
||||
}
|
||||
|
||||
def changeset(%Notification{} = notification, attrs) do
|
||||
|
@ -127,6 +128,7 @@ def for_user_query(user, opts \\ %{}) do
|
|||
|> where([user_actor: user_actor], user_actor.is_active)
|
||||
|> exclude_notification_muted(user, exclude_notification_muted_opts)
|
||||
|> exclude_blocked(user, exclude_blocked_opts)
|
||||
|> exclude_blockers(user)
|
||||
|> exclude_filtered(user)
|
||||
|> exclude_visibility(opts)
|
||||
end
|
||||
|
@ -140,6 +142,17 @@ defp exclude_blocked(query, user, opts) do
|
|||
|> FollowingRelationship.keep_following_or_not_domain_blocked(user)
|
||||
end
|
||||
|
||||
defp exclude_blockers(query, user) do
|
||||
if Pleroma.Config.get([:activitypub, :blockers_visible]) == true do
|
||||
query
|
||||
else
|
||||
blocker_ap_ids = User.incoming_relationships_ungrouped_ap_ids(user, [:block])
|
||||
|
||||
query
|
||||
|> where([n, a], a.actor not in ^blocker_ap_ids)
|
||||
end
|
||||
end
|
||||
|
||||
defp exclude_notification_muted(query, _, %{@include_muted_option => true}) do
|
||||
query
|
||||
end
|
||||
|
@ -379,7 +392,7 @@ defp do_create_notifications(%Activity{} = activity, options) do
|
|||
notifications =
|
||||
Enum.map(potential_receivers, fn user ->
|
||||
do_send = do_send && user in enabled_receivers
|
||||
create_notification(activity, user, do_send)
|
||||
create_notification(activity, user, do_send: do_send)
|
||||
end)
|
||||
|> Enum.reject(&is_nil/1)
|
||||
|
||||
|
@ -435,15 +448,18 @@ defp type_from_activity_object(%{data: %{"type" => "Create"}} = activity) do
|
|||
end
|
||||
|
||||
# TODO move to sql, too.
|
||||
def create_notification(%Activity{} = activity, %User{} = user, do_send \\ true) do
|
||||
unless skip?(activity, user) do
|
||||
def create_notification(%Activity{} = activity, %User{} = user, opts \\ []) do
|
||||
do_send = Keyword.get(opts, :do_send, true)
|
||||
type = Keyword.get(opts, :type, type_from_activity(activity))
|
||||
|
||||
unless skip?(activity, user, opts) do
|
||||
{:ok, %{notification: notification}} =
|
||||
Multi.new()
|
||||
|> Multi.insert(:notification, %Notification{
|
||||
user_id: user.id,
|
||||
activity: activity,
|
||||
seen: mark_as_read?(activity, user),
|
||||
type: type_from_activity(activity)
|
||||
type: type
|
||||
})
|
||||
|> Marker.multi_set_last_read_id(user, "notifications")
|
||||
|> Repo.transaction()
|
||||
|
@ -457,6 +473,28 @@ def create_notification(%Activity{} = activity, %User{} = user, do_send \\ true)
|
|||
end
|
||||
end
|
||||
|
||||
def create_poll_notifications(%Activity{} = activity) do
|
||||
with %Object{data: %{"type" => "Question", "actor" => actor} = data} <-
|
||||
Object.normalize(activity) do
|
||||
voters =
|
||||
case data do
|
||||
%{"voters" => voters} when is_list(voters) -> voters
|
||||
_ -> []
|
||||
end
|
||||
|
||||
notifications =
|
||||
Enum.reduce([actor | voters], [], fn ap_id, acc ->
|
||||
with %User{local: true} = user <- User.get_by_ap_id(ap_id) do
|
||||
[create_notification(activity, user, type: "poll") | acc]
|
||||
else
|
||||
_ -> acc
|
||||
end
|
||||
end)
|
||||
|
||||
{:ok, notifications}
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns a tuple with 2 elements:
|
||||
{notification-enabled receivers, currently disabled receivers (blocking / [thread] muting)}
|
||||
|
@ -572,8 +610,10 @@ def exclude_thread_muter_ap_ids(ap_ids, %Activity{} = activity) do
|
|||
Enum.uniq(ap_ids) -- thread_muter_ap_ids
|
||||
end
|
||||
|
||||
@spec skip?(Activity.t(), User.t()) :: boolean()
|
||||
def skip?(%Activity{} = activity, %User{} = user) do
|
||||
def skip?(activity, user, opts \\ [])
|
||||
|
||||
@spec skip?(Activity.t(), User.t(), Keyword.t()) :: boolean()
|
||||
def skip?(%Activity{} = activity, %User{} = user, opts) do
|
||||
[
|
||||
:self,
|
||||
:invisible,
|
||||
|
@ -581,17 +621,21 @@ def skip?(%Activity{} = activity, %User{} = user) do
|
|||
:recently_followed,
|
||||
:filtered
|
||||
]
|
||||
|> Enum.find(&skip?(&1, activity, user))
|
||||
|> Enum.find(&skip?(&1, activity, user, opts))
|
||||
end
|
||||
|
||||
def skip?(_, _), do: false
|
||||
def skip?(_activity, _user, _opts), do: false
|
||||
|
||||
@spec skip?(atom(), Activity.t(), User.t()) :: boolean()
|
||||
def skip?(:self, %Activity{} = activity, %User{} = user) do
|
||||
activity.data["actor"] == user.ap_id
|
||||
@spec skip?(atom(), Activity.t(), User.t(), Keyword.t()) :: boolean()
|
||||
def skip?(:self, %Activity{} = activity, %User{} = user, opts) do
|
||||
cond do
|
||||
opts[:type] == "poll" -> false
|
||||
activity.data["actor"] == user.ap_id -> true
|
||||
true -> false
|
||||
end
|
||||
end
|
||||
|
||||
def skip?(:invisible, %Activity{} = activity, _) do
|
||||
def skip?(:invisible, %Activity{} = activity, _user, _opts) do
|
||||
actor = activity.data["actor"]
|
||||
user = User.get_cached_by_ap_id(actor)
|
||||
User.invisible?(user)
|
||||
|
@ -600,15 +644,27 @@ def skip?(:invisible, %Activity{} = activity, _) do
|
|||
def skip?(
|
||||
:block_from_strangers,
|
||||
%Activity{} = activity,
|
||||
%User{notification_settings: %{block_from_strangers: true}} = user
|
||||
%User{notification_settings: %{block_from_strangers: true}} = user,
|
||||
opts
|
||||
) do
|
||||
actor = activity.data["actor"]
|
||||
follower = User.get_cached_by_ap_id(actor)
|
||||
!User.following?(follower, user)
|
||||
|
||||
cond do
|
||||
opts[:type] == "poll" -> false
|
||||
user.ap_id == actor -> false
|
||||
!User.following?(follower, user) -> true
|
||||
true -> false
|
||||
end
|
||||
end
|
||||
|
||||
# To do: consider defining recency in hours and checking FollowingRelationship with a single SQL
|
||||
def skip?(:recently_followed, %Activity{data: %{"type" => "Follow"}} = activity, %User{} = user) do
|
||||
def skip?(
|
||||
:recently_followed,
|
||||
%Activity{data: %{"type" => "Follow"}} = activity,
|
||||
%User{} = user,
|
||||
_opts
|
||||
) do
|
||||
actor = activity.data["actor"]
|
||||
|
||||
Notification.for_user(user)
|
||||
|
@ -618,9 +674,10 @@ def skip?(:recently_followed, %Activity{data: %{"type" => "Follow"}} = activity,
|
|||
end)
|
||||
end
|
||||
|
||||
def skip?(:filtered, %{data: %{"type" => type}}, _) when type in ["Follow", "Move"], do: false
|
||||
def skip?(:filtered, %{data: %{"type" => type}}, _user, _opts) when type in ["Follow", "Move"],
|
||||
do: false
|
||||
|
||||
def skip?(:filtered, activity, user) do
|
||||
def skip?(:filtered, activity, user, _opts) do
|
||||
object = Object.normalize(activity, fetch: false)
|
||||
|
||||
cond do
|
||||
|
@ -638,7 +695,7 @@ def skip?(:filtered, activity, user) do
|
|||
end
|
||||
end
|
||||
|
||||
def skip?(_, _, _), do: false
|
||||
def skip?(_type, _activity, _user, _opts), do: false
|
||||
|
||||
def mark_as_read?(activity, target_user) do
|
||||
user = Activity.user_actor(activity)
|
||||
|
|
|
@ -366,7 +366,7 @@ def update_data(%Object{data: data} = object, attrs \\ %{}) do
|
|||
end
|
||||
|
||||
def local?(%Object{data: %{"id" => id}}) do
|
||||
String.starts_with?(id, Pleroma.Web.base_url() <> "/")
|
||||
String.starts_with?(id, Pleroma.Web.Endpoint.url() <> "/")
|
||||
end
|
||||
|
||||
def replies(object, opts \\ []) do
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Object.Fetcher do
|
||||
alias Pleroma.HTTP
|
||||
alias Pleroma.Maps
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Object.Containment
|
||||
alias Pleroma.Repo
|
||||
|
@ -101,6 +102,9 @@ def fetch_object_from_id(id, options \\ []) do
|
|||
{:transmogrifier, {:error, {:reject, e}}} ->
|
||||
{:reject, e}
|
||||
|
||||
{:transmogrifier, {:reject, e}} ->
|
||||
{:reject, e}
|
||||
|
||||
{:transmogrifier, _} = e ->
|
||||
{:error, e}
|
||||
|
||||
|
@ -124,12 +128,14 @@ def fetch_object_from_id(id, options \\ []) do
|
|||
defp prepare_activity_params(data) do
|
||||
%{
|
||||
"type" => "Create",
|
||||
"to" => data["to"] || [],
|
||||
"cc" => data["cc"] || [],
|
||||
# Should we seriously keep this attributedTo thing?
|
||||
"actor" => data["actor"] || data["attributedTo"],
|
||||
"object" => data
|
||||
}
|
||||
|> Maps.put_if_present("to", data["to"])
|
||||
|> Maps.put_if_present("cc", data["cc"])
|
||||
|> Maps.put_if_present("bto", data["bto"])
|
||||
|> Maps.put_if_present("bcc", data["bcc"])
|
||||
end
|
||||
|
||||
def fetch_object_from_id!(id, options \\ []) do
|
||||
|
|
|
@ -8,8 +8,6 @@ defmodule Pleroma.Repo do
|
|||
adapter: Ecto.Adapters.Postgres,
|
||||
migration_timestamps: [type: :naive_datetime_usec]
|
||||
|
||||
use Ecto.Explain
|
||||
|
||||
import Ecto.Query
|
||||
require Logger
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ defp increase_read_duration(_) do
|
|||
{:ok, :no_duration_limit, :no_duration_limit}
|
||||
end
|
||||
|
||||
defp client, do: Pleroma.ReverseProxy.Client
|
||||
defp client, do: Pleroma.ReverseProxy.Client.Wrapper
|
||||
|
||||
defp track_failed_url(url, error, opts) do
|
||||
ttl =
|
||||
|
|
|
@ -17,22 +17,4 @@ defmodule Pleroma.ReverseProxy.Client do
|
|||
@callback stream_body(map()) :: {:ok, binary(), map()} | :done | {:error, atom() | String.t()}
|
||||
|
||||
@callback close(reference() | pid() | map()) :: :ok
|
||||
|
||||
def request(method, url, headers, body \\ "", opts \\ []) do
|
||||
client().request(method, url, headers, body, opts)
|
||||
end
|
||||
|
||||
def stream_body(ref), do: client().stream_body(ref)
|
||||
|
||||
def close(ref), do: client().close(ref)
|
||||
|
||||
defp client do
|
||||
:tesla
|
||||
|> Application.get_env(:adapter)
|
||||
|> client()
|
||||
end
|
||||
|
||||
defp client(Tesla.Adapter.Hackney), do: Pleroma.ReverseProxy.Client.Hackney
|
||||
defp client(Tesla.Adapter.Gun), do: Pleroma.ReverseProxy.Client.Tesla
|
||||
defp client(_), do: Pleroma.Config.get!(Pleroma.ReverseProxy.Client)
|
||||
end
|
||||
|
|
29
lib/pleroma/reverse_proxy/client/wrapper.ex
Normal file
29
lib/pleroma/reverse_proxy/client/wrapper.ex
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.ReverseProxy.Client.Wrapper do
|
||||
@moduledoc "Meta-client that calls the appropriate client from the config."
|
||||
@behaviour Pleroma.ReverseProxy.Client
|
||||
|
||||
@impl true
|
||||
def request(method, url, headers, body \\ "", opts \\ []) do
|
||||
client().request(method, url, headers, body, opts)
|
||||
end
|
||||
|
||||
@impl true
|
||||
def stream_body(ref), do: client().stream_body(ref)
|
||||
|
||||
@impl true
|
||||
def close(ref), do: client().close(ref)
|
||||
|
||||
defp client do
|
||||
:tesla
|
||||
|> Application.get_env(:adapter)
|
||||
|> client()
|
||||
end
|
||||
|
||||
defp client(Tesla.Adapter.Hackney), do: Pleroma.ReverseProxy.Client.Hackney
|
||||
defp client(Tesla.Adapter.Gun), do: Pleroma.ReverseProxy.Client.Tesla
|
||||
defp client(_), do: Pleroma.Config.get!(Pleroma.ReverseProxy.Client)
|
||||
end
|
|
@ -29,9 +29,7 @@ def handle_event(
|
|||
_
|
||||
) do
|
||||
Logger.debug(fn ->
|
||||
"Connection pool is exhausted (reached #{max_connections} connections). Starting idle connection cleanup to reclaim as much as #{
|
||||
reclaim_max
|
||||
} connections"
|
||||
"Connection pool is exhausted (reached #{max_connections} connections). Starting idle connection cleanup to reclaim as much as #{reclaim_max} connections"
|
||||
end)
|
||||
end
|
||||
|
||||
|
@ -73,9 +71,7 @@ def handle_event(
|
|||
_
|
||||
) do
|
||||
Logger.warn(fn ->
|
||||
"Pool worker for #{key}: Client #{inspect(client_pid)} died before releasing the connection with #{
|
||||
inspect(reason)
|
||||
}"
|
||||
"Pool worker for #{key}: Client #{inspect(client_pid)} died before releasing the connection with #{inspect(reason)}"
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ defmodule Pleroma.Tests.AuthTestController do
|
|||
use Pleroma.Web, :controller
|
||||
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.Plugs.EnsurePublicOrAuthenticatedPlug
|
||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||
|
||||
# Serves only with proper OAuth token (:api and :authenticated_api)
|
||||
|
@ -47,10 +46,7 @@ defmodule Pleroma.Tests.AuthTestController do
|
|||
# Via :authenticated_api, serves if token is present and has requested scopes
|
||||
#
|
||||
# Suggested use: as :fallback_oauth_check but open with nil :user for :api on private instances
|
||||
plug(
|
||||
:skip_plug,
|
||||
EnsurePublicOrAuthenticatedPlug when action == :fallback_oauth_skip_publicity_check
|
||||
)
|
||||
plug(:skip_public_check when action == :fallback_oauth_skip_publicity_check)
|
||||
|
||||
plug(
|
||||
OAuthScopesPlug,
|
||||
|
@ -62,11 +58,7 @@ defmodule Pleroma.Tests.AuthTestController do
|
|||
# Via :authenticated_api, serves if :user is set (regardless of token presence and its scopes)
|
||||
#
|
||||
# Suggested use: making an :api endpoint always accessible (e.g. email confirmation endpoint)
|
||||
plug(
|
||||
:skip_plug,
|
||||
[OAuthScopesPlug, EnsurePublicOrAuthenticatedPlug]
|
||||
when action == :skip_oauth_skip_publicity_check
|
||||
)
|
||||
plug(:skip_auth when action == :skip_oauth_skip_publicity_check)
|
||||
|
||||
# Via :authenticated_api, always fails with 403 (endpoint is insecure)
|
||||
# Via :api, drops :user if present and serves if public (private instance rejects on no user)
|
||||
|
|
|
@ -23,6 +23,9 @@ defmodule Pleroma.Upload do
|
|||
is once created permanent and changing it (especially in uploaders) is probably a bad idea!
|
||||
* `:tempfile` - path to the temporary file. Prefer in-place changes on the file rather than changing the
|
||||
path as the temporary file is also tracked by `Plug.Upload{}` and automatically deleted once the request is over.
|
||||
* `:width` - width of the media in pixels
|
||||
* `:height` - height of the media in pixels
|
||||
* `:blurhash` - string hash of the image encoded with the blurhash algorithm (https://blurha.sh/)
|
||||
|
||||
Related behaviors:
|
||||
|
||||
|
@ -32,6 +35,7 @@ defmodule Pleroma.Upload do
|
|||
"""
|
||||
alias Ecto.UUID
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Maps
|
||||
require Logger
|
||||
|
||||
@type source ::
|
||||
|
@ -53,9 +57,12 @@ defmodule Pleroma.Upload do
|
|||
name: String.t(),
|
||||
tempfile: String.t(),
|
||||
content_type: String.t(),
|
||||
width: integer(),
|
||||
height: integer(),
|
||||
blurhash: String.t(),
|
||||
path: String.t()
|
||||
}
|
||||
defstruct [:id, :name, :tempfile, :content_type, :path]
|
||||
defstruct [:id, :name, :tempfile, :content_type, :width, :height, :blurhash, :path]
|
||||
|
||||
defp get_description(opts, upload) do
|
||||
case {opts[:description], Pleroma.Config.get([Pleroma.Upload, :default_description])} do
|
||||
|
@ -89,9 +96,12 @@ def store(upload, opts \\ []) do
|
|||
"mediaType" => upload.content_type,
|
||||
"href" => url_from_spec(upload, opts.base_url, url_spec)
|
||||
}
|
||||
|> Maps.put_if_present("width", upload.width)
|
||||
|> Maps.put_if_present("height", upload.height)
|
||||
],
|
||||
"name" => description
|
||||
}}
|
||||
}
|
||||
|> Maps.put_if_present("blurhash", upload.blurhash)}
|
||||
else
|
||||
{:description_limit, _} ->
|
||||
{:error, :description_too_long}
|
||||
|
@ -225,7 +235,7 @@ def base_url do
|
|||
|
||||
case uploader do
|
||||
Pleroma.Uploaders.Local ->
|
||||
upload_base_url || Pleroma.Web.base_url() <> "/media/"
|
||||
upload_base_url || Pleroma.Web.Endpoint.url() <> "/media/"
|
||||
|
||||
Pleroma.Uploaders.S3 ->
|
||||
bucket = Config.get([Pleroma.Uploaders.S3, :bucket])
|
||||
|
@ -251,7 +261,7 @@ def base_url do
|
|||
end
|
||||
|
||||
_ ->
|
||||
public_endpoint || upload_base_url || Pleroma.Web.base_url() <> "/media/"
|
||||
public_endpoint || upload_base_url || Pleroma.Web.Endpoint.url() <> "/media/"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,13 +15,13 @@ defmodule Pleroma.Upload.Filter do
|
|||
|
||||
require Logger
|
||||
|
||||
@callback filter(Pleroma.Upload.t()) ::
|
||||
@callback filter(upload :: struct()) ::
|
||||
{:ok, :filtered}
|
||||
| {:ok, :noop}
|
||||
| {:ok, :filtered, Pleroma.Upload.t()}
|
||||
| {:ok, :filtered, upload :: struct()}
|
||||
| {:error, any()}
|
||||
|
||||
@spec filter([module()], Pleroma.Upload.t()) :: {:ok, Pleroma.Upload.t()} | {:error, any()}
|
||||
@spec filter([module()], upload :: struct()) :: {:ok, upload :: struct()} | {:error, any()}
|
||||
|
||||
def filter([], upload) do
|
||||
{:ok, upload}
|
||||
|
|
83
lib/pleroma/upload/filter/analyze_metadata.ex
Normal file
83
lib/pleroma/upload/filter/analyze_metadata.ex
Normal file
|
@ -0,0 +1,83 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Upload.Filter.AnalyzeMetadata do
|
||||
@moduledoc """
|
||||
Extracts metadata about the upload, such as width/height
|
||||
"""
|
||||
require Logger
|
||||
|
||||
@behaviour Pleroma.Upload.Filter
|
||||
|
||||
@spec filter(Pleroma.Upload.t()) ::
|
||||
{:ok, :filtered, Pleroma.Upload.t()} | {:ok, :noop} | {:error, String.t()}
|
||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _} = upload) do
|
||||
try do
|
||||
image =
|
||||
file
|
||||
|> Mogrify.open()
|
||||
|> Mogrify.verbose()
|
||||
|
||||
upload =
|
||||
upload
|
||||
|> Map.put(:width, image.width)
|
||||
|> Map.put(:height, image.height)
|
||||
|> Map.put(:blurhash, get_blurhash(file))
|
||||
|
||||
{:ok, :filtered, upload}
|
||||
rescue
|
||||
e in ErlangError ->
|
||||
Logger.warn("#{__MODULE__}: #{inspect(e)}")
|
||||
{:ok, :noop}
|
||||
end
|
||||
end
|
||||
|
||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "video" <> _} = upload) do
|
||||
try do
|
||||
result = media_dimensions(file)
|
||||
|
||||
upload =
|
||||
upload
|
||||
|> Map.put(:width, result.width)
|
||||
|> Map.put(:height, result.height)
|
||||
|
||||
{:ok, :filtered, upload}
|
||||
rescue
|
||||
e in ErlangError ->
|
||||
Logger.warn("#{__MODULE__}: #{inspect(e)}")
|
||||
{:ok, :noop}
|
||||
end
|
||||
end
|
||||
|
||||
def filter(_), do: {:ok, :noop}
|
||||
|
||||
defp get_blurhash(file) do
|
||||
with {:ok, blurhash} <- :eblurhash.magick(file) do
|
||||
blurhash
|
||||
else
|
||||
_ -> nil
|
||||
end
|
||||
end
|
||||
|
||||
defp media_dimensions(file) do
|
||||
with executable when is_binary(executable) <- System.find_executable("ffprobe"),
|
||||
args = [
|
||||
"-v",
|
||||
"error",
|
||||
"-show_entries",
|
||||
"stream=width,height",
|
||||
"-of",
|
||||
"csv=p=0:s=x",
|
||||
file
|
||||
],
|
||||
{result, 0} <- System.cmd(executable, args),
|
||||
[width, height] <-
|
||||
String.split(String.trim(result), "x") |> Enum.map(&String.to_integer(&1)) do
|
||||
%{width: width, height: height}
|
||||
else
|
||||
nil -> {:error, {:ffprobe, :command_not_found}}
|
||||
{:error, _} = error -> error
|
||||
end
|
||||
end
|
||||
end
|
|
@ -35,7 +35,7 @@ defmodule Pleroma.Uploaders.Uploader do
|
|||
|
||||
"""
|
||||
@type file_spec :: {:file | :url, String.t()}
|
||||
@callback put_file(Pleroma.Upload.t()) ::
|
||||
@callback put_file(upload :: struct()) ::
|
||||
:ok | {:ok, file_spec()} | {:error, String.t()} | :wait_callback
|
||||
|
||||
@callback delete_file(file :: String.t()) :: :ok | {:error, String.t()}
|
||||
|
@ -46,7 +46,7 @@ defmodule Pleroma.Uploaders.Uploader do
|
|||
| {:error, Plug.Conn.t(), String.t()}
|
||||
@optional_callbacks http_callback: 2
|
||||
|
||||
@spec put_file(module(), Pleroma.Upload.t()) :: {:ok, file_spec()} | {:error, String.t()}
|
||||
@spec put_file(module(), upload :: struct()) :: {:ok, file_spec()} | {:error, String.t()}
|
||||
def put_file(uploader, upload) do
|
||||
case uploader.put_file(upload) do
|
||||
:ok -> {:ok, {:file, upload.path}}
|
||||
|
|
|
@ -27,13 +27,13 @@ defmodule Pleroma.User do
|
|||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.UserRelationship
|
||||
alias Pleroma.Web
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.ActivityPub.Builder
|
||||
alias Pleroma.Web.ActivityPub.Pipeline
|
||||
alias Pleroma.Web.ActivityPub.Utils
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.CommonAPI.Utils, as: CommonUtils
|
||||
alias Pleroma.Web.Endpoint
|
||||
alias Pleroma.Web.OAuth
|
||||
alias Pleroma.Web.RelMe
|
||||
alias Pleroma.Workers.BackgroundWorker
|
||||
|
@ -124,7 +124,6 @@ defmodule Pleroma.User do
|
|||
field(:is_moderator, :boolean, default: false)
|
||||
field(:is_admin, :boolean, default: false)
|
||||
field(:show_role, :boolean, default: true)
|
||||
field(:mastofe_settings, :map, default: nil)
|
||||
field(:uri, ObjectValidators.Uri, default: nil)
|
||||
field(:hide_followers_count, :boolean, default: false)
|
||||
field(:hide_follows_count, :boolean, default: false)
|
||||
|
@ -149,6 +148,7 @@ defmodule Pleroma.User do
|
|||
field(:last_active_at, :naive_datetime)
|
||||
field(:disclose_client, :boolean, default: true)
|
||||
field(:pinned_objects, :map, default: %{})
|
||||
field(:is_suggested, :boolean, default: false)
|
||||
|
||||
embeds_one(
|
||||
:notification_settings,
|
||||
|
@ -360,7 +360,7 @@ def avatar_url(user, options \\ []) do
|
|||
|
||||
_ ->
|
||||
unless options[:no_default] do
|
||||
Config.get([:assets, :default_user_avatar], "#{Web.base_url()}/images/avi.png")
|
||||
Config.get([:assets, :default_user_avatar], "#{Endpoint.url()}/images/avi.png")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -368,13 +368,13 @@ def avatar_url(user, options \\ []) do
|
|||
def banner_url(user, options \\ []) do
|
||||
case user.banner do
|
||||
%{"url" => [%{"href" => href} | _]} -> href
|
||||
_ -> !options[:no_default] && "#{Web.base_url()}/images/banner.png"
|
||||
_ -> !options[:no_default] && "#{Endpoint.url()}/images/banner.png"
|
||||
end
|
||||
end
|
||||
|
||||
# Should probably be renamed or removed
|
||||
@spec ap_id(User.t()) :: String.t()
|
||||
def ap_id(%User{nickname: nickname}), do: "#{Web.base_url()}/users/#{nickname}"
|
||||
def ap_id(%User{nickname: nickname}), do: "#{Endpoint.url()}/users/#{nickname}"
|
||||
|
||||
@spec ap_followers(User.t()) :: String.t()
|
||||
def ap_followers(%User{follower_address: fa}) when is_binary(fa), do: fa
|
||||
|
@ -1677,6 +1677,22 @@ def confirm(%User{is_confirmed: false} = user) do
|
|||
|
||||
def confirm(%User{} = user), do: {:ok, user}
|
||||
|
||||
def set_suggestion(users, is_suggested) when is_list(users) do
|
||||
Repo.transaction(fn ->
|
||||
Enum.map(users, fn user ->
|
||||
with {:ok, user} <- set_suggestion(user, is_suggested), do: user
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
def set_suggestion(%User{is_suggested: is_suggested} = user, is_suggested), do: {:ok, user}
|
||||
|
||||
def set_suggestion(%User{} = user, is_suggested) when is_boolean(is_suggested) do
|
||||
user
|
||||
|> change(is_suggested: is_suggested)
|
||||
|> update_and_set_cache()
|
||||
end
|
||||
|
||||
def update_notification_settings(%User{} = user, settings) do
|
||||
user
|
||||
|> cast(%{notification_settings: settings}, [])
|
||||
|
@ -1695,8 +1711,6 @@ def purge_user_changeset(user) do
|
|||
email: nil,
|
||||
name: nil,
|
||||
password_hash: nil,
|
||||
keys: nil,
|
||||
public_key: nil,
|
||||
avatar: %{},
|
||||
tags: [],
|
||||
last_refreshed_at: nil,
|
||||
|
@ -1707,9 +1721,7 @@ def purge_user_changeset(user) do
|
|||
follower_count: 0,
|
||||
following_count: 0,
|
||||
is_locked: false,
|
||||
is_confirmed: true,
|
||||
password_reset_pending: false,
|
||||
is_approved: true,
|
||||
registration_reason: nil,
|
||||
confirmation_token: nil,
|
||||
domain_blocks: [],
|
||||
|
@ -1717,7 +1729,6 @@ def purge_user_changeset(user) do
|
|||
ap_enabled: false,
|
||||
is_moderator: false,
|
||||
is_admin: false,
|
||||
mastofe_settings: nil,
|
||||
mascot: nil,
|
||||
emoji: %{},
|
||||
pleroma_settings_store: %{},
|
||||
|
@ -1725,45 +1736,53 @@ def purge_user_changeset(user) do
|
|||
raw_fields: [],
|
||||
is_discoverable: false,
|
||||
also_known_as: []
|
||||
# id: preserved
|
||||
# ap_id: preserved
|
||||
# nickname: preserved
|
||||
})
|
||||
end
|
||||
|
||||
# Purge doesn't delete the user from the database.
|
||||
# It just nulls all its fields and deactivates it.
|
||||
# See `User.purge_user_changeset/1` above.
|
||||
defp purge(%User{} = user) do
|
||||
user
|
||||
|> purge_user_changeset()
|
||||
|> update_and_set_cache()
|
||||
end
|
||||
|
||||
def delete(users) when is_list(users) do
|
||||
for user <- users, do: delete(user)
|
||||
end
|
||||
|
||||
def delete(%User{} = user) do
|
||||
# Purge the user immediately
|
||||
purge(user)
|
||||
BackgroundWorker.enqueue("delete_user", %{"user_id" => user.id})
|
||||
end
|
||||
|
||||
defp delete_and_invalidate_cache(%User{} = user) do
|
||||
# *Actually* delete the user from the DB
|
||||
defp delete_from_db(%User{} = user) do
|
||||
invalidate_cache(user)
|
||||
Repo.delete(user)
|
||||
end
|
||||
|
||||
defp delete_or_deactivate(%User{local: false} = user), do: delete_and_invalidate_cache(user)
|
||||
# If the user never finalized their account, it's safe to delete them.
|
||||
defp maybe_delete_from_db(%User{local: true, is_confirmed: false} = user),
|
||||
do: delete_from_db(user)
|
||||
|
||||
defp delete_or_deactivate(%User{local: true} = user) do
|
||||
status = account_status(user)
|
||||
defp maybe_delete_from_db(%User{local: true, is_approved: false} = user),
|
||||
do: delete_from_db(user)
|
||||
|
||||
case status do
|
||||
:confirmation_pending ->
|
||||
delete_and_invalidate_cache(user)
|
||||
|
||||
:approval_pending ->
|
||||
delete_and_invalidate_cache(user)
|
||||
|
||||
_ ->
|
||||
user
|
||||
|> purge_user_changeset()
|
||||
|> update_and_set_cache()
|
||||
end
|
||||
end
|
||||
defp maybe_delete_from_db(user), do: {:ok, user}
|
||||
|
||||
def perform(:force_password_reset, user), do: force_password_reset(user)
|
||||
|
||||
@spec perform(atom(), User.t()) :: {:ok, User.t()}
|
||||
def perform(:delete, %User{} = user) do
|
||||
# Purge the user again, in case perform/2 is called directly
|
||||
purge(user)
|
||||
|
||||
# Remove all relationships
|
||||
user
|
||||
|> get_followers()
|
||||
|
@ -1781,10 +1800,9 @@ def perform(:delete, %User{} = user) do
|
|||
|
||||
delete_user_activities(user)
|
||||
delete_notifications_from_user_activities(user)
|
||||
|
||||
delete_outgoing_pending_follow_requests(user)
|
||||
|
||||
delete_or_deactivate(user)
|
||||
maybe_delete_from_db(user)
|
||||
end
|
||||
|
||||
def perform(:set_activation_async, user, status), do: set_activation(user, status)
|
||||
|
@ -2245,7 +2263,7 @@ def get_delivered_users_by_object_id(object_id) do
|
|||
def change_email(user, email) do
|
||||
user
|
||||
|> cast(%{email: email}, [:email])
|
||||
|> validate_required([:email])
|
||||
|> maybe_validate_required_email(false)
|
||||
|> unique_constraint(:email)
|
||||
|> validate_format(:email, @email_regex)
|
||||
|> update_and_set_cache()
|
||||
|
@ -2328,13 +2346,6 @@ def mascot_update(user, url) do
|
|||
|> update_and_set_cache()
|
||||
end
|
||||
|
||||
def mastodon_settings_update(user, settings) do
|
||||
user
|
||||
|> cast(%{mastofe_settings: settings}, [:mastofe_settings])
|
||||
|> validate_required([:mastofe_settings])
|
||||
|> update_and_set_cache()
|
||||
end
|
||||
|
||||
@spec confirmation_changeset(User.t(), keyword()) :: Changeset.t()
|
||||
def confirmation_changeset(user, set_confirmation: confirmed?) do
|
||||
params =
|
||||
|
@ -2480,8 +2491,8 @@ def update_last_active_at(%__MODULE__{local: true} = user) do
|
|||
|> update_and_set_cache()
|
||||
end
|
||||
|
||||
def active_user_count(weeks \\ 4) do
|
||||
active_after = Timex.shift(NaiveDateTime.utc_now(), weeks: -weeks)
|
||||
def active_user_count(days \\ 30) do
|
||||
active_after = Timex.shift(NaiveDateTime.utc_now(), days: -days)
|
||||
|
||||
__MODULE__
|
||||
|> where([u], u.last_active_at >= ^active_after)
|
||||
|
|
|
@ -27,7 +27,7 @@ defmodule Pleroma.User.Query do
|
|||
- e.g. Pleroma.User.Query.build(%{ap_id: ["http://ap_id1", "http://ap_id2"]})
|
||||
"""
|
||||
import Ecto.Query
|
||||
import Pleroma.Web.AdminAPI.Search, only: [not_empty_string: 1]
|
||||
import Pleroma.Web.Utils.Guards, only: [not_empty_string: 1]
|
||||
|
||||
alias Pleroma.FollowingRelationship
|
||||
alias Pleroma.User
|
||||
|
@ -46,6 +46,7 @@ defmodule Pleroma.User.Query do
|
|||
unconfirmed: boolean(),
|
||||
is_admin: boolean(),
|
||||
is_moderator: boolean(),
|
||||
is_suggested: boolean(),
|
||||
super_users: boolean(),
|
||||
invisible: boolean(),
|
||||
internal: boolean(),
|
||||
|
@ -167,6 +168,10 @@ defp compose_query({:unconfirmed, _}, query) do
|
|||
where(query, [u], u.is_confirmed == false)
|
||||
end
|
||||
|
||||
defp compose_query({:is_suggested, bool}, query) do
|
||||
where(query, [u], u.is_suggested == ^bool)
|
||||
end
|
||||
|
||||
defp compose_query({:followers, %User{id: id}}, query) do
|
||||
query
|
||||
|> where([u], u.id != ^id)
|
||||
|
|
52
lib/pleroma/user_note.ex
Normal file
52
lib/pleroma/user_note.ex
Normal file
|
@ -0,0 +1,52 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.UserNote do
|
||||
use Ecto.Schema
|
||||
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.UserNote
|
||||
|
||||
schema "user_notes" do
|
||||
belongs_to(:source, User, type: FlakeId.Ecto.CompatType)
|
||||
belongs_to(:target, User, type: FlakeId.Ecto.CompatType)
|
||||
field(:comment, :string)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
def changeset(%UserNote{} = user_note, params \\ %{}) do
|
||||
user_note
|
||||
|> cast(params, [:source_id, :target_id, :comment])
|
||||
|> validate_required([:source_id, :target_id])
|
||||
end
|
||||
|
||||
def show(%User{} = source, %User{} = target) do
|
||||
with %UserNote{} = note <-
|
||||
UserNote
|
||||
|> where(source_id: ^source.id, target_id: ^target.id)
|
||||
|> Repo.one() do
|
||||
note.comment
|
||||
else
|
||||
_ -> ""
|
||||
end
|
||||
end
|
||||
|
||||
def create(%User{} = source, %User{} = target, comment) do
|
||||
%UserNote{}
|
||||
|> changeset(%{
|
||||
source_id: source.id,
|
||||
target_id: target.id,
|
||||
comment: comment
|
||||
})
|
||||
|> Repo.insert(
|
||||
on_conflict: {:replace, [:comment]},
|
||||
conflict_target: [:source_id, :target_id]
|
||||
)
|
||||
end
|
||||
end
|
|
@ -35,9 +35,10 @@ def controller do
|
|||
import Plug.Conn
|
||||
|
||||
import Pleroma.Web.Gettext
|
||||
import Pleroma.Web.Router.Helpers
|
||||
import Pleroma.Web.TranslationHelpers
|
||||
|
||||
alias Pleroma.Web.Router.Helpers, as: Routes
|
||||
|
||||
plug(:set_put_layout)
|
||||
|
||||
defp set_put_layout(conn, _) do
|
||||
|
@ -61,6 +62,14 @@ defp skip_plug(conn, plug_modules) do
|
|||
)
|
||||
end
|
||||
|
||||
defp skip_auth(conn, _) do
|
||||
skip_plug(conn, [OAuthScopesPlug, EnsurePublicOrAuthenticatedPlug])
|
||||
end
|
||||
|
||||
defp skip_public_check(conn, _) do
|
||||
skip_plug(conn, EnsurePublicOrAuthenticatedPlug)
|
||||
end
|
||||
|
||||
# Executed just before actual controller action, invokes before-action hooks (callbacks)
|
||||
defp action(conn, params) do
|
||||
with %{halted: false} = conn <-
|
||||
|
@ -131,7 +140,8 @@ def view do
|
|||
|
||||
import Pleroma.Web.ErrorHelpers
|
||||
import Pleroma.Web.Gettext
|
||||
import Pleroma.Web.Router.Helpers
|
||||
|
||||
alias Pleroma.Web.Router.Helpers, as: Routes
|
||||
|
||||
require Logger
|
||||
|
||||
|
@ -229,20 +239,4 @@ def call(%Plug.Conn{} = conn, options) do
|
|||
defmacro __using__(which) when is_atom(which) do
|
||||
apply(__MODULE__, which, [])
|
||||
end
|
||||
|
||||
def base_url do
|
||||
Pleroma.Web.Endpoint.url()
|
||||
end
|
||||
|
||||
# TODO: Change to Phoenix.Router.routes/1 for Phoenix 1.6.0+
|
||||
def get_api_routes do
|
||||
Pleroma.Web.Router.__routes__()
|
||||
|> Enum.reject(fn r -> r.plug == Pleroma.Web.Fallback.RedirectController end)
|
||||
|> Enum.map(fn r ->
|
||||
r.path
|
||||
|> String.split("/", trim: true)
|
||||
|> List.first()
|
||||
end)
|
||||
|> Enum.uniq()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,6 +25,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
alias Pleroma.Web.Streamer
|
||||
alias Pleroma.Web.WebFinger
|
||||
alias Pleroma.Workers.BackgroundWorker
|
||||
alias Pleroma.Workers.PollWorker
|
||||
|
||||
import Ecto.Query
|
||||
import Pleroma.Web.ActivityPub.Utils
|
||||
|
@ -53,15 +54,18 @@ defp get_recipients(data) do
|
|||
{recipients, to, cc}
|
||||
end
|
||||
|
||||
defp check_actor_is_active(nil), do: true
|
||||
defp check_actor_can_insert(%{"type" => "Delete"}), do: true
|
||||
defp check_actor_can_insert(%{"type" => "Undo"}), do: true
|
||||
|
||||
defp check_actor_is_active(actor) when is_binary(actor) do
|
||||
defp check_actor_can_insert(%{"actor" => actor}) when is_binary(actor) do
|
||||
case User.get_cached_by_ap_id(actor) do
|
||||
%User{is_active: true} -> true
|
||||
_ -> false
|
||||
end
|
||||
end
|
||||
|
||||
defp check_actor_can_insert(_), do: true
|
||||
|
||||
defp check_remote_limit(%{"object" => %{"content" => content}}) when not is_nil(content) do
|
||||
limit = Config.get([:instance, :remote_limit])
|
||||
String.length(content) <= limit
|
||||
|
@ -88,7 +92,7 @@ defp increase_replies_count_if_reply(%{
|
|||
|
||||
defp increase_replies_count_if_reply(_create_data), do: :noop
|
||||
|
||||
@object_types ~w[ChatMessage Question Answer Audio Video Event Article]
|
||||
@object_types ~w[ChatMessage Question Answer Audio Video Event Article Note Page]
|
||||
@impl true
|
||||
def persist(%{"type" => type} = object, meta) when type in @object_types do
|
||||
with {:ok, object} <- Object.create(object) do
|
||||
|
@ -117,7 +121,7 @@ def persist(object, meta) do
|
|||
def insert(map, local \\ true, fake \\ false, bypass_actor_check \\ false) when is_map(map) do
|
||||
with nil <- Activity.normalize(map),
|
||||
map <- lazy_put_activity_defaults(map, fake),
|
||||
{_, true} <- {:actor_check, bypass_actor_check || check_actor_is_active(map["actor"])},
|
||||
{_, true} <- {:actor_check, bypass_actor_check || check_actor_can_insert(map)},
|
||||
{_, true} <- {:remote_limit_pass, check_remote_limit(map)},
|
||||
{:ok, map} <- MRF.filter(map),
|
||||
{recipients, _, _} = get_recipients(map),
|
||||
|
@ -285,6 +289,7 @@ defp do_create(%{to: to, actor: actor, context: context, object: object} = param
|
|||
{:quick_insert, false, activity} <- {:quick_insert, quick_insert?, activity},
|
||||
{:ok, _actor} <- increase_note_count_if_public(actor, activity),
|
||||
_ <- notify_and_stream(activity),
|
||||
:ok <- maybe_schedule_poll_notifications(activity),
|
||||
:ok <- maybe_federate(activity) do
|
||||
{:ok, activity}
|
||||
else
|
||||
|
@ -299,6 +304,11 @@ defp do_create(%{to: to, actor: actor, context: context, object: object} = param
|
|||
end
|
||||
end
|
||||
|
||||
defp maybe_schedule_poll_notifications(activity) do
|
||||
PollWorker.schedule_poll_end(activity)
|
||||
:ok
|
||||
end
|
||||
|
||||
@spec listen(map()) :: {:ok, Activity.t()} | {:error, any()}
|
||||
def listen(%{to: to, actor: actor, context: context, object: object} = params) do
|
||||
additional = params[:additional] || %{}
|
||||
|
@ -431,6 +441,7 @@ def fetch_activities_for_context_query(context, opts) do
|
|||
|> maybe_preload_bookmarks(opts)
|
||||
|> maybe_set_thread_muted_field(opts)
|
||||
|> restrict_blocked(opts)
|
||||
|> restrict_blockers_visibility(opts)
|
||||
|> restrict_recipients(recipients, opts[:user])
|
||||
|> restrict_filtered(opts)
|
||||
|> where(
|
||||
|
@ -1018,7 +1029,10 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) do
|
|||
|
||||
from(
|
||||
[activity, object: o] in query,
|
||||
# You don't block the author
|
||||
where: fragment("not (? = ANY(?))", activity.actor, ^blocked_ap_ids),
|
||||
|
||||
# You don't block any recipients, and didn't author the post
|
||||
where:
|
||||
fragment(
|
||||
"((not (? && ?)) or ? = ?)",
|
||||
|
@ -1027,12 +1041,18 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) do
|
|||
activity.actor,
|
||||
^user.ap_id
|
||||
),
|
||||
|
||||
# You don't block the domain of any recipients, and didn't author the post
|
||||
where:
|
||||
fragment(
|
||||
"recipients_contain_blocked_domains(?, ?) = false",
|
||||
"(recipients_contain_blocked_domains(?, ?) = false) or ? = ?",
|
||||
activity.recipients,
|
||||
^domain_blocks
|
||||
^domain_blocks,
|
||||
activity.actor,
|
||||
^user.ap_id
|
||||
),
|
||||
|
||||
# It's not a boost of a user you block
|
||||
where:
|
||||
fragment(
|
||||
"not (?->>'type' = 'Announce' and ?->'to' \\?| ?)",
|
||||
|
@ -1040,6 +1060,8 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) do
|
|||
activity.data,
|
||||
^blocked_ap_ids
|
||||
),
|
||||
|
||||
# You don't block the author's domain, and also don't follow the author
|
||||
where:
|
||||
fragment(
|
||||
"(not (split_part(?, '/', 3) = ANY(?))) or ? = ANY(?)",
|
||||
|
@ -1048,6 +1070,8 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) do
|
|||
activity.actor,
|
||||
^following_ap_ids
|
||||
),
|
||||
|
||||
# Same as above, but checks the Object
|
||||
where:
|
||||
fragment(
|
||||
"(not (split_part(?->>'actor', '/', 3) = ANY(?))) or (?->>'actor') = ANY(?)",
|
||||
|
@ -1061,6 +1085,31 @@ defp restrict_blocked(query, %{blocking_user: %User{} = user} = opts) do
|
|||
|
||||
defp restrict_blocked(query, _), do: query
|
||||
|
||||
defp restrict_blockers_visibility(query, %{blocking_user: %User{} = user}) do
|
||||
if Config.get([:activitypub, :blockers_visible]) == true do
|
||||
query
|
||||
else
|
||||
blocker_ap_ids = User.incoming_relationships_ungrouped_ap_ids(user, [:block])
|
||||
|
||||
from(
|
||||
activity in query,
|
||||
# The author doesn't block you
|
||||
where: fragment("not (? = ANY(?))", activity.actor, ^blocker_ap_ids),
|
||||
|
||||
# It's not a boost of a user that blocks you
|
||||
where:
|
||||
fragment(
|
||||
"not (?->>'type' = 'Announce' and ?->'to' \\?| ?)",
|
||||
activity.data,
|
||||
activity.data,
|
||||
^blocker_ap_ids
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
defp restrict_blockers_visibility(query, _), do: query
|
||||
|
||||
defp restrict_unlisted(query, %{restrict_unlisted: true}) do
|
||||
from(
|
||||
activity in query,
|
||||
|
@ -1287,6 +1336,7 @@ def fetch_activities_query(recipients, opts \\ %{}) do
|
|||
|> restrict_state(opts)
|
||||
|> restrict_favorited_by(opts)
|
||||
|> restrict_blocked(restrict_blocked_opts)
|
||||
|> restrict_blockers_visibility(opts)
|
||||
|> restrict_muted(restrict_muted_opts)
|
||||
|> restrict_filtered(opts)
|
||||
|> restrict_media(opts)
|
||||
|
@ -1587,9 +1637,7 @@ def maybe_handle_clashing_nickname(data) do
|
|||
%User{} = old_user <- User.get_by_nickname(nickname),
|
||||
{_, false} <- {:ap_id_comparison, data[:ap_id] == old_user.ap_id} do
|
||||
Logger.info(
|
||||
"Found an old user for #{nickname}, the old ap id is #{old_user.ap_id}, new one is #{
|
||||
data[:ap_id]
|
||||
}, renaming."
|
||||
"Found an old user for #{nickname}, the old ap id is #{old_user.ap_id}, new one is #{data[:ap_id]}, renaming."
|
||||
)
|
||||
|
||||
old_user
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.ActivityPub.Persisting do
|
||||
@callback persist(map(), keyword()) :: {:ok, Activity.t() | Object.t()}
|
||||
@callback persist(map(), keyword()) :: {:ok, struct()}
|
||||
end
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.ActivityPub.Streaming do
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.User
|
||||
|
||||
@callback stream_out(Activity.t()) :: any()
|
||||
@callback stream_out_participations(Object.t(), User.t()) :: any()
|
||||
@callback stream_out(struct()) :: any()
|
||||
@callback stream_out_participations(struct(), struct()) :: any()
|
||||
end
|
||||
|
|
|
@ -11,7 +11,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
|||
alias Pleroma.Object.Fetcher
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.ActivityPub.Builder
|
||||
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
||||
alias Pleroma.Web.ActivityPub.ObjectView
|
||||
alias Pleroma.Web.ActivityPub.Pipeline
|
||||
|
@ -284,15 +283,29 @@ def inbox(%{assigns: %{valid_signature: true}} = conn, params) do
|
|||
json(conn, "ok")
|
||||
end
|
||||
|
||||
def inbox(%{assigns: %{valid_signature: false}} = conn, _params) do
|
||||
conn
|
||||
|> put_status(:bad_request)
|
||||
|> json("Invalid HTTP Signature")
|
||||
end
|
||||
|
||||
# POST /relay/inbox -or- POST /internal/fetch/inbox
|
||||
def inbox(conn, params) do
|
||||
if params["type"] == "Create" && FederatingPlug.federating?() do
|
||||
def inbox(conn, %{"type" => "Create"} = params) do
|
||||
if FederatingPlug.federating?() do
|
||||
post_inbox_relayed_create(conn, params)
|
||||
else
|
||||
post_inbox_fallback(conn, params)
|
||||
conn
|
||||
|> put_status(:bad_request)
|
||||
|> json("Not federating")
|
||||
end
|
||||
end
|
||||
|
||||
def inbox(conn, _params) do
|
||||
conn
|
||||
|> put_status(:bad_request)
|
||||
|> json("error, missing HTTP Signature")
|
||||
end
|
||||
|
||||
defp post_inbox_relayed_create(conn, params) do
|
||||
Logger.debug(
|
||||
"Signature missing or not from author, relayed Create message, fetching object from source"
|
||||
|
@ -303,23 +316,6 @@ defp post_inbox_relayed_create(conn, params) do
|
|||
json(conn, "ok")
|
||||
end
|
||||
|
||||
defp post_inbox_fallback(conn, params) do
|
||||
headers = Enum.into(conn.req_headers, %{})
|
||||
|
||||
if headers["signature"] && params["actor"] &&
|
||||
String.contains?(headers["signature"], params["actor"]) do
|
||||
Logger.debug(
|
||||
"Signature validation error for: #{params["actor"]}, make sure you are forwarding the HTTP Host header!"
|
||||
)
|
||||
|
||||
Logger.debug(inspect(conn.req_headers))
|
||||
end
|
||||
|
||||
conn
|
||||
|> put_status(:bad_request)
|
||||
|> json(dgettext("errors", "error"))
|
||||
end
|
||||
|
||||
defp represent_service_actor(%User{} = user, conn) do
|
||||
with {:ok, user} <- User.ensure_keys_present(user) do
|
||||
conn
|
||||
|
@ -403,83 +399,90 @@ def read_inbox(%{assigns: %{user: %User{nickname: as_nickname}}} = conn, %{
|
|||
|> json(err)
|
||||
end
|
||||
|
||||
defp handle_user_activity(
|
||||
%User{} = user,
|
||||
%{"type" => "Create", "object" => %{"type" => "Note"} = object} = params
|
||||
) do
|
||||
content = if is_binary(object["content"]), do: object["content"], else: ""
|
||||
name = if is_binary(object["name"]), do: object["name"], else: ""
|
||||
summary = if is_binary(object["summary"]), do: object["summary"], else: ""
|
||||
length = String.length(content <> name <> summary)
|
||||
defp fix_user_message(%User{ap_id: actor}, %{"type" => "Create", "object" => object} = activity)
|
||||
when is_map(object) do
|
||||
length =
|
||||
[object["content"], object["summary"], object["name"]]
|
||||
|> Enum.filter(&is_binary(&1))
|
||||
|> Enum.join("")
|
||||
|> String.length()
|
||||
|
||||
if length > Pleroma.Config.get([:instance, :limit]) do
|
||||
{:error, dgettext("errors", "Note is over the character limit")}
|
||||
else
|
||||
limit = Pleroma.Config.get([:instance, :limit])
|
||||
|
||||
if length < limit do
|
||||
object =
|
||||
object
|
||||
|> Map.merge(Map.take(params, ["to", "cc"]))
|
||||
|> Map.put("attributedTo", user.ap_id)
|
||||
|> Transmogrifier.fix_object()
|
||||
|> Transmogrifier.strip_internal_fields()
|
||||
|> Map.put("attributedTo", actor)
|
||||
|> Map.put("actor", actor)
|
||||
|> Map.put("id", Utils.generate_object_id())
|
||||
|
||||
ActivityPub.create(%{
|
||||
to: params["to"],
|
||||
actor: user,
|
||||
context: object["context"],
|
||||
object: object,
|
||||
additional: Map.take(params, ["cc"])
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
defp handle_user_activity(%User{} = user, %{"type" => "Delete"} = params) do
|
||||
with %Object{} = object <- Object.normalize(params["object"], fetch: false),
|
||||
true <- user.is_moderator || user.ap_id == object.data["actor"],
|
||||
{:ok, delete_data, _} <- Builder.delete(user, object.data["id"]),
|
||||
{:ok, delete, _} <- Pipeline.common_pipeline(delete_data, local: true) do
|
||||
{:ok, delete}
|
||||
{:ok, Map.put(activity, "object", object)}
|
||||
else
|
||||
_ -> {:error, dgettext("errors", "Can't delete object")}
|
||||
{:error,
|
||||
dgettext(
|
||||
"errors",
|
||||
"Character limit (%{limit} characters) exceeded, contains %{length} characters",
|
||||
limit: limit,
|
||||
length: length
|
||||
)}
|
||||
end
|
||||
end
|
||||
|
||||
defp handle_user_activity(%User{} = user, %{"type" => "Like"} = params) do
|
||||
with %Object{} = object <- Object.normalize(params["object"], fetch: false),
|
||||
{_, {:ok, like_object, meta}} <- {:build_object, Builder.like(user, object)},
|
||||
{_, {:ok, %Activity{} = activity, _meta}} <-
|
||||
{:common_pipeline,
|
||||
Pipeline.common_pipeline(like_object, Keyword.put(meta, :local, true))} do
|
||||
defp fix_user_message(
|
||||
%User{ap_id: actor} = user,
|
||||
%{"type" => "Delete", "object" => object} = activity
|
||||
) do
|
||||
with {_, %Object{data: object_data}} <- {:normalize, Object.normalize(object, fetch: false)},
|
||||
{_, true} <- {:permission, user.is_moderator || actor == object_data["actor"]} do
|
||||
{:ok, activity}
|
||||
else
|
||||
_ -> {:error, dgettext("errors", "Can't like object")}
|
||||
{:normalize, _} ->
|
||||
{:error, "No such object found"}
|
||||
|
||||
{:permission, _} ->
|
||||
{:forbidden, "You can't delete this object"}
|
||||
end
|
||||
end
|
||||
|
||||
defp handle_user_activity(_, _) do
|
||||
{:error, dgettext("errors", "Unhandled activity type")}
|
||||
defp fix_user_message(%User{}, activity) do
|
||||
{:ok, activity}
|
||||
end
|
||||
|
||||
def update_outbox(
|
||||
%{assigns: %{user: %User{nickname: nickname} = user}} = conn,
|
||||
%{assigns: %{user: %User{nickname: nickname, ap_id: actor} = user}} = conn,
|
||||
%{"nickname" => nickname} = params
|
||||
) do
|
||||
actor = user.ap_id
|
||||
|
||||
params =
|
||||
params
|
||||
|> Map.drop(["id"])
|
||||
|> Map.drop(["nickname"])
|
||||
|> Map.put("id", Utils.generate_activity_id())
|
||||
|> Map.put("actor", actor)
|
||||
|> Transmogrifier.fix_addressing()
|
||||
|
||||
with {:ok, %Activity{} = activity} <- handle_user_activity(user, params) do
|
||||
with {:ok, params} <- fix_user_message(user, params),
|
||||
{:ok, activity, _} <- Pipeline.common_pipeline(params, local: true),
|
||||
%Activity{data: activity_data} <- Activity.normalize(activity) do
|
||||
conn
|
||||
|> put_status(:created)
|
||||
|> put_resp_header("location", activity.data["id"])
|
||||
|> json(activity.data)
|
||||
|> put_resp_header("location", activity_data["id"])
|
||||
|> json(activity_data)
|
||||
else
|
||||
{:forbidden, message} ->
|
||||
conn
|
||||
|> put_status(:forbidden)
|
||||
|> json(message)
|
||||
|
||||
{:error, message} ->
|
||||
conn
|
||||
|> put_status(:bad_request)
|
||||
|> json(message)
|
||||
|
||||
e ->
|
||||
Logger.warn(fn -> "AP C2S: #{inspect(e)}" end)
|
||||
|
||||
conn
|
||||
|> put_status(:bad_request)
|
||||
|> json("Bad Request")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ defmodule Pleroma.Web.ActivityPub.Builder do
|
|||
alias Pleroma.Web.ActivityPub.Relay
|
||||
alias Pleroma.Web.ActivityPub.Utils
|
||||
alias Pleroma.Web.ActivityPub.Visibility
|
||||
alias Pleroma.Web.CommonAPI.ActivityDraft
|
||||
|
||||
require Pleroma.Constants
|
||||
|
||||
|
@ -125,6 +126,37 @@ def create(actor, object, recipients) do
|
|||
|> Pleroma.Maps.put_if_present("context", context), []}
|
||||
end
|
||||
|
||||
@spec note(ActivityDraft.t()) :: {:ok, map(), keyword()}
|
||||
def note(%ActivityDraft{} = draft) do
|
||||
data =
|
||||
%{
|
||||
"type" => "Note",
|
||||
"to" => draft.to,
|
||||
"cc" => draft.cc,
|
||||
"content" => draft.content_html,
|
||||
"summary" => draft.summary,
|
||||
"sensitive" => draft.sensitive,
|
||||
"context" => draft.context,
|
||||
"attachment" => draft.attachments,
|
||||
"actor" => draft.user.ap_id,
|
||||
"tag" => Keyword.values(draft.tags) |> Enum.uniq()
|
||||
}
|
||||
|> add_in_reply_to(draft.in_reply_to)
|
||||
|> Map.merge(draft.extra)
|
||||
|
||||
{:ok, data, []}
|
||||
end
|
||||
|
||||
defp add_in_reply_to(object, nil), do: object
|
||||
|
||||
defp add_in_reply_to(object, in_reply_to) do
|
||||
with %Object{} = in_reply_to_object <- Object.normalize(in_reply_to, fetch: false) do
|
||||
Map.put(object, "inReplyTo", in_reply_to_object.data["id"])
|
||||
else
|
||||
_ -> object
|
||||
end
|
||||
end
|
||||
|
||||
def chat_message(actor, recipient, content, opts \\ []) do
|
||||
basic = %{
|
||||
"id" => Utils.generate_object_id(),
|
||||
|
@ -223,7 +255,7 @@ def announce(actor, object, options \\ []) do
|
|||
[actor.follower_address]
|
||||
|
||||
public? and Visibility.is_local_public?(object) ->
|
||||
[actor.follower_address, object.data["actor"], Pleroma.Constants.as_local_public()]
|
||||
[actor.follower_address, object.data["actor"], Utils.as_local_public()]
|
||||
|
||||
public? ->
|
||||
[actor.follower_address, object.data["actor"], Pleroma.Constants.as_public()]
|
||||
|
|
|
@ -21,7 +21,7 @@ defmodule Pleroma.Web.ActivityPub.MRF do
|
|||
type: [:module, {:list, :module}],
|
||||
description:
|
||||
"A list of MRF policies enabled. Module names are shortened (removed leading `Pleroma.Web.ActivityPub.MRF.` part), but on adding custom module you need to use full name.",
|
||||
suggestions: {:list_behaviour_implementations, Pleroma.Web.ActivityPub.MRF}
|
||||
suggestions: {:list_behaviour_implementations, Pleroma.Web.ActivityPub.MRF.Policy}
|
||||
},
|
||||
%{
|
||||
key: :transparency,
|
||||
|
@ -33,9 +33,11 @@ defmodule Pleroma.Web.ActivityPub.MRF do
|
|||
%{
|
||||
key: :transparency_exclusions,
|
||||
label: "MRF transparency exclusions",
|
||||
type: {:list, :string},
|
||||
type: {:list, :tuple},
|
||||
key_placeholder: "instance",
|
||||
value_placeholder: "reason",
|
||||
description:
|
||||
"Exclude specific instance names from MRF transparency. The use of the exclusions feature will be disclosed in nodeinfo as a boolean value.",
|
||||
"Exclude specific instance names from MRF transparency. The use of the exclusions feature will be disclosed in nodeinfo as a boolean value. You can also provide a reason for excluding these instance names. The instances and reasons won't be publicly disclosed.",
|
||||
suggestions: [
|
||||
"exclusion.com"
|
||||
]
|
||||
|
@ -51,17 +53,6 @@ defmodule Pleroma.Web.ActivityPub.MRF do
|
|||
|
||||
@required_description_keys [:key, :related_policy]
|
||||
|
||||
@callback filter(Map.t()) :: {:ok | :reject, Map.t()}
|
||||
@callback describe() :: {:ok | :error, Map.t()}
|
||||
@callback config_description() :: %{
|
||||
optional(:children) => [map()],
|
||||
key: atom(),
|
||||
related_policy: String.t(),
|
||||
label: String.t(),
|
||||
description: String.t()
|
||||
}
|
||||
@optional_callbacks config_description: 0
|
||||
|
||||
def filter(policies, %{} = message) do
|
||||
policies
|
||||
|> Enum.reduce({:ok, message}, fn
|
||||
|
@ -111,6 +102,11 @@ def subdomain_match?(domains, host) do
|
|||
Enum.any?(domains, fn domain -> Regex.match?(domain, host) end)
|
||||
end
|
||||
|
||||
@spec instance_list_from_tuples([{String.t(), String.t()}]) :: [String.t()]
|
||||
def instance_list_from_tuples(list) do
|
||||
Enum.map(list, fn {instance, _} -> instance end)
|
||||
end
|
||||
|
||||
def describe(policies) do
|
||||
{:ok, policy_configs} =
|
||||
policies
|
||||
|
@ -142,7 +138,7 @@ def describe(policies) do
|
|||
def describe, do: get_policies() |> describe()
|
||||
|
||||
def config_descriptions do
|
||||
Pleroma.Web.ActivityPub.MRF
|
||||
Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|> Pleroma.Docs.Generator.list_behaviour_implementations()
|
||||
|> config_descriptions()
|
||||
end
|
||||
|
@ -161,9 +157,7 @@ def config_descriptions(policies) do
|
|||
[description | acc]
|
||||
else
|
||||
Logger.warn(
|
||||
"#{policy} config description doesn't have one or all required keys #{
|
||||
inspect(@required_description_keys)
|
||||
}"
|
||||
"#{policy} config description doesn't have one or all required keys #{inspect(@required_description_keys)}"
|
||||
)
|
||||
|
||||
acc
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
defmodule Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy do
|
||||
@moduledoc "Adds expiration to all local Create activities"
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|
||||
@impl true
|
||||
def filter(activity) do
|
||||
|
|
|
@ -7,7 +7,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy do
|
|||
|
||||
@moduledoc "Prevent followbots from following with a bit of heuristic"
|
||||
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|
||||
# XXX: this should become User.normalize_by_ap_id() or similar, really.
|
||||
defp normalize_by_ap_id(%{"id" => id}), do: User.get_cached_by_ap_id(id)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy do
|
||||
alias Pleroma.User
|
||||
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|
||||
require Logger
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
defmodule Pleroma.Web.ActivityPub.MRF.DropPolicy do
|
||||
require Logger
|
||||
@moduledoc "Drop and log everything received"
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|
||||
@impl true
|
||||
def filter(object) do
|
||||
|
|
|
@ -6,7 +6,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.EnsureRePrepended do
|
|||
alias Pleroma.Object
|
||||
|
||||
@moduledoc "Ensure a re: is prepended on replies to a post with a Subject"
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF.Policy
|
||||
|
||||
@reply_prefix Regex.compile!("^re:[[:space:]]*", [:caseless])
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue