Merge remote-tracking branch 'origin/develop' into shigusegubu
* origin/develop: (566 commits) Fix MRF reject for ChatMessage Create MRF.filter_pipeline to inject :object_data when present KeywordPolicy: Still match when fields are absent pleroma-fe bundle: bump to b225c3578f3c89af5ed3a0be3f8f3a6bbcedcc7d CHANGELOG.md: Add 2.1.2 entry mix.exs: bump version to 2.1.2 Merge branch '2130-mfa-users-oauth-login-fix' into 'develop' Merge branch 'fix/streaming-termination-errors' into 'develop' Merge branch 'fix/mrf-simple-welcome-chats' into 'develop' Merge branch 'reply-visibility-user-guard' into 'develop' Merge branch 'bugfix/mrf-ingestion' into 'develop' adapt to new user factory behavior add test and changelog entry User search respect discoverable flag Merge branch 'hotfix/rich-media-compile-error' into 'develop' Merge branch 'feat/rich-media-head' into 'develop' Deny ConfigDB migration when deprecated settings found RichMedia: Fix log spam on failures and resetting TTL on cached errors Return the file content for `GET /api/pleroma/admin/instance_document/:document_name` add description to changelog ...
This commit is contained in:
commit
4174bc6126
598 changed files with 10803 additions and 10594 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -27,8 +27,6 @@ erl_crash.dump
|
|||
# variables.
|
||||
/config/*.secret.exs
|
||||
/config/generated_config.exs
|
||||
/config/*.env
|
||||
|
||||
|
||||
# Database setup file, some may forget to delete it
|
||||
/config/setup_db.psql
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ stages:
|
|||
- docker
|
||||
|
||||
before_script:
|
||||
- apt-get update && apt-get install -y cmake
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
|
||||
|
|
@ -64,19 +65,21 @@ unit-testing:
|
|||
- mix ecto.migrate
|
||||
- mix coveralls --preload-modules
|
||||
|
||||
federated-testing:
|
||||
stage: test
|
||||
cache: *testing_cache_policy
|
||||
services:
|
||||
- name: minibikini/postgres-with-rum:12
|
||||
alias: postgres
|
||||
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
|
||||
script:
|
||||
- mix deps.get
|
||||
- mix ecto.create
|
||||
- mix ecto.migrate
|
||||
- epmd -daemon
|
||||
- mix test --trace --only federated
|
||||
# Removed to fix CI issue. In this early state it wasn't adding much value anyway.
|
||||
# TODO Fix and reinstate federated testing
|
||||
# federated-testing:
|
||||
# stage: test
|
||||
# cache: *testing_cache_policy
|
||||
# services:
|
||||
# - name: minibikini/postgres-with-rum:12
|
||||
# alias: postgres
|
||||
# command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
|
||||
# script:
|
||||
# - mix deps.get
|
||||
# - mix ecto.create
|
||||
# - mix ecto.migrate
|
||||
# - epmd -daemon
|
||||
# - mix test --trace --only federated
|
||||
|
||||
unit-testing-rum:
|
||||
stage: test
|
||||
|
|
@ -193,6 +196,7 @@ amd64:
|
|||
variables: &release-variables
|
||||
MIX_ENV: prod
|
||||
before_script: &before-release
|
||||
- apt-get update && apt-get install -y cmake
|
||||
- echo "import Mix.Config" > config/prod.secret.exs
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
|
|
@ -211,7 +215,7 @@ amd64-musl:
|
|||
cache: *release-cache
|
||||
variables: *release-variables
|
||||
before_script: &before-release-musl
|
||||
- apk add git gcc g++ musl-dev make
|
||||
- apk add git gcc g++ musl-dev make cmake
|
||||
- echo "import Mix.Config" > config/prod.secret.exs
|
||||
- mix local.hex --force
|
||||
- mix local.rebar --force
|
||||
|
|
@ -278,6 +282,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
|
||||
before_script: &before-docker
|
||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
||||
- docker pull $IMAGE_TAG_SLUG || true
|
||||
|
|
@ -285,10 +291,14 @@ docker:
|
|||
- export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
|
||||
allow_failure: true
|
||||
script:
|
||||
- docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST .
|
||||
- docker push $IMAGE_TAG
|
||||
- docker push $IMAGE_TAG_SLUG
|
||||
- docker push $IMAGE_TAG_LATEST
|
||||
- mkdir -p /root/.docker/cli-plugins
|
||||
- wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
|
||||
- echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
|
||||
- chmod +x ~/.docker/cli-plugins/docker-buildx
|
||||
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
- docker buildx create --name mbuilder --driver docker-container --use
|
||||
- docker buildx inspect --bootstrap
|
||||
- docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64/v8 --push --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST .
|
||||
tags:
|
||||
- dind
|
||||
only:
|
||||
|
|
@ -303,10 +313,14 @@ docker-stable:
|
|||
before_script: *before-docker
|
||||
allow_failure: true
|
||||
script:
|
||||
- docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST_STABLE .
|
||||
- docker push $IMAGE_TAG
|
||||
- docker push $IMAGE_TAG_SLUG
|
||||
- docker push $IMAGE_TAG_LATEST_STABLE
|
||||
- mkdir -p /root/.docker/cli-plugins
|
||||
- wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
|
||||
- echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
|
||||
- chmod +x ~/.docker/cli-plugins/docker-buildx
|
||||
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
- docker buildx create --name mbuilder --driver docker-container --use
|
||||
- docker buildx inspect --bootstrap
|
||||
- docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64/v8 --push --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST_STABLE .
|
||||
tags:
|
||||
- dind
|
||||
only:
|
||||
|
|
@ -321,9 +335,15 @@ docker-release:
|
|||
before_script: *before-docker
|
||||
allow_failure: true
|
||||
script:
|
||||
- docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG .
|
||||
- docker push $IMAGE_TAG
|
||||
- docker push $IMAGE_TAG_SLUG
|
||||
script:
|
||||
- mkdir -p /root/.docker/cli-plugins
|
||||
- wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
|
||||
- echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
|
||||
- chmod +x ~/.docker/cli-plugins/docker-buildx
|
||||
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
|
||||
- docker buildx create --name mbuilder --driver docker-container --use
|
||||
- docker buildx inspect --bootstrap
|
||||
- docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64/v8 --push --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG .
|
||||
tags:
|
||||
- dind
|
||||
only:
|
||||
|
|
|
|||
|
|
@ -3,3 +3,4 @@
|
|||
* [ ] Compile a changelog
|
||||
* [ ] Create an MR with an announcement to pleroma.social
|
||||
* [ ] Tag the release
|
||||
* [ ] Merge `stable` into `develop` (in case the fixes are already in develop, use `git merge -s ours --no-commit` and manually merge the changelogs)
|
||||
|
|
|
|||
395
CC-BY-4.0
Normal file
395
CC-BY-4.0
Normal file
|
|
@ -0,0 +1,395 @@
|
|||
Attribution 4.0 International
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
||||
does not provide legal services or legal advice. Distribution of
|
||||
Creative Commons public licenses does not create a lawyer-client or
|
||||
other relationship. Creative Commons makes its licenses and related
|
||||
information available on an "as-is" basis. Creative Commons gives no
|
||||
warranties regarding its licenses, any material licensed under their
|
||||
terms and conditions, or any related information. Creative Commons
|
||||
disclaims all liability for damages resulting from their use to the
|
||||
fullest extent possible.
|
||||
|
||||
Using Creative Commons Public Licenses
|
||||
|
||||
Creative Commons public licenses provide a standard set of terms and
|
||||
conditions that creators and other rights holders may use to share
|
||||
original works of authorship and other material subject to copyright
|
||||
and certain other rights specified in the public license below. The
|
||||
following considerations are for informational purposes only, are not
|
||||
exhaustive, and do not form part of our licenses.
|
||||
|
||||
Considerations for licensors: Our public licenses are
|
||||
intended for use by those authorized to give the public
|
||||
permission to use material in ways otherwise restricted by
|
||||
copyright and certain other rights. Our licenses are
|
||||
irrevocable. Licensors should read and understand the terms
|
||||
and conditions of the license they choose before applying it.
|
||||
Licensors should also secure all rights necessary before
|
||||
applying our licenses so that the public can reuse the
|
||||
material as expected. Licensors should clearly mark any
|
||||
material not subject to the license. This includes other CC-
|
||||
licensed material, or material used under an exception or
|
||||
limitation to copyright. More considerations for licensors:
|
||||
wiki.creativecommons.org/Considerations_for_licensors
|
||||
|
||||
Considerations for the public: By using one of our public
|
||||
licenses, a licensor grants the public permission to use the
|
||||
licensed material under specified terms and conditions. If
|
||||
the licensor's permission is not necessary for any reason--for
|
||||
example, because of any applicable exception or limitation to
|
||||
copyright--then that use is not regulated by the license. Our
|
||||
licenses grant only permissions under copyright and certain
|
||||
other rights that a licensor has authority to grant. Use of
|
||||
the licensed material may still be restricted for other
|
||||
reasons, including because others have copyright or other
|
||||
rights in the material. A licensor may make special requests,
|
||||
such as asking that all changes be marked or described.
|
||||
Although not required by our licenses, you are encouraged to
|
||||
respect those requests where reasonable. More considerations
|
||||
for the public:
|
||||
wiki.creativecommons.org/Considerations_for_licensees
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons Attribution 4.0 International Public License
|
||||
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution 4.0 International Public License ("Public License"). To the
|
||||
extent this Public License may be interpreted as a contract, You are
|
||||
granted the Licensed Rights in consideration of Your acceptance of
|
||||
these terms and conditions, and the Licensor grants You such rights in
|
||||
consideration of benefits the Licensor receives from making the
|
||||
Licensed Material available under these terms and conditions.
|
||||
|
||||
|
||||
Section 1 -- Definitions.
|
||||
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Adapter's License means the license You apply to Your Copyright
|
||||
and Similar Rights in Your contributions to Adapted Material in
|
||||
accordance with the terms and conditions of this Public License.
|
||||
|
||||
c. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
d. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
e. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
f. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
g. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
h. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
i. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part; and
|
||||
|
||||
b. produce, reproduce, and Share Adapted Material.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material (including in modified
|
||||
form), You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
4. If You Share Adapted Material You produce, the Adapter's
|
||||
License You apply must not prevent recipients of the Adapted
|
||||
Material from complying with this Public License.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
|
||||
=======================================================================
|
||||
|
||||
Creative Commons is not a party to its public
|
||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
||||
its public licenses to material it publishes and in those instances
|
||||
will be considered the “Licensor.” The text of the Creative Commons
|
||||
public licenses is dedicated to the public domain under the CC0 Public
|
||||
Domain Dedication. Except for the limited purpose of indicating that
|
||||
material is shared under a Creative Commons public license or as
|
||||
otherwise permitted by the Creative Commons policies published at
|
||||
creativecommons.org/policies, Creative Commons does not authorize the
|
||||
use of the trademark "Creative Commons" or any other trademark or logo
|
||||
of Creative Commons without its prior written consent including,
|
||||
without limitation, in connection with any unauthorized modifications
|
||||
to any of its public licenses or any other arrangements,
|
||||
understandings, or agreements concerning use of licensed material. For
|
||||
the avoidance of doubt, this paragraph does not form part of the
|
||||
public licenses.
|
||||
|
||||
Creative Commons may be contacted at creativecommons.org.
|
||||
174
CHANGELOG.md
174
CHANGELOG.md
|
|
@ -3,18 +3,93 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
## [unreleased]
|
||||
## Unreleased
|
||||
|
||||
### Changed
|
||||
|
||||
- Renamed `:await_up_timeout` in `:connections_pool` namespace to `:connect_timeout`, old name is deprecated.
|
||||
- Renamed `:timeout` in `pools` namespace to `:recv_timeout`, old name is deprecated.
|
||||
- The `discoverable` field in the `User` struct will now add a NOINDEX metatag to profile pages when false.
|
||||
- Users with the `discoverable` field set to false will not show up in searches.
|
||||
- Minimum lifetime for ephmeral activities changed to 10 minutes and made configurable (`:min_lifetime` option).
|
||||
### Removed
|
||||
|
||||
- **Breaking:** `Pleroma.Workers.Cron.StatsWorker` setting from Oban `:crontab` (moved to a simpler implementation).
|
||||
- **Breaking:** `Pleroma.Workers.Cron.ClearOauthTokenWorker` setting from Oban `:crontab` (moved to scheduled jobs).
|
||||
- **Breaking:** `Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker` setting from Oban `:crontab` (moved to scheduled jobs).
|
||||
- Removed `:managed_config` option. In practice, it was accidentally removed with 2.0.0 release when frontends were
|
||||
switched to a new configuration mechanism, however it was not officially removed until now.
|
||||
|
||||
## [2.1.2] - 2020-09-17
|
||||
|
||||
### Security
|
||||
|
||||
- Fix most MRF rules either crashing or not being applied to objects passed into the Common Pipeline (ChatMessage, Question, Answer, Audio, Event).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Welcome Chat messages preventing user registration with MRF Simple Policy applied to the local instance.
|
||||
- Mastodon API: the public timeline returning an error when the `reply_visibility` parameter is set to `self` for an unauthenticated user.
|
||||
- Mastodon Streaming API: Handler crashes on authentication failures, resulting in error logs.
|
||||
- Mastodon Streaming API: Error logs on client pings.
|
||||
- Rich media: Log spam on failures. Now the error is only logged once per attempt.
|
||||
|
||||
### Changed
|
||||
|
||||
- Rich Media: A HEAD request is now done to the url, to ensure it has the appropriate content type and size before proceeding with a GET.
|
||||
|
||||
### Upgrade notes
|
||||
|
||||
1. Restart Pleroma
|
||||
|
||||
## [2.1.1] - 2020-09-08
|
||||
|
||||
### Security
|
||||
- Fix possible DoS in Mastodon API user search due to an error in match clauses, leading to an infinite recursion and subsequent OOM with certain inputs.
|
||||
- Fix metadata leak for accounts and statuses on private instances.
|
||||
- Fix possible DoS in Admin API search using an atom leak vulnerability. Authentication with admin rights was required to exploit.
|
||||
|
||||
### Changed
|
||||
|
||||
- **Breaking:** The metadata providers RelMe and Feed are no longer configurable. RelMe should always be activated and Feed only provides a <link> header tag for the actual RSS/Atom feed when the instance is public.
|
||||
- Improved error message when cmake is not available at build stage.
|
||||
|
||||
### Added
|
||||
- Rich media failure tracking (along with `:failure_backoff` option).
|
||||
|
||||
<details>
|
||||
<summary>Admin API Changes</summary>
|
||||
|
||||
- Add `PATCH /api/pleroma/admin/instance_document/:document_name` to modify the Terms of Service and Instance Panel HTML pages via Admin API
|
||||
</details>
|
||||
|
||||
### Fixed
|
||||
- Default HTTP adapter not respecting pool setting, leading to possible OOM.
|
||||
- Fixed uploading webp images when the Exiftool Upload Filter is enabled by skipping them
|
||||
- Mastodon API: Search parameter `following` now correctly returns the followings rather than the followers
|
||||
- Mastodon API: Timelines hanging for (`number of posts with links * rich media timeout`) in the worst case.
|
||||
Reduced to just rich media timeout.
|
||||
- Mastodon API: Cards being wrong for preview statuses due to cache key collision.
|
||||
- Password resets no longer processed for deactivated accounts.
|
||||
- Favicon scraper raising exceptions on URLs longer than 255 characters.
|
||||
|
||||
## [2.1.0] - 2020-08-28
|
||||
|
||||
### Changed
|
||||
|
||||
- **Breaking:** The default descriptions on uploads are now empty. The old behavior (filename as default) can be configured, see the cheat sheet.
|
||||
- **Breaking:** Added the ObjectAgePolicy to the default set of MRFs. This will delist and strip the follower collection of any message received that is older than 7 days. This will stop users from seeing very old messages in the timelines. The messages can still be viewed on the user's page and in conversations. They also still trigger notifications.
|
||||
- **Breaking:** Elixir >=1.9 is now required (was >= 1.8)
|
||||
- **Breaking:** Configuration: `:auto_linker, :opts` moved to `:pleroma, Pleroma.Formatter`. Old config namespace is deprecated.
|
||||
- **Breaking:** Configuration: `:instance, welcome_user_nickname` moved to `:welcome, :direct_message, :sender_nickname`, `:instance, :welcome_message` moved to `:welcome, :direct_message, :message`. Old config namespace is deprecated.
|
||||
- **Breaking:** LDAP: Fallback to local database authentication has been removed for security reasons and lack of a mechanism to ensure the passwords are synchronized when LDAP passwords are updated.
|
||||
- **Breaking** Changed defaults for `:restrict_unauthenticated` so that when `:instance, :public` is set to `false` then all `:restrict_unauthenticated` items be effectively set to `true`. If you'd like to allow unauthenticated access to specific API endpoints on a private instance, please explicitly set `:restrict_unauthenticated` to non-default value in `config/prod.secret.exs`.
|
||||
- In Conversations, return only direct messages as `last_status`
|
||||
- Using the `only_media` filter on timelines will now exclude reblog media
|
||||
- MFR policy to set global expiration for all local Create activities
|
||||
- OGP rich media parser merged with TwitterCard
|
||||
- Configuration: `:instance, rewrite_policy` moved to `:mrf, policies`, `:instance, :mrf_transparency` moved to `:mrf, :transparency`, `:instance, :mrf_transparency_exclusions` moved to `:mrf, :transparency_exclusions`. Old config namespace is deprecated.
|
||||
- Configuration: `:media_proxy, whitelist` format changed to host with scheme (e.g. `http://example.com` instead of `example.com`). Domain format is deprecated.
|
||||
- **Breaking:** Configuration: `:instance, welcome_user_nickname` moved to `:welcome, :direct_message, :sender_nickname`, `:instance, :welcome_message` moved to `:welcome, :direct_message, :message`. Old config namespace is deprecated.
|
||||
|
||||
<details>
|
||||
<summary>API Changes</summary>
|
||||
|
|
@ -22,33 +97,38 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- **Breaking:** Pleroma API: The routes to update avatar, banner and background have been removed.
|
||||
- **Breaking:** Image description length is limited now.
|
||||
- **Breaking:** Emoji API: changed methods and renamed routes.
|
||||
- **Breaking:** Notification Settings API for suppressing notifications has been simplified down to `block_from_strangers`.
|
||||
- **Breaking:** Notification Settings API option for hiding push notification contents has been renamed to `hide_notification_contents`.
|
||||
- MastodonAPI: Allow removal of avatar, banner and background.
|
||||
- Streaming: Repeats of a user's posts will no longer be pushed to the user's stream.
|
||||
- Mastodon API: Added `pleroma.metadata.fields_limits` to /api/v1/instance
|
||||
- Mastodon API: On deletion, returns the original post text.
|
||||
- Mastodon API: Add `pleroma.unread_count` to the Marker entity.
|
||||
- **Breaking:** Notification Settings API for suppressing notifications
|
||||
has been simplified down to `block_from_strangers`.
|
||||
- **Breaking:** Notification Settings API option for hiding push notification
|
||||
contents has been renamed to `hide_notification_contents`
|
||||
- Mastodon API: Added `pleroma.metadata.post_formats` to /api/v1/instance
|
||||
- Mastodon API (legacy): Allow query parameters for `/api/v1/domain_blocks`, e.g. `/api/v1/domain_blocks?domain=badposters.zone`
|
||||
- Mastodon API: Make notifications about statuses from muted users and threads read automatically
|
||||
- Pleroma API: `/api/pleroma/captcha` responses now include `seconds_valid` with an integer value.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Admin API Changes</summary>
|
||||
|
||||
- **Breaking** Changed relay `/api/pleroma/admin/relay` endpoints response format.
|
||||
- Status visibility stats: now can return stats per instance.
|
||||
|
||||
- Mix task to refresh counter cache (`mix pleroma.refresh_counter_cache`)
|
||||
|
||||
</details>
|
||||
|
||||
### Removed
|
||||
|
||||
- **Breaking:** removed `with_move` parameter from notifications timeline.
|
||||
|
||||
### Added
|
||||
|
||||
- Frontends: Add mix task to install frontends.
|
||||
- Frontends: Add configurable frontends for primary and admin fe.
|
||||
- Configuration: Added a blacklist for email servers.
|
||||
- Chats: Added `accepts_chat_messages` field to user, exposed in APIs and federation.
|
||||
- Chats: Added support for federated chats. For details, see the docs.
|
||||
- ActivityPub: Added support for existing AP ids for instances migrated from Mastodon.
|
||||
|
|
@ -69,7 +149,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Support for viewing instances favicons next to posts and accounts
|
||||
- Added Pleroma.Upload.Filter.Exiftool as an alternate EXIF stripping mechanism targeting GPS/location metadata.
|
||||
- "By approval" registrations mode.
|
||||
- Configuration: Added `:welcome` settings for the welcome message to newly registered users.
|
||||
- Configuration: Added `:welcome` settings for the welcome message to newly registered users. You can send a welcome message as a direct message, chat or email.
|
||||
- Ability to hide favourites and emoji reactions in the API with `[:instance, :show_reactions]` config.
|
||||
|
||||
<details>
|
||||
|
|
@ -89,6 +169,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
</details>
|
||||
|
||||
### Fixed
|
||||
- Fix list pagination and other list issues.
|
||||
- Support pagination in conversations API
|
||||
- **Breaking**: SimplePolicy `:reject` and `:accept` allow deletions again
|
||||
- Fix follower/blocks import when nicknames starts with @
|
||||
|
|
@ -101,12 +182,82 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Fix CSP policy generation to include remote Captcha services
|
||||
- Fix edge case where MediaProxy truncates media, usually caused when Caddy is serving content for the other Federated instance.
|
||||
- Emoji Packs could not be listed when instance was set to `public: false`
|
||||
- Fix whole_word always returning false on filter get requests
|
||||
- Migrations not working on OTP releases if the database was connected over ssl
|
||||
- Fix relay following
|
||||
|
||||
## [Unreleased (patch)]
|
||||
## [2.0.7] - 2020-06-13
|
||||
|
||||
### Security
|
||||
- Fix potential DoSes exploiting atom leaks in rich media parser and the `UserAllowListPolicy` MRF policy
|
||||
|
||||
### Fixed
|
||||
- CSP: not allowing images/media from every host when mediaproxy is disabled
|
||||
- CSP: not adding mediaproxy base url to image/media hosts
|
||||
- StaticFE missing the CSS file
|
||||
|
||||
### Upgrade notes
|
||||
|
||||
1. Restart Pleroma
|
||||
|
||||
## [2.0.6] - 2020-06-09
|
||||
|
||||
### Security
|
||||
- CSP: harden `image-src` and `media-src` when MediaProxy is used
|
||||
|
||||
### Fixed
|
||||
- AP C2S: Fix pagination in inbox/outbox
|
||||
- Various compilation errors on OTP 23
|
||||
- Mastodon API streaming: Repeats from muted threads not being filtered
|
||||
|
||||
### Changed
|
||||
- Various database performance improvements
|
||||
|
||||
### Upgrade notes
|
||||
1. Run database migrations (inside Pleroma directory):
|
||||
- OTP: `./bin/pleroma_ctl migrate`
|
||||
- From Source: `mix ecto.migrate`
|
||||
2. Restart Pleroma
|
||||
|
||||
## [2.0.5] - 2020-05-13
|
||||
|
||||
### Security
|
||||
- Fix possible private status leaks in Mastodon Streaming API
|
||||
|
||||
### Fixed
|
||||
- Crashes when trying to block a user if block federation is disabled
|
||||
- Not being able to start the instance without `erlang-eldap` installed
|
||||
- Users with bios over the limit getting rejected
|
||||
- Follower counters not being updated on incoming follow accepts
|
||||
|
||||
### Upgrade notes
|
||||
|
||||
1. Restart Pleroma
|
||||
|
||||
## [2.0.4] - 2020-05-10
|
||||
|
||||
### Security
|
||||
- AP C2S: Fix a potential DoS by creating nonsensical objects that break timelines
|
||||
|
||||
### Fixed
|
||||
- Peertube user lookups not working
|
||||
- `InsertSkeletonsForDeletedUsers` migration failing on some instances
|
||||
- Healthcheck reporting the number of memory currently used, rather than allocated in total
|
||||
- `InsertSkeletonsForDeletedUsers` failing on some instances
|
||||
- LDAP not being usable in OTP releases
|
||||
- Default apache configuration having tls chain issues
|
||||
|
||||
### Upgrade notes
|
||||
|
||||
#### Apache only
|
||||
|
||||
1. Remove the following line from your config:
|
||||
```
|
||||
SSLCertificateFile /etc/letsencrypt/live/${servername}/cert.pem
|
||||
```
|
||||
|
||||
#### Everyone
|
||||
|
||||
1. Restart Pleroma
|
||||
|
||||
## [2.0.3] - 2020-05-02
|
||||
|
||||
|
|
@ -130,7 +281,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Follow request notifications
|
||||
<details>
|
||||
<summary>API Changes</summary>
|
||||
|
||||
- Admin API: `GET /api/pleroma/admin/need_reboot`.
|
||||
</details>
|
||||
|
||||
|
|
@ -165,6 +315,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||
- Static-FE: Fix remote posts not being sanitized
|
||||
|
||||
### Fixed
|
||||
=======
|
||||
- Rate limiter crashes when there is no explicitly specified ip in the config
|
||||
- 500 errors when no `Accept` header is present if Static-FE is enabled
|
||||
- Instance panel not being updated immediately due to wrong `Cache-Control` headers
|
||||
- Statuses posted with BBCode/Markdown having unncessary newlines in Pleroma-FE
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ COPY . .
|
|||
|
||||
ENV MIX_ENV=prod
|
||||
|
||||
RUN apk add git gcc g++ musl-dev make &&\
|
||||
RUN apk add git gcc g++ musl-dev make cmake &&\
|
||||
echo "import Mix.Config" > config/prod.secret.exs &&\
|
||||
mix local.hex --force &&\
|
||||
mix local.rebar --force &&\
|
||||
|
|
@ -31,7 +31,7 @@ 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 &&\
|
||||
RUN echo "https://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories &&\
|
||||
apk update &&\
|
||||
apk add exiftool imagemagick ncurses postgresql-client &&\
|
||||
adduser --system --shell /bin/false --home ${HOME} pleroma &&\
|
||||
|
|
|
|||
16
SECURITY.md
Normal file
16
SECURITY.md
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Pleroma backend security policy
|
||||
|
||||
## Supported versions
|
||||
|
||||
Currently, Pleroma offers bugfixes and security patches only for the latest minor release.
|
||||
|
||||
| Version | Support
|
||||
|---------| --------
|
||||
| 2.1 | Bugfixes and security patches
|
||||
|
||||
## Reporting a vulnerability
|
||||
|
||||
Please use confidential issues (tick the "This issue is confidential and should only be visible to team members with at least Reporter access." box when submitting) at our [bugtracker](https://git.pleroma.social/pleroma/pleroma/-/issues/new) for reporting vulnerabilities.
|
||||
## Announcements
|
||||
|
||||
New releases are announced at [pleroma.social](https://pleroma.social/announcements/). All security releases are tagged with ["Security"](https://pleroma.social/announcements/tags/security/). You can be notified of them by subscribing to an Atom feed at <https://pleroma.social/announcements/tags/security/feed.xml>.
|
||||
|
|
@ -72,7 +72,8 @@ config :pleroma, Pleroma.Upload,
|
|||
pool: :upload
|
||||
]
|
||||
],
|
||||
filename_display_max_length: 30
|
||||
filename_display_max_length: 30,
|
||||
default_description: nil
|
||||
|
||||
config :pleroma, Pleroma.Uploaders.Local, uploads: "uploads"
|
||||
|
||||
|
|
@ -215,7 +216,6 @@ config :pleroma, :instance,
|
|||
allow_relay: true,
|
||||
public: true,
|
||||
quarantined_instances: ["pleroma.rareome.ga"],
|
||||
managed_config: true,
|
||||
static_dir: "instance/static/",
|
||||
allowed_post_formats: [
|
||||
"text/plain",
|
||||
|
|
@ -259,6 +259,11 @@ config :pleroma, :welcome,
|
|||
sender_nickname: nil,
|
||||
message: nil
|
||||
],
|
||||
chat_message: [
|
||||
enabled: false,
|
||||
sender_nickname: nil,
|
||||
message: nil
|
||||
],
|
||||
email: [
|
||||
enabled: false,
|
||||
sender: nil,
|
||||
|
|
@ -388,6 +393,7 @@ config :pleroma, :mrf_simple,
|
|||
],
|
||||
report_removal: [],
|
||||
reject: [],
|
||||
followers_only: [],
|
||||
accept: [],
|
||||
avatar_removal: [],
|
||||
banner_removal: [],
|
||||
|
|
@ -406,8 +412,9 @@ config :pleroma, :mrf_vocabulary,
|
|||
accept: [],
|
||||
reject: []
|
||||
|
||||
# threshold of 7 days
|
||||
config :pleroma, :mrf_object_age,
|
||||
threshold: 172_800,
|
||||
threshold: 604_800,
|
||||
actions: [:delist, :strip_followers]
|
||||
|
||||
config :pleroma, :rich_media,
|
||||
|
|
@ -418,6 +425,7 @@ config :pleroma, :rich_media,
|
|||
Pleroma.Web.RichMedia.Parsers.TwitterCard,
|
||||
Pleroma.Web.RichMedia.Parsers.OEmbed
|
||||
],
|
||||
failure_backoff: 60_000,
|
||||
ttl_setters: [Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl]
|
||||
|
||||
config :pleroma, :media_proxy,
|
||||
|
|
@ -459,9 +467,7 @@ config :pleroma, :gopher,
|
|||
config :pleroma, Pleroma.Web.Metadata,
|
||||
providers: [
|
||||
Pleroma.Web.Metadata.Providers.OpenGraph,
|
||||
Pleroma.Web.Metadata.Providers.TwitterCard,
|
||||
Pleroma.Web.Metadata.Providers.RelMe,
|
||||
Pleroma.Web.Metadata.Providers.Feed
|
||||
Pleroma.Web.Metadata.Providers.TwitterCard
|
||||
],
|
||||
unfurl_nsfw: false
|
||||
|
||||
|
|
@ -522,14 +528,22 @@ config :pleroma, Pleroma.User,
|
|||
"user-search",
|
||||
"user_exists",
|
||||
"users",
|
||||
"web"
|
||||
]
|
||||
"web",
|
||||
"verify_credentials",
|
||||
"update_credentials",
|
||||
"relationships",
|
||||
"search",
|
||||
"confirmation_resend",
|
||||
"mfa"
|
||||
],
|
||||
email_blacklist: []
|
||||
|
||||
config :pleroma, Oban,
|
||||
repo: Pleroma.Repo,
|
||||
log: false,
|
||||
queues: [
|
||||
activity_expiration: 10,
|
||||
token_expiration: 5,
|
||||
federator_incoming: 50,
|
||||
federator_outgoing: 50,
|
||||
web_push: 50,
|
||||
|
|
@ -543,9 +557,6 @@ config :pleroma, Oban,
|
|||
],
|
||||
plugins: [Oban.Plugins.Pruner],
|
||||
crontab: [
|
||||
{"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker},
|
||||
{"0 * * * *", Pleroma.Workers.Cron.StatsWorker},
|
||||
{"* * * * *", Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker},
|
||||
{"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker},
|
||||
{"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker}
|
||||
]
|
||||
|
|
@ -656,7 +667,7 @@ config :pleroma, :rate_limit,
|
|||
account_confirmation_resend: {8_640_000, 5},
|
||||
ap_routes: {60_000, 15}
|
||||
|
||||
config :pleroma, Pleroma.ActivityExpiration, enabled: true
|
||||
config :pleroma, Pleroma.Workers.PurgeExpiredActivity, enabled: true, min_lifetime: 600
|
||||
|
||||
config :pleroma, Pleroma.Plugs.RemoteIp, enabled: true
|
||||
|
||||
|
|
@ -670,7 +681,50 @@ config :pleroma, :static_fe, enabled: false
|
|||
# With no frontend configuration, the bundled files from the `static` directory will
|
||||
# be used.
|
||||
#
|
||||
# config :pleroma, :frontends, primary: %{"name" => "pleroma", "ref" => "develop"}
|
||||
# config :pleroma, :frontends,
|
||||
# primary: %{"name" => "pleroma-fe", "ref" => "develop"},
|
||||
# admin: %{"name" => "admin-fe", "ref" => "stable"},
|
||||
# available: %{...}
|
||||
|
||||
config :pleroma, :frontends,
|
||||
available: %{
|
||||
"kenoma" => %{
|
||||
"name" => "kenoma",
|
||||
"git" => "https://git.pleroma.social/lambadalambda/kenoma",
|
||||
"build_url" =>
|
||||
"https://git.pleroma.social/lambadalambda/kenoma/-/jobs/artifacts/${ref}/download?job=build",
|
||||
"ref" => "master"
|
||||
},
|
||||
"pleroma-fe" => %{
|
||||
"name" => "pleroma-fe",
|
||||
"git" => "https://git.pleroma.social/pleroma/pleroma-fe",
|
||||
"build_url" =>
|
||||
"https://git.pleroma.social/pleroma/pleroma-fe/-/jobs/artifacts/${ref}/download?job=build",
|
||||
"ref" => "develop"
|
||||
},
|
||||
"fedi-fe" => %{
|
||||
"name" => "fedi-fe",
|
||||
"git" => "https://git.pleroma.social/pleroma/fedi-fe",
|
||||
"build_url" =>
|
||||
"https://git.pleroma.social/pleroma/fedi-fe/-/jobs/artifacts/${ref}/download?job=build",
|
||||
"ref" => "master"
|
||||
},
|
||||
"admin-fe" => %{
|
||||
"name" => "admin-fe",
|
||||
"git" => "https://git.pleroma.social/pleroma/admin-fe",
|
||||
"build_url" =>
|
||||
"https://git.pleroma.social/pleroma/admin-fe/-/jobs/artifacts/${ref}/download?job=build",
|
||||
"ref" => "develop"
|
||||
},
|
||||
"soapbox-fe" => %{
|
||||
"name" => "soapbox-fe",
|
||||
"git" => "https://gitlab.com/soapbox-pub/soapbox-fe",
|
||||
"build_url" =>
|
||||
"https://gitlab.com/soapbox-pub/soapbox-fe/-/jobs/artifacts/${ref}/download?job=build-production",
|
||||
"ref" => "v1.0.0",
|
||||
"build_dir" => "static"
|
||||
}
|
||||
}
|
||||
|
||||
config :pleroma, :web_cache_ttl,
|
||||
activity_pub: nil,
|
||||
|
|
@ -691,24 +745,28 @@ config :pleroma, :connections_pool,
|
|||
max_connections: 250,
|
||||
max_idle_time: 30_000,
|
||||
retry: 0,
|
||||
await_up_timeout: 5_000
|
||||
connect_timeout: 5_000
|
||||
|
||||
config :pleroma, :pools,
|
||||
federation: [
|
||||
size: 50,
|
||||
max_waiting: 10
|
||||
max_waiting: 10,
|
||||
recv_timeout: 10_000
|
||||
],
|
||||
media: [
|
||||
size: 50,
|
||||
max_waiting: 10
|
||||
max_waiting: 10,
|
||||
recv_timeout: 10_000
|
||||
],
|
||||
upload: [
|
||||
size: 25,
|
||||
max_waiting: 5
|
||||
max_waiting: 5,
|
||||
recv_timeout: 15_000
|
||||
],
|
||||
default: [
|
||||
size: 10,
|
||||
max_waiting: 2
|
||||
max_waiting: 2,
|
||||
recv_timeout: 5_000
|
||||
]
|
||||
|
||||
config :pleroma, :hackney_pools,
|
||||
|
|
@ -725,10 +783,12 @@ config :pleroma, :hackney_pools,
|
|||
timeout: 300_000
|
||||
]
|
||||
|
||||
private_instance? = :if_instance_is_private
|
||||
|
||||
config :pleroma, :restrict_unauthenticated,
|
||||
timelines: %{local: false, federated: false},
|
||||
profiles: %{local: false, remote: false},
|
||||
activities: %{local: false, remote: false}
|
||||
timelines: %{local: private_instance?, federated: private_instance?},
|
||||
profiles: %{local: private_instance?, remote: private_instance?},
|
||||
activities: %{local: private_instance?, remote: private_instance?}
|
||||
|
||||
config :pleroma, Pleroma.Web.ApiSpec.CastAndValidate, strict: false
|
||||
|
||||
|
|
@ -748,6 +808,10 @@ config :ex_aws, http_client: Pleroma.HTTP.ExAws
|
|||
|
||||
config :pleroma, :instances_favicons, enabled: false
|
||||
|
||||
config :floki, :html_parser, Floki.HTMLParser.FastHtml
|
||||
|
||||
config :pleroma, Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.PleromaAuthenticator
|
||||
|
||||
# Import environment specific config. This must remain at the bottom
|
||||
# of this file so it overrides the configuration defined above.
|
||||
import_config "#{Mix.env()}.exs"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,55 @@ websocket_config = [
|
|||
compress: false
|
||||
]
|
||||
|
||||
installed_frontend_options = [
|
||||
%{
|
||||
key: "name",
|
||||
label: "Name",
|
||||
type: :string,
|
||||
description:
|
||||
"Name of the installed frontend. Valid config must include both `Name` and `Reference` values."
|
||||
},
|
||||
%{
|
||||
key: "ref",
|
||||
label: "Reference",
|
||||
type: :string,
|
||||
description:
|
||||
"Reference of the installed frontend to be used. Valid config must include both `Name` and `Reference` values."
|
||||
}
|
||||
]
|
||||
|
||||
frontend_options = [
|
||||
%{
|
||||
key: "name",
|
||||
label: "Name",
|
||||
type: :string,
|
||||
description: "Name of the frontend."
|
||||
},
|
||||
%{
|
||||
key: "ref",
|
||||
label: "Reference",
|
||||
type: :string,
|
||||
description: "Reference of the frontend to be used."
|
||||
},
|
||||
%{
|
||||
key: "git",
|
||||
type: :string,
|
||||
description: "URL of the git repository of the frontend"
|
||||
},
|
||||
%{
|
||||
key: "build_url",
|
||||
type: :string,
|
||||
description:
|
||||
"Either an url to a zip file containing the frontend or a template to build it by inserting the `ref`. The string `${ref}` will be replaced by the configured `ref`.",
|
||||
example: "https://some.url/builds/${ref}.zip"
|
||||
},
|
||||
%{
|
||||
key: "build_dir",
|
||||
type: :string,
|
||||
description: "The directory inside the zip file "
|
||||
}
|
||||
]
|
||||
|
||||
config :pleroma, :config_description, [
|
||||
%{
|
||||
group: :pleroma,
|
||||
|
|
@ -194,7 +243,7 @@ config :pleroma, :config_description, [
|
|||
type: [:string, {:list, :string}, {:list, :tuple}],
|
||||
description:
|
||||
"List of actions for the mogrify command. It's possible to add self-written settings as string. " <>
|
||||
"For example `[\"auto-orient\", \"strip\", {\"resize\", \"3840x1080>\"}]` string will be parsed into list of the settings.",
|
||||
"For example `auto-orient, strip, {\"resize\", \"3840x1080>\"}` value will be parsed into valid list of the settings.",
|
||||
suggestions: [
|
||||
"strip",
|
||||
"auto-orient",
|
||||
|
|
@ -715,12 +764,6 @@ config :pleroma, :config_description, [
|
|||
"*.quarantined.com"
|
||||
]
|
||||
},
|
||||
%{
|
||||
key: :managed_config,
|
||||
type: :boolean,
|
||||
description:
|
||||
"Whenether the config for pleroma-fe is configured in this config or in static/config.json"
|
||||
},
|
||||
%{
|
||||
key: :static_dir,
|
||||
type: :string,
|
||||
|
|
@ -951,7 +994,7 @@ config :pleroma, :config_description, [
|
|||
},
|
||||
%{
|
||||
key: :instance_thumbnail,
|
||||
type: :string,
|
||||
type: {:string, :image},
|
||||
description:
|
||||
"The instance thumbnail can be any image that represents your instance and is used by some apps or services when they display information about your instance.",
|
||||
suggestions: ["/instance/thumbnail.jpeg"]
|
||||
|
|
@ -964,25 +1007,25 @@ config :pleroma, :config_description, [
|
|||
]
|
||||
},
|
||||
%{
|
||||
group: :welcome,
|
||||
group: :pleroma,
|
||||
key: :welcome,
|
||||
type: :group,
|
||||
description: "Welcome messages settings",
|
||||
children: [
|
||||
%{
|
||||
group: :direct_message,
|
||||
type: :group,
|
||||
key: :direct_message,
|
||||
type: :keyword,
|
||||
descpiption: "Direct message settings",
|
||||
children: [
|
||||
%{
|
||||
key: :enabled,
|
||||
type: :boolean,
|
||||
description: "Enables sends direct message for new user after registration"
|
||||
description: "Enables sending a direct message to newly registered users"
|
||||
},
|
||||
%{
|
||||
key: :message,
|
||||
type: :string,
|
||||
description:
|
||||
"A message that will be sent to a newly registered users as a direct message",
|
||||
description: "A message that will be sent to newly registered users",
|
||||
suggestions: [
|
||||
"Hi, @username! Welcome on board!"
|
||||
]
|
||||
|
|
@ -990,7 +1033,7 @@ config :pleroma, :config_description, [
|
|||
%{
|
||||
key: :sender_nickname,
|
||||
type: :string,
|
||||
description: "The nickname of the local user that sends the welcome message",
|
||||
description: "The nickname of the local user that sends a welcome message",
|
||||
suggestions: [
|
||||
"lain"
|
||||
]
|
||||
|
|
@ -998,20 +1041,49 @@ config :pleroma, :config_description, [
|
|||
]
|
||||
},
|
||||
%{
|
||||
group: :email,
|
||||
type: :group,
|
||||
key: :chat_message,
|
||||
type: :keyword,
|
||||
descpiption: "Chat message settings",
|
||||
children: [
|
||||
%{
|
||||
key: :enabled,
|
||||
type: :boolean,
|
||||
description: "Enables sending a chat message to newly registered users"
|
||||
},
|
||||
%{
|
||||
key: :message,
|
||||
type: :string,
|
||||
description:
|
||||
"A message that will be sent to newly registered users as a chat message",
|
||||
suggestions: [
|
||||
"Hello, welcome on board!"
|
||||
]
|
||||
},
|
||||
%{
|
||||
key: :sender_nickname,
|
||||
type: :string,
|
||||
description: "The nickname of the local user that sends a welcome chat message",
|
||||
suggestions: [
|
||||
"lain"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
%{
|
||||
key: :email,
|
||||
type: :keyword,
|
||||
descpiption: "Email message settings",
|
||||
children: [
|
||||
%{
|
||||
key: :enabled,
|
||||
type: :boolean,
|
||||
description: "Enables sends direct message for new user after registration"
|
||||
description: "Enables sending an email to newly registered users"
|
||||
},
|
||||
%{
|
||||
key: :sender,
|
||||
type: [:string, :tuple],
|
||||
description:
|
||||
"The email address or tuple with `{nickname, email}` that will use as sender to the welcome email.",
|
||||
"Email address and/or nickname that will be used to send the welcome email.",
|
||||
suggestions: [
|
||||
{"Pleroma App", "welcome@pleroma.app"}
|
||||
]
|
||||
|
|
@ -1020,21 +1092,21 @@ config :pleroma, :config_description, [
|
|||
key: :subject,
|
||||
type: :string,
|
||||
description:
|
||||
"The subject of welcome email. Can be use EEX template with `user` and `instance_name` variables.",
|
||||
"Subject of the welcome email. EEX template with user and instance_name variables can be used.",
|
||||
suggestions: ["Welcome to <%= instance_name%>"]
|
||||
},
|
||||
%{
|
||||
key: :html,
|
||||
type: :string,
|
||||
description:
|
||||
"The html content of welcome email. Can be use EEX template with `user` and `instance_name` variables.",
|
||||
"HTML content of the welcome email. EEX template with user and instance_name variables can be used.",
|
||||
suggestions: ["<h1>Hello <%= user.name%>. Welcome to <%= instance_name%></h1>"]
|
||||
},
|
||||
%{
|
||||
key: :text,
|
||||
type: :string,
|
||||
description:
|
||||
"The text content of welcome email. Can be use EEX template with `user` and `instance_name` variables.",
|
||||
"Text content of the welcome email. EEX template with user and instance_name variables can be used.",
|
||||
suggestions: ["Hello <%= user.name%>. \n Welcome to <%= instance_name%>\n"]
|
||||
}
|
||||
]
|
||||
|
|
@ -1207,7 +1279,7 @@ config :pleroma, :config_description, [
|
|||
},
|
||||
%{
|
||||
key: :background,
|
||||
type: :string,
|
||||
type: {:string, :image},
|
||||
description:
|
||||
"URL of the background, unless viewing a user profile with a background that is set",
|
||||
suggestions: ["/images/city.jpg"]
|
||||
|
|
@ -1264,7 +1336,7 @@ config :pleroma, :config_description, [
|
|||
},
|
||||
%{
|
||||
key: :logo,
|
||||
type: :string,
|
||||
type: {:string, :image},
|
||||
description: "URL of the logo, defaults to Pleroma's logo",
|
||||
suggestions: ["/static/logo.png"]
|
||||
},
|
||||
|
|
@ -1296,7 +1368,7 @@ config :pleroma, :config_description, [
|
|||
%{
|
||||
key: :nsfwCensorImage,
|
||||
label: "NSFW Censor Image",
|
||||
type: :string,
|
||||
type: {:string, :image},
|
||||
description:
|
||||
"URL of the image to use for hiding NSFW media attachments in the timeline",
|
||||
suggestions: ["/static/img/nsfw.74818f9.png"]
|
||||
|
|
@ -1422,7 +1494,7 @@ config :pleroma, :config_description, [
|
|||
},
|
||||
%{
|
||||
key: :default_user_avatar,
|
||||
type: :string,
|
||||
type: {:string, :image},
|
||||
description: "URL of the default user avatar",
|
||||
suggestions: ["/images/avi.png"]
|
||||
}
|
||||
|
|
@ -1542,6 +1614,12 @@ config :pleroma, :config_description, [
|
|||
description: "List of instances to only accept activities from (except deletes)",
|
||||
suggestions: ["example.com", "*.example.com"]
|
||||
},
|
||||
%{
|
||||
key: :followers_only,
|
||||
type: {:list, :string},
|
||||
description: "Force posts from the given instances to be visible by followers only",
|
||||
suggestions: ["example.com", "*.example.com"]
|
||||
},
|
||||
%{
|
||||
key: :report_removal,
|
||||
type: {:list, :string},
|
||||
|
|
@ -1775,12 +1853,12 @@ config :pleroma, :config_description, [
|
|||
%{
|
||||
key: :enabled,
|
||||
type: :boolean,
|
||||
description: "Enables invalidate media cache"
|
||||
description: "Enables media cache object invalidation."
|
||||
},
|
||||
%{
|
||||
key: :provider,
|
||||
type: :module,
|
||||
description: "Module which will be used to cache purge.",
|
||||
description: "Module which will be used to purge objects from the cache.",
|
||||
suggestions: [
|
||||
Pleroma.Web.MediaProxy.Invalidation.Script,
|
||||
Pleroma.Web.MediaProxy.Invalidation.Http
|
||||
|
|
@ -2206,9 +2284,6 @@ config :pleroma, :config_description, [
|
|||
type: {:list, :tuple},
|
||||
description: "Settings for cron background jobs",
|
||||
suggestions: [
|
||||
{"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker},
|
||||
{"0 * * * *", Pleroma.Workers.Cron.StatsWorker},
|
||||
{"* * * * *", Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker},
|
||||
{"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker},
|
||||
{"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker}
|
||||
]
|
||||
|
|
@ -2301,6 +2376,13 @@ config :pleroma, :config_description, [
|
|||
suggestions: [
|
||||
Pleroma.Web.RichMedia.Parser.TTL.AwsSignedUrl
|
||||
]
|
||||
},
|
||||
%{
|
||||
key: :failure_backoff,
|
||||
type: :integer,
|
||||
description:
|
||||
"Amount of milliseconds after request failure, during which the request will not be retried.",
|
||||
suggestions: [60_000]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -2384,14 +2466,20 @@ config :pleroma, :config_description, [
|
|||
},
|
||||
%{
|
||||
group: :pleroma,
|
||||
key: Pleroma.ActivityExpiration,
|
||||
key: Pleroma.Workers.PurgeExpiredActivity,
|
||||
type: :group,
|
||||
description: "Expired activity settings",
|
||||
description: "Expired activities settings",
|
||||
children: [
|
||||
%{
|
||||
key: :enabled,
|
||||
type: :boolean,
|
||||
description: "Whether expired activities will be sent to the job queue to be deleted"
|
||||
description: "Enables expired activities addition & deletion"
|
||||
},
|
||||
%{
|
||||
key: :min_lifetime,
|
||||
type: :integer,
|
||||
description: "Minimum lifetime for ephemeral activity (in seconds)",
|
||||
suggestions: [600]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -2607,7 +2695,7 @@ config :pleroma, :config_description, [
|
|||
children: [
|
||||
%{
|
||||
key: :logo,
|
||||
type: :string,
|
||||
type: {:string, :image},
|
||||
description: "A path to a custom logo. Set it to `nil` to use the default Pleroma logo.",
|
||||
suggestions: ["some/path/logo.png"]
|
||||
},
|
||||
|
|
@ -3021,6 +3109,7 @@ config :pleroma, :config_description, [
|
|||
%{
|
||||
key: :restricted_nicknames,
|
||||
type: {:list, :string},
|
||||
description: "List of nicknames users may not register with.",
|
||||
suggestions: [
|
||||
".well-known",
|
||||
"~",
|
||||
|
|
@ -3053,6 +3142,12 @@ config :pleroma, :config_description, [
|
|||
"users",
|
||||
"web"
|
||||
]
|
||||
},
|
||||
%{
|
||||
key: :email_blacklist,
|
||||
type: {:list, :string},
|
||||
description: "List of email domains users may not register with.",
|
||||
suggestions: ["mailinator.com", "maildrop.cc"]
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
@ -3257,7 +3352,7 @@ config :pleroma, :config_description, [
|
|||
group: :pleroma,
|
||||
key: :connections_pool,
|
||||
type: :group,
|
||||
description: "Advanced settings for `gun` connections pool",
|
||||
description: "Advanced settings for `Gun` connections pool",
|
||||
children: [
|
||||
%{
|
||||
key: :connection_acquisition_wait,
|
||||
|
|
@ -3280,7 +3375,7 @@ config :pleroma, :config_description, [
|
|||
suggestions: [250]
|
||||
},
|
||||
%{
|
||||
key: :await_up_timeout,
|
||||
key: :connect_timeout,
|
||||
type: :integer,
|
||||
description: "Timeout while `gun` will wait until connection is up. Default: 5000ms.",
|
||||
suggestions: [5000]
|
||||
|
|
@ -3298,7 +3393,7 @@ config :pleroma, :config_description, [
|
|||
group: :pleroma,
|
||||
key: :pools,
|
||||
type: :group,
|
||||
description: "Advanced settings for `gun` workers pools",
|
||||
description: "Advanced settings for `Gun` workers pools",
|
||||
children:
|
||||
Enum.map([:federation, :media, :upload, :default], fn pool_name ->
|
||||
%{
|
||||
|
|
@ -3318,6 +3413,12 @@ config :pleroma, :config_description, [
|
|||
description:
|
||||
"Maximum number of requests waiting for other requests to finish. After this number is reached, the pool will start returning errrors when a new request is made",
|
||||
suggestions: [10]
|
||||
},
|
||||
%{
|
||||
key: :recv_timeout,
|
||||
type: :integer,
|
||||
description: "Timeout for the pool while gun will wait for response",
|
||||
suggestions: [10_000]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -3327,7 +3428,7 @@ config :pleroma, :config_description, [
|
|||
group: :pleroma,
|
||||
key: :hackney_pools,
|
||||
type: :group,
|
||||
description: "Advanced settings for `hackney` connections pools",
|
||||
description: "Advanced settings for `Hackney` connections pools",
|
||||
children: [
|
||||
%{
|
||||
key: :federation,
|
||||
|
|
@ -3391,6 +3492,7 @@ config :pleroma, :config_description, [
|
|||
%{
|
||||
group: :pleroma,
|
||||
key: :restrict_unauthenticated,
|
||||
label: "Restrict Unauthenticated",
|
||||
type: :group,
|
||||
description:
|
||||
"Disallow viewing timelines, user profiles and statuses for unauthenticated users.",
|
||||
|
|
@ -3510,18 +3612,41 @@ config :pleroma, :config_description, [
|
|||
key: :primary,
|
||||
type: :map,
|
||||
description: "Primary frontend, the one that is served for all pages by default",
|
||||
children: [
|
||||
%{
|
||||
key: "name",
|
||||
type: :string,
|
||||
description: "Name of the installed primary frontend"
|
||||
children: installed_frontend_options
|
||||
},
|
||||
%{
|
||||
key: "ref",
|
||||
type: :string,
|
||||
description: "reference of the installed primary frontend to be used"
|
||||
key: :admin,
|
||||
type: :map,
|
||||
description: "Admin frontend",
|
||||
children: installed_frontend_options
|
||||
},
|
||||
%{
|
||||
key: :available,
|
||||
type: :map,
|
||||
description:
|
||||
"A map containing available frontends and parameters for their installation.",
|
||||
children: [
|
||||
frontend_options
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
%{
|
||||
group: :pleroma,
|
||||
key: Pleroma.Web.Preload,
|
||||
type: :group,
|
||||
description: "Preload-related settings",
|
||||
children: [
|
||||
%{
|
||||
key: :providers,
|
||||
type: {:list, :module},
|
||||
description: "List of preload providers to enable",
|
||||
suggestions: [
|
||||
Pleroma.Web.Preload.Providers.Instance,
|
||||
Pleroma.Web.Preload.Providers.User,
|
||||
Pleroma.Web.Preload.Providers.Timelines,
|
||||
Pleroma.Web.Preload.Providers.StatusNet
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@ config :logger, :console,
|
|||
|
||||
config :pleroma, :auth, oauth_consumer_strategies: []
|
||||
|
||||
config :pleroma, Pleroma.Upload, filters: [], link_name: false
|
||||
config :pleroma, Pleroma.Upload,
|
||||
filters: [],
|
||||
link_name: false,
|
||||
default_description: :filename
|
||||
|
||||
config :pleroma, Pleroma.Uploaders.Local, uploads: "test/uploads"
|
||||
|
||||
|
|
@ -111,8 +114,6 @@ config :pleroma, Pleroma.Plugs.RemoteIp, enabled: false
|
|||
|
||||
config :pleroma, Pleroma.Web.ApiSpec.CastAndValidate, strict: true
|
||||
|
||||
config :pleroma, :instances_favicons, enabled: true
|
||||
|
||||
config :pleroma, Pleroma.Uploaders.S3,
|
||||
bucket: nil,
|
||||
streaming_enabled: true,
|
||||
|
|
@ -120,6 +121,8 @@ config :pleroma, Pleroma.Uploaders.S3,
|
|||
|
||||
config :tzdata, :autoupdate, :disabled
|
||||
|
||||
config :pleroma, :mrf, policies: []
|
||||
|
||||
if File.exists?("./config/test.secret.exs") do
|
||||
import_config "test.secret.exs"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -313,31 +313,53 @@ Note: Available `:permission_group` is currently moderator and admin. 404 is ret
|
|||
- On failure: `Not found`
|
||||
- On success: JSON array of user's latest statuses
|
||||
|
||||
## `GET /api/pleroma/admin/relay`
|
||||
|
||||
### List Relays
|
||||
|
||||
Params: none
|
||||
Response:
|
||||
|
||||
* On success: JSON array of relays
|
||||
|
||||
```json
|
||||
[
|
||||
{"actor": "https://example.com/relay", "followed_back": true},
|
||||
{"actor": "https://example2.com/relay", "followed_back": false}
|
||||
]
|
||||
```
|
||||
|
||||
## `POST /api/pleroma/admin/relay`
|
||||
|
||||
### Follow a Relay
|
||||
|
||||
- Params:
|
||||
- `relay_url`
|
||||
- Response:
|
||||
- On success: URL of the followed relay
|
||||
Params:
|
||||
|
||||
* `relay_url`
|
||||
|
||||
Response:
|
||||
|
||||
* On success: relay json object
|
||||
|
||||
```json
|
||||
{"actor": "https://example.com/relay", "followed_back": true}
|
||||
```
|
||||
|
||||
## `DELETE /api/pleroma/admin/relay`
|
||||
|
||||
### Unfollow a Relay
|
||||
|
||||
- Params:
|
||||
- `relay_url`
|
||||
- Response:
|
||||
- On success: URL of the unfollowed relay
|
||||
Params:
|
||||
|
||||
## `GET /api/pleroma/admin/relay`
|
||||
* `relay_url`
|
||||
|
||||
### List Relays
|
||||
Response:
|
||||
|
||||
- Params: none
|
||||
- Response:
|
||||
- On success: JSON array of relays
|
||||
* On success: URL of the unfollowed relay
|
||||
|
||||
```json
|
||||
{"https://example.com/relay"}
|
||||
```
|
||||
|
||||
## `POST /api/pleroma/admin/users/invite_token`
|
||||
|
||||
|
|
@ -1266,11 +1288,14 @@ Loads json generated from `config/descriptions.exs`.
|
|||
- Params:
|
||||
- *optional* `page`: **integer** page number
|
||||
- *optional* `page_size`: **integer** number of log entries per page (default is `50`)
|
||||
- *optional* `query`: **string** search term
|
||||
|
||||
- Response:
|
||||
|
||||
``` json
|
||||
{
|
||||
"page_size": integer,
|
||||
"count": integer,
|
||||
"urls": [
|
||||
"http://example.com/media/a688346.jpg",
|
||||
"http://example.com/media/fb1f4d.jpg"
|
||||
|
|
@ -1290,12 +1315,7 @@ Loads json generated from `config/descriptions.exs`.
|
|||
- Response:
|
||||
|
||||
``` json
|
||||
{
|
||||
"urls": [
|
||||
"http://example.com/media/a688346.jpg",
|
||||
"http://example.com/media/fb1f4d.jpg"
|
||||
]
|
||||
}
|
||||
{ }
|
||||
|
||||
```
|
||||
|
||||
|
|
@ -1311,11 +1331,169 @@ Loads json generated from `config/descriptions.exs`.
|
|||
- Response:
|
||||
|
||||
``` json
|
||||
{
|
||||
"urls": [
|
||||
"http://example.com/media/a688346.jpg",
|
||||
"http://example.com/media/fb1f4d.jpg"
|
||||
]
|
||||
}
|
||||
{ }
|
||||
|
||||
```
|
||||
|
||||
## GET /api/pleroma/admin/users/:nickname/chats
|
||||
|
||||
### List a user's chats
|
||||
|
||||
- Params: None
|
||||
|
||||
- Response:
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"sender": {
|
||||
"id": "someflakeid",
|
||||
"username": "somenick",
|
||||
...
|
||||
},
|
||||
"receiver": {
|
||||
"id": "someflakeid",
|
||||
"username": "somenick",
|
||||
...
|
||||
},
|
||||
"id" : "1",
|
||||
"unread" : 2,
|
||||
"last_message" : {...}, // The last message in that chat
|
||||
"updated_at": "2020-04-21T15:11:46.000Z"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## GET /api/pleroma/admin/chats/:chat_id
|
||||
|
||||
### View a single chat
|
||||
|
||||
- Params: None
|
||||
|
||||
- Response:
|
||||
|
||||
```json
|
||||
{
|
||||
"sender": {
|
||||
"id": "someflakeid",
|
||||
"username": "somenick",
|
||||
...
|
||||
},
|
||||
"receiver": {
|
||||
"id": "someflakeid",
|
||||
"username": "somenick",
|
||||
...
|
||||
},
|
||||
"id" : "1",
|
||||
"unread" : 2,
|
||||
"last_message" : {...}, // The last message in that chat
|
||||
"updated_at": "2020-04-21T15:11:46.000Z"
|
||||
}
|
||||
```
|
||||
|
||||
## GET /api/pleroma/admin/chats/:chat_id/messages
|
||||
|
||||
### List the messages in a chat
|
||||
|
||||
- Params: `max_id`, `min_id`
|
||||
|
||||
- Response:
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"account_id": "someflakeid",
|
||||
"chat_id": "1",
|
||||
"content": "Check this out :firefox:",
|
||||
"created_at": "2020-04-21T15:11:46.000Z",
|
||||
"emojis": [
|
||||
{
|
||||
"shortcode": "firefox",
|
||||
"static_url": "https://dontbulling.me/emoji/Firefox.gif",
|
||||
"url": "https://dontbulling.me/emoji/Firefox.gif",
|
||||
"visible_in_picker": false
|
||||
}
|
||||
],
|
||||
"id": "13",
|
||||
"unread": true
|
||||
},
|
||||
{
|
||||
"account_id": "someflakeid",
|
||||
"chat_id": "1",
|
||||
"content": "Whats' up?",
|
||||
"created_at": "2020-04-21T15:06:45.000Z",
|
||||
"emojis": [],
|
||||
"id": "12",
|
||||
"unread": false
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## DELETE /api/pleroma/admin/chats/:chat_id/messages/:message_id
|
||||
|
||||
### Delete a single message
|
||||
|
||||
- Params: None
|
||||
|
||||
- Response:
|
||||
|
||||
```json
|
||||
{
|
||||
"account_id": "someflakeid",
|
||||
"chat_id": "1",
|
||||
"content": "Check this out :firefox:",
|
||||
"created_at": "2020-04-21T15:11:46.000Z",
|
||||
"emojis": [
|
||||
{
|
||||
"shortcode": "firefox",
|
||||
"static_url": "https://dontbulling.me/emoji/Firefox.gif",
|
||||
"url": "https://dontbulling.me/emoji/Firefox.gif",
|
||||
"visible_in_picker": false
|
||||
}
|
||||
],
|
||||
"id": "13",
|
||||
"unread": false
|
||||
}
|
||||
```
|
||||
|
||||
## `GET /api/pleroma/admin/instance_document/:document_name`
|
||||
|
||||
### Get an instance document
|
||||
|
||||
- Authentication: required
|
||||
|
||||
- Response:
|
||||
|
||||
Returns the content of the document
|
||||
|
||||
```html
|
||||
<h1>Instance panel</h1>
|
||||
```
|
||||
|
||||
## `PATCH /api/pleroma/admin/instance_document/:document_name`
|
||||
- Params:
|
||||
- `file` (the file to be uploaded, using multipart form data.)
|
||||
|
||||
### Update an instance document
|
||||
|
||||
- Authentication: required
|
||||
|
||||
- Response:
|
||||
|
||||
``` json
|
||||
{
|
||||
"url": "https://example.com/instance/panel.html"
|
||||
}
|
||||
```
|
||||
|
||||
## `DELETE /api/pleroma/admin/instance_document/:document_name`
|
||||
|
||||
### Delete an instance document
|
||||
|
||||
- Response:
|
||||
|
||||
``` json
|
||||
{
|
||||
"url": "https://example.com/instance/panel.html"
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -11,15 +11,18 @@
|
|||
config :pleroma, configurable_from_database: true
|
||||
```
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl config migrate_to_db
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.config migrate_to_db
|
||||
```
|
||||
|
||||
|
||||
## Transfer config from DB to `config/env.exported_from_db.secret.exs`
|
||||
|
||||
!!! note
|
||||
|
|
@ -31,10 +34,12 @@ mix pleroma.config migrate_to_db
|
|||
|
||||
To delete transfered settings from database optional flag `-d` can be used. `<env>` is `prod` by default.
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
```sh
|
||||
./bin/pleroma_ctl config migrate_from_db [--env=<env>] [-d]
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
```sh
|
||||
mix pleroma.config migrate_from_db [--env=<env>] [-d]
|
||||
```
|
||||
|
|
|
|||
|
|
@ -9,14 +9,19 @@
|
|||
|
||||
Replaces embedded objects with references to them in the `objects` table. Only needs to be ran once if the instance was created before Pleroma 1.0.5. The reason why this is not a migration is because it could significantly increase the database size after being ran, however after this `VACUUM FULL` will be able to reclaim about 20% (really depends on what is in the database, your mileage may vary) of the db size before the migration.
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl database remove_embedded_objects [option ...]
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.database remove_embedded_objects [option ...]
|
||||
```
|
||||
|
||||
|
||||
### Options
|
||||
- `--vacuum` - run `VACUUM FULL` after the embedded objects are replaced with their references
|
||||
|
||||
|
|
@ -27,11 +32,15 @@ This will prune remote posts older than 90 days (configurable with [`config :ple
|
|||
!!! danger
|
||||
The disk space will only be reclaimed after `VACUUM FULL`. You may run out of disk space during the execution of the task or vacuuming if you don't have about 1/3rds of the database size free.
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl database prune_objects [option ...]
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.database prune_objects [option ...]
|
||||
```
|
||||
|
||||
|
|
@ -42,31 +51,43 @@ mix pleroma.database prune_objects [option ...]
|
|||
|
||||
Can be safely re-run
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl database bump_all_conversations
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.database bump_all_conversations
|
||||
```
|
||||
|
||||
## Remove duplicated items from following and update followers count for all users
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl database update_users_following_followers_counts
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.database update_users_following_followers_counts
|
||||
```
|
||||
|
||||
## Fix the pre-existing "likes" collections for all objects
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl database fix_likes_collections
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.database fix_likes_collections
|
||||
```
|
||||
|
||||
|
|
@ -76,11 +97,15 @@ mix pleroma.database fix_likes_collections
|
|||
|
||||
Running an `analyze` vacuum job can improve performance by updating statistics used by the query planner. **It is safe to cancel this.**
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl database vacuum analyze
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.database vacuum analyze
|
||||
```
|
||||
|
||||
|
|
@ -91,10 +116,28 @@ and more compact files with an optimized layout. This process will take a long t
|
|||
it builds the files side-by-side the existing database files. It can make your database faster and use less disk space,
|
||||
but should only be run if necessary. **It is safe to cancel this.**
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl database vacuum full
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.database vacuum full
|
||||
```
|
||||
|
||||
## Add expiration to all local statuses
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl database ensure_expiration
|
||||
```
|
||||
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.database ensure_expiration
|
||||
```
|
||||
|
|
|
|||
|
|
@ -4,22 +4,30 @@
|
|||
|
||||
## Send digest email since given date (user registration date by default) ignoring user activity status.
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl digest test <nickname> [since_date]
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.digest test <nickname> [since_date]
|
||||
```
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl digest test donaldtheduck 2019-05-20
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.digest test donaldtheduck 2019-05-20
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -4,21 +4,29 @@
|
|||
|
||||
## Send test email (instance email by default)
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl email test [--to <destination email address>]
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.email test [--to <destination email address>]
|
||||
```
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl email test --to root@example.org
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.email test --to root@example.org
|
||||
```
|
||||
|
|
|
|||
|
|
@ -4,11 +4,13 @@
|
|||
|
||||
## Lists emoji packs and metadata specified in the manifest
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
```sh
|
||||
./bin/pleroma_ctl emoji ls-packs [option ...]
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
```sh
|
||||
mix pleroma.emoji ls-packs [option ...]
|
||||
```
|
||||
|
||||
|
|
@ -18,11 +20,13 @@ mix pleroma.emoji ls-packs [option ...]
|
|||
|
||||
## Fetch, verify and install the specified packs from the manifest into `STATIC-DIR/emoji/PACK-NAME`
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
```sh
|
||||
./bin/pleroma_ctl emoji get-packs [option ...] <pack ...>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
```sh
|
||||
mix pleroma.emoji get-packs [option ...] <pack ...>
|
||||
```
|
||||
|
||||
|
|
@ -31,11 +35,13 @@ mix pleroma.emoji get-packs [option ...] <pack ...>
|
|||
|
||||
## Create a new manifest entry and a file list from the specified remote pack file
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
```sh
|
||||
./bin/pleroma_ctl emoji gen-pack PACK-URL
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
```sh
|
||||
mix pleroma.emoji gen-pack PACK-URL
|
||||
```
|
||||
|
||||
|
|
@ -47,7 +53,8 @@ Currently, only .zip archives are recognized as remote pack files and packs are
|
|||
|
||||
## Reload emoji packs
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
```sh
|
||||
./bin/pleroma_ctl emoji reload
|
||||
```
|
||||
|
||||
|
|
|
|||
69
docs/administration/CLI_tasks/frontend.md
Normal file
69
docs/administration/CLI_tasks/frontend.md
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# Managing frontends
|
||||
|
||||
`mix pleroma.frontend install <frontend> [--ref <ref>] [--file <file>] [--build-url <build-url>] [--path <path>] [--build-dir <build-dir>]`
|
||||
|
||||
Frontend can be installed either from local zip file, or automatically downloaded from the web.
|
||||
|
||||
You can give all the options directly on the command like, but missing information will be filled out by looking at the data configured under `frontends.available` in the config files.
|
||||
|
||||
Currently known `<frontend>` values are:
|
||||
- [admin-fe](https://git.pleroma.social/pleroma/admin-fe)
|
||||
- [kenoma](http://git.pleroma.social/lambadalambda/kenoma)
|
||||
- [pleroma-fe](http://git.pleroma.social/pleroma/pleroma-fe)
|
||||
- [fedi-fe](https://git.pleroma.social/pleroma/fedi-fe)
|
||||
- [soapbox-fe](https://gitlab.com/soapbox-pub/soapbox-fe)
|
||||
|
||||
You can still install frontends that are not configured, see below.
|
||||
|
||||
## Example installations for a known frontend
|
||||
|
||||
For a frontend configured under the `available` key, it's enough to install it by name.
|
||||
|
||||
```sh tab="OTP"
|
||||
./bin/pleroma_ctl frontend install pleroma
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
mix pleroma.frontend install pleroma
|
||||
```
|
||||
|
||||
This will download the latest build for the the pre-configured `ref` and install it. It can then be configured as the one of the served frontends in the config file (see `primary` or `admin`).
|
||||
|
||||
You can override any of the details. To install a pleroma build from a different url, you could do this:
|
||||
|
||||
```sh tab="OPT"
|
||||
./bin/pleroma_ctl frontend install pleroma --ref 2hu_edition --build-url https://example.org/raymoo.zip
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
mix pleroma.frontend install pleroma --ref 2hu_edition --build-url https://example.org/raymoo.zip
|
||||
```
|
||||
|
||||
Similarly, you can also install from a local zip file.
|
||||
|
||||
```sh tab="OTP"
|
||||
./bin/pleroma_ctl frontend install pleroma --ref mybuild --file ~/Downloads/doomfe.zip
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
mix pleroma.frontend install pleroma --ref mybuild --file ~/Downloads/doomfe.zip
|
||||
```
|
||||
|
||||
The resulting frontend will always be installed into a folder of this template: `${instance_static}/frontends/${name}/${ref}`
|
||||
|
||||
Careful: This folder will be completely replaced on installation
|
||||
|
||||
## Example installation for an unknown frontend
|
||||
|
||||
The installation process is the same, but you will have to give all the needed options on the commond line. For example:
|
||||
|
||||
```sh tab="OTP"
|
||||
./bin/pleroma_ctl frontend install gensokyo --ref master --build-url https://gensokyo.2hu/builds/marisa.zip
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
mix pleroma.frontend install gensokyo --ref master --build-url https://gensokyo.2hu/builds/marisa.zip
|
||||
```
|
||||
|
||||
If you don't have a zip file but just want to install a frontend from a local path, you can simply copy the files over a folder of this template: `${instance_static}/frontends/${name}/${ref}`
|
||||
|
||||
|
|
@ -3,11 +3,15 @@
|
|||
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
|
||||
|
||||
## Generate a new configuration file
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl instance gen [option ...]
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.instance gen [option ...]
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,14 @@
|
|||
Optional params:
|
||||
* `-s SCOPES` - scopes for app, e.g. `read,write,follow,push`.
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl app create -n APP_NAME -r REDIRECT_URI
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.app create -n APP_NAME -r REDIRECT_URI
|
||||
```
|
||||
|
|
@ -4,30 +4,42 @@
|
|||
|
||||
## Follow a relay
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl relay follow <relay_url>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.relay follow <relay_url>
|
||||
```
|
||||
|
||||
## Unfollow a remote relay
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl relay unfollow <relay_url>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.relay unfollow <relay_url>
|
||||
```
|
||||
|
||||
## List relay subscriptions
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl relay list
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.relay list
|
||||
```
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
# Generate release environment file
|
||||
|
||||
```sh tab="OTP"
|
||||
./bin/pleroma_ctl release_env gen
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
mix pleroma.release_env gen
|
||||
```
|
||||
21
docs/administration/CLI_tasks/robots_txt.md
Normal file
21
docs/administration/CLI_tasks/robots_txt.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Managing robots.txt
|
||||
|
||||
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
|
||||
|
||||
## Generate a new robots.txt file and add it to the static directory
|
||||
|
||||
The `robots.txt` that ships by default is permissive. It allows well-behaved search engines to index all of your instance's URIs.
|
||||
|
||||
If you want to generate a restrictive `robots.txt`, you can run the following mix task. The generated `robots.txt` will be written in your instance [static directory](../../../configuration/static_dir/).
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl robots_txt disallow_all
|
||||
```
|
||||
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.robots_txt disallow_all
|
||||
```
|
||||
|
|
@ -3,11 +3,15 @@
|
|||
{! backend/administration/CLI_tasks/general_cli_task_info.include !}
|
||||
|
||||
## Migrate uploads from local to remote storage
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl uploads migrate_local <target_uploader> [option ...]
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.uploads migrate_local <target_uploader> [option ...]
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -4,11 +4,15 @@
|
|||
|
||||
## Create a user
|
||||
|
||||
```sh tab="OTP"
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user new <nickname> <email> [option ...]
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user new <nickname> <email> [option ...]
|
||||
```
|
||||
|
||||
|
|
@ -22,21 +26,31 @@ mix pleroma.user new <nickname> <email> [option ...]
|
|||
- `-y`, `--assume-yes`/`--no-assume-yes` - whether to assume yes to all questions
|
||||
|
||||
## List local users
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user list
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user list
|
||||
```
|
||||
|
||||
|
||||
## Generate an invite link
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user invite [option ...]
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user invite [option ...]
|
||||
```
|
||||
|
||||
|
|
@ -46,111 +60,166 @@ mix pleroma.user invite [option ...]
|
|||
- `--max-use NUMBER` - maximum numbers of token uses
|
||||
|
||||
## List generated invites
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user invites
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user invites
|
||||
```
|
||||
|
||||
|
||||
## Revoke invite
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user revoke_invite <token>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user revoke_invite <token>
|
||||
```
|
||||
|
||||
|
||||
## Delete a user
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user rm <nickname>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user rm <nickname>
|
||||
```
|
||||
|
||||
|
||||
## Delete user's posts and interactions
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user delete_activities <nickname>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user delete_activities <nickname>
|
||||
```
|
||||
|
||||
|
||||
## Sign user out from all applications (delete user's OAuth tokens and authorizations)
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user sign_out <nickname>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user sign_out <nickname>
|
||||
```
|
||||
|
||||
|
||||
## Deactivate or activate a user
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user toggle_activated <nickname>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user toggle_activated <nickname>
|
||||
```
|
||||
|
||||
|
||||
## Deactivate a user and unsubscribes local users from the user
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user deactivate NICKNAME
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user deactivate NICKNAME
|
||||
```
|
||||
|
||||
|
||||
## Deactivate all accounts from an instance and unsubscribe local users on it
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user deactivate_all_from_instance <instance>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user deactivate_all_from_instance <instance>
|
||||
```
|
||||
|
||||
|
||||
## Create a password reset link for user
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user reset_password <nickname>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user reset_password <nickname>
|
||||
```
|
||||
|
||||
|
||||
## Disable Multi Factor Authentication (MFA/2FA) for a user
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user reset_mfa <nickname>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user reset_mfa <nickname>
|
||||
```
|
||||
|
||||
|
||||
## Set the value of the given user's settings
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user set <nickname> [option ...]
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user set <nickname> [option ...]
|
||||
```
|
||||
|
||||
|
|
@ -160,30 +229,45 @@ mix pleroma.user set <nickname> [option ...]
|
|||
- `--admin`/`--no-admin` - whether the user should be an admin
|
||||
|
||||
## Add tags to a user
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user tag <nickname> <tags>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user tag <nickname> <tags>
|
||||
```
|
||||
|
||||
|
||||
## Delete tags from a user
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user untag <nickname> <tags>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user untag <nickname> <tags>
|
||||
```
|
||||
|
||||
|
||||
## Toggle confirmation status of the user
|
||||
```sh tab="OTP"
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl user toggle_confirmed <nickname>
|
||||
```
|
||||
|
||||
```sh tab="From Source"
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.user toggle_confirmed <nickname>
|
||||
```
|
||||
|
|
|
|||
|
|
@ -18,9 +18,10 @@ su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
|
|||
|
||||
1. Go to the working directory of Pleroma (default is `/opt/pleroma`)
|
||||
2. Run `git pull`. This pulls the latest changes from upstream.
|
||||
3. Run `mix deps.get`. This pulls in any new dependencies.
|
||||
3. Run `mix deps.get` [^1]. This pulls in any new dependencies.
|
||||
4. Stop the Pleroma service.
|
||||
5. Run `mix ecto.migrate`[^1]. This task performs database migrations, if there were any.
|
||||
5. Run `mix ecto.migrate` [^1] [^2]. This task performs database migrations, if there were any.
|
||||
6. Start the Pleroma service.
|
||||
|
||||
[^1]: Prefix with `MIX_ENV=prod` to run it using the production config file.
|
||||
[^1]: Depending on which install guide you followed (for example on Debian/Ubuntu), you want to run `mix` tasks as `pleroma` user by adding `sudo -Hu pleroma` before the command.
|
||||
[^2]: Prefix with `MIX_ENV=prod` to run it using the production config file.
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ Feel free to contact us to be added to this list!
|
|||
### Roma for Desktop
|
||||
- Homepage: <https://www.pleroma.com/#desktopApp>
|
||||
- Source Code: <https://github.com/roma-apps/roma-desktop>
|
||||
- Platforms: Windows, Mac, (Linux?)
|
||||
- Platforms: Windows, Mac, Linux
|
||||
- Features: Streaming Ready
|
||||
|
||||
### Social
|
||||
- Source Code: <https://gitlab.gnome.org/BrainBlasted/Social>
|
||||
- Source Code: <https://gitlab.gnome.org/World/Social>
|
||||
- Contact: [@brainblasted@social.libre.fi](https://social.libre.fi/users/brainblasted)
|
||||
- Platforms: Linux (GNOME)
|
||||
- Note(2019-01-28): Not at a pre-alpha stage yet
|
||||
|
|
@ -48,16 +48,9 @@ Feel free to contact us to be added to this list!
|
|||
- Platforms: Android
|
||||
- Features: No Streaming, Emoji Reactions, Text Formatting, FE Stickers
|
||||
|
||||
### Nekonium
|
||||
- Homepage: [F-Droid Repository](https://repo.gdgd.jp.net/), [Google Play](https://play.google.com/store/apps/details?id=com.apps.nekonium), [Amazon](https://www.amazon.co.jp/dp/B076FXPRBC/)
|
||||
- Source: <https://gogs.gdgd.jp.net/lin/nekonium>
|
||||
- Contact: [@lin@pleroma.gdgd.jp.net](https://pleroma.gdgd.jp.net/users/lin)
|
||||
- Platforms: Android
|
||||
- Features: Streaming Ready
|
||||
|
||||
### Fedi
|
||||
- Homepage: <https://www.fediapp.com/>
|
||||
- Source Code: Proprietary, but free
|
||||
- Source Code: Proprietary, but gratis
|
||||
- Platforms: iOS, Android
|
||||
- Features: Pleroma-specific features like Reactions
|
||||
|
||||
|
|
@ -70,9 +63,16 @@ Feel free to contact us to be added to this list!
|
|||
|
||||
### Twidere
|
||||
- Homepage: <https://twidere.mariotaku.org/>
|
||||
- Source Code: <https://github.com/TwidereProject/Twidere-Android/>, <https://github.com/TwidereProject/Twidere-iOS/>
|
||||
- Source Code: <https://github.com/TwidereProject/Twidere-Android/>
|
||||
- Contact: <me@mariotaku.org>
|
||||
- Platform: Android, iOS
|
||||
- Platform: Android
|
||||
- Features: No Streaming
|
||||
|
||||
### Indigenous
|
||||
- Homepage: <https://indigenous.realize.be/>
|
||||
- Source Code: <https://github.com/swentel/indigenous-android/>
|
||||
- Contact: [@realize.be@realize.be](@realize.be@realize.be)
|
||||
- Platforms: Android
|
||||
- Features: No Streaming
|
||||
|
||||
## Alternative Web Interfaces
|
||||
|
|
@ -82,11 +82,6 @@ Feel free to contact us to be added to this list!
|
|||
- Contact: [@gcupc@glitch.social](https://glitch.social/users/gcupc)
|
||||
- Features: No Streaming
|
||||
|
||||
### Feather
|
||||
- Source Code: <https://github.com/kaniini/feather>
|
||||
- Contact: [@kaniini@pleroma.site](https://pleroma.site/kaniini)
|
||||
- Features: No Streaming
|
||||
|
||||
### Halcyon
|
||||
- Source Code: <https://notabug.org/halcyon-suite/halcyon>
|
||||
- Contact: [@halcyon@social.csswg.org](https://social.csswg.org/users/halcyon)
|
||||
|
|
@ -100,6 +95,15 @@ Feel free to contact us to be added to this list!
|
|||
- Features: No Streaming
|
||||
|
||||
### Sengi
|
||||
- Homepage: <https://nicolasconstant.github.io/sengi/>
|
||||
- Source Code: <https://github.com/NicolasConstant/sengi>
|
||||
- Contact: [@sengi_app@mastodon.social](https://mastodon.social/users/sengi_app)
|
||||
- Note(2019-01-28): The development is currently in a early stage.
|
||||
|
||||
### DashFE
|
||||
- Source Code: <https://notabug.org/daisuke/DashboardFE>
|
||||
- Contact: [@dashfe@stereophonic.space](https://stereophonic.space/users/dashfe)
|
||||
|
||||
### BloatFE
|
||||
- Source Code: <https://git.freesoftwareextremist.com/bloat/>
|
||||
- Contact: [@r@freesoftwareextremist.com](https://freesoftwareextremist.com/users/r)
|
||||
- Features: Does not requires JavaScript
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ To add configuration to your config file, you can copy it from the base config.
|
|||
* `notify_email`: Email used for notifications.
|
||||
* `description`: The instance’s description, can be seen in nodeinfo and ``/api/v1/instance``.
|
||||
* `limit`: Posts character limit (CW/Subject included in the counter).
|
||||
* `discription_limit`: The character limit for image descriptions.
|
||||
* `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).
|
||||
|
|
@ -38,9 +38,8 @@ To add configuration to your config file, you can copy it from the base config.
|
|||
* `federation_incoming_replies_max_depth`: Max. depth of reply-to activities fetching on incoming federation, to prevent out-of-memory situations while fetching very long threads. If set to `nil`, threads of any depth will be fetched. Lower this value if you experience out-of-memory crashes.
|
||||
* `federation_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.
|
||||
* `public`: Makes the client API in authenticated mode-only except for user-profiles. Useful for disabling the Local Timeline and The Whole Known Network. See also: `restrict_unauthenticated`.
|
||||
* `public`: Makes the client API in authenticated mode-only except for user-profiles. Useful for disabling the Local Timeline and The Whole Known Network. Note that there is a dependent setting restricting or allowing unauthenticated access to specific resources, see `restrict_unauthenticated` for more details.
|
||||
* `quarantined_instances`: List of ActivityPub instances where private (DMs, followers-only) activities will not be send.
|
||||
* `managed_config`: Whenether the config for pleroma-fe is configured in [:frontend_configurations](#frontend_configurations) or in ``static/config.json``.
|
||||
* `allowed_post_formats`: MIME-type list of formats allowed to be posted (transformed into HTML).
|
||||
* `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.
|
||||
|
|
@ -69,6 +68,10 @@ To add configuration to your config file, you can copy it from the base config.
|
|||
* `enabled`: Enables the send a direct message to a newly registered user. Defaults to `false`.
|
||||
* `sender_nickname`: The nickname of the local user that sends the welcome message.
|
||||
* `message`: A message that will be send to a newly registered users as a direct message.
|
||||
* `chat_message`: - welcome message sent as a chat message.
|
||||
* `enabled`: Enables the send a chat message to a newly registered user. Defaults to `false`.
|
||||
* `sender_nickname`: The nickname of the local user that sends the welcome message.
|
||||
* `message`: A message that will be send to a newly registered users as a chat message.
|
||||
* `email`: - welcome message sent as a email.
|
||||
* `enabled`: Enables the send a welcome email to a newly registered user. Defaults to `false`.
|
||||
* `sender`: The email address or tuple with `{nickname, email}` that will use as sender to the welcome email.
|
||||
|
|
@ -83,7 +86,7 @@ To add configuration to your config file, you can copy it from the base config.
|
|||
direct_message: [
|
||||
enabled: true,
|
||||
sender_nickname: "lain",
|
||||
message: "Hi, @username! Welcome on board!"
|
||||
message: "Hi! Welcome on board!"
|
||||
],
|
||||
email: [
|
||||
enabled: true,
|
||||
|
|
@ -110,6 +113,8 @@ To add configuration to your config file, you can copy it from the base config.
|
|||
* `Pleroma.Web.ActivityPub.MRF.MentionPolicy`: Drops posts mentioning configurable users. (See [`:mrf_mention`](#mrf_mention)).
|
||||
* `Pleroma.Web.ActivityPub.MRF.VocabularyPolicy`: Restricts activities to a configured set of vocabulary. (See [`:mrf_vocabulary`](#mrf_vocabulary)).
|
||||
* `Pleroma.Web.ActivityPub.MRF.ObjectAgePolicy`: Rejects or delists posts based on their age when received. (See [`:mrf_object_age`](#mrf_object_age)).
|
||||
* `Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy`: Sets a default expiration on all posts made by users of the local instance. Requires `Pleroma.ActivityExpiration` to be enabled for processing the scheduled delections.
|
||||
* `Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicy`: Makes all bot posts to disappear from public timelines.
|
||||
* `transparency`: Make the content of your Message Rewrite Facility settings public (via nodeinfo).
|
||||
* `transparency_exclusions`: Exclude specific instance names from MRF transparency. The use of the exclusions feature will be disclosed in nodeinfo as a boolean value.
|
||||
|
||||
|
|
@ -125,6 +130,7 @@ To add configuration to your config file, you can copy it from the base config.
|
|||
* `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.
|
||||
|
|
@ -202,6 +208,11 @@ config :pleroma, :mrf_user_allowlist, %{
|
|||
* `sign_object_fetches`: Sign object fetches with HTTP signatures
|
||||
* `authorized_fetch_mode`: Require HTTP signatures for AP fetches
|
||||
|
||||
## Pleroma.User
|
||||
|
||||
* `restricted_nicknames`: List of nicknames users may not register with.
|
||||
* `email_blacklist`: List of email domains users may not register with.
|
||||
|
||||
## Pleroma.ScheduledActivity
|
||||
|
||||
* `daily_user_limit`: the number of scheduled activities a user is allowed to create in a single day (Default: `25`)
|
||||
|
|
@ -210,6 +221,8 @@ config :pleroma, :mrf_user_allowlist, %{
|
|||
|
||||
## Pleroma.ActivityExpiration
|
||||
|
||||
Enables the worker which processes posts scheduled for deletion. Pinned posts are exempt from expiration.
|
||||
|
||||
* `enabled`: whether expired activities will be sent to the job queue to be deleted
|
||||
|
||||
## Frontends
|
||||
|
|
@ -339,8 +352,6 @@ config :pleroma, Pleroma.Web.MediaProxy.Invalidation.Http,
|
|||
* `providers`: a list of metadata providers to enable. Providers available:
|
||||
* `Pleroma.Web.Metadata.Providers.OpenGraph`
|
||||
* `Pleroma.Web.Metadata.Providers.TwitterCard`
|
||||
* `Pleroma.Web.Metadata.Providers.RelMe` - add links from user bio with rel=me into the `<header>` as `<link rel=me>`.
|
||||
* `Pleroma.Web.Metadata.Providers.Feed` - add a link to a user's Atom feed into the `<header>` as `<link rel=alternate>`.
|
||||
* `unfurl_nsfw`: If set to `true` nsfw attachments will be shown in previews.
|
||||
|
||||
### :rich_media (consumer)
|
||||
|
|
@ -348,6 +359,7 @@ config :pleroma, Pleroma.Web.MediaProxy.Invalidation.Http,
|
|||
* `ignore_hosts`: list of hosts which will be ignored by the metadata parser. For example `["accounts.google.com", "xss.website"]`, defaults to `[]`.
|
||||
* `ignore_tld`: list TLDs (top-level domains) which will ignore for parse metadata. default is ["local", "localdomain", "lan"].
|
||||
* `parsers`: list of Rich Media parsers.
|
||||
* `failure_backoff`: Amount of milliseconds after request failure, during which the request will not be retried.
|
||||
|
||||
## HTTP server
|
||||
|
||||
|
|
@ -484,7 +496,7 @@ Settings for HTTP connection pool.
|
|||
* `:connection_acquisition_wait` - Timeout to acquire a connection from pool.The total max time is this value multiplied by the number of retries.
|
||||
* `connection_acquisition_retries` - Number of attempts to acquire the connection from the pool if it is overloaded. Each attempt is timed `:connection_acquisition_wait` apart.
|
||||
* `:max_connections` - Maximum number of connections in the pool.
|
||||
* `:await_up_timeout` - Timeout to connect to the host.
|
||||
* `:connect_timeout` - Timeout to connect to the host.
|
||||
* `:reclaim_multiplier` - Multiplied by `:max_connections` this will be the maximum number of idle connections that will be reclaimed in case the pool is overloaded.
|
||||
|
||||
### :pools
|
||||
|
|
@ -503,7 +515,7 @@ There are four pools used:
|
|||
For each pool, the options are:
|
||||
|
||||
* `:size` - limit to how much requests can be concurrently executed.
|
||||
* `:timeout` - timeout while `gun` will wait for response
|
||||
* `:recv_timeout` - timeout while `gun` will wait for response
|
||||
* `:max_waiting` - limit to how much requests can be waiting for others to finish, after this is reached, subsequent requests will be dropped.
|
||||
|
||||
## Captcha
|
||||
|
|
@ -539,6 +551,7 @@ the source code is here: [kocaptcha](https://github.com/koto-bank/kocaptcha). Th
|
|||
* `proxy_remote`: If you're using a remote uploader, Pleroma will proxy media requests instead of redirecting to it.
|
||||
* `proxy_opts`: Proxy options, see `Pleroma.ReverseProxy` documentation.
|
||||
* `filename_display_max_length`: Set max length of a filename to display. 0 = no limit. Default: 30.
|
||||
* `default_description`: Sets which default description an image has if none is set explicitly. Options: nil (default) - Don't set a default, :filename - use the filename of the file, a string (e.g. "attachment") - Use this string
|
||||
|
||||
!!! warning
|
||||
`strip_exif` has been replaced by `Pleroma.Upload.Filter.Mogrify`.
|
||||
|
|
@ -677,9 +690,8 @@ Pleroma has the following queues:
|
|||
|
||||
Pleroma has these periodic job workers:
|
||||
|
||||
`Pleroma.Workers.Cron.ClearOauthTokenWorker` - a job worker to cleanup expired oauth tokens.
|
||||
|
||||
Example:
|
||||
* `Pleroma.Workers.Cron.DigestEmailsWorker` - digest emails for users with new mentions and follows
|
||||
* `Pleroma.Workers.Cron.NewUsersDigestWorker` - digest emails for admins with new registrations
|
||||
|
||||
```elixir
|
||||
config :pleroma, Oban,
|
||||
|
|
@ -691,7 +703,8 @@ config :pleroma, Oban,
|
|||
federator_outgoing: 50
|
||||
],
|
||||
crontab: [
|
||||
{"0 0 * * *", Pleroma.Workers.Cron.ClearOauthTokenWorker}
|
||||
{"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker},
|
||||
{"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker}
|
||||
]
|
||||
```
|
||||
|
||||
|
|
@ -848,9 +861,6 @@ Warning: it's discouraged to use this feature because of the associated security
|
|||
|
||||
### :auth
|
||||
|
||||
* `Pleroma.Web.Auth.PleromaAuthenticator`: default database authenticator.
|
||||
* `Pleroma.Web.Auth.LDAPAuthenticator`: LDAP authentication.
|
||||
|
||||
Authentication / authorization settings.
|
||||
|
||||
* `auth_template`: authentication form template. By default it's `show.html` which corresponds to `lib/pleroma/web/templates/o_auth/o_auth/show.html.eex`.
|
||||
|
|
@ -880,6 +890,9 @@ Pleroma account will be created with the same name as the LDAP user name.
|
|||
* `base`: LDAP base, e.g. "dc=example,dc=com"
|
||||
* `uid`: LDAP attribute name to authenticate the user, e.g. when "cn", the filter will be "cn=username,base"
|
||||
|
||||
Note, if your LDAP server is an Active Directory server the correct value is commonly `uid: "cn"`, but if you use an
|
||||
OpenLDAP server the value may be `uid: "uid"`.
|
||||
|
||||
### OAuth consumer mode
|
||||
|
||||
OAuth consumer mode allows sign in / sign up via external OAuth providers (e.g. Twitter, Facebook, Google, Microsoft, etc.).
|
||||
|
|
@ -958,7 +971,7 @@ Configure OAuth 2 provider capabilities:
|
|||
|
||||
* `token_expires_in` - The lifetime in seconds of the access token.
|
||||
* `issue_new_refresh_token` - Keeps old refresh token or generate new refresh token when to obtain an access token.
|
||||
* `clean_expired_tokens` - Enable a background job to clean expired oauth tokens. Defaults to `false`. Interval settings sets in configuration periodic jobs [`Oban.Cron`](#obancron)
|
||||
* `clean_expired_tokens` - Enable a background job to clean expired oauth tokens. Defaults to `false`.
|
||||
|
||||
## Link parsing
|
||||
|
||||
|
|
@ -1038,6 +1051,8 @@ Restrict access for unauthenticated users to timelines (public and federated), u
|
|||
* `local`
|
||||
* `remote`
|
||||
|
||||
Note: when `:instance, :public` is set to `false`, all `:restrict_unauthenticated` items be effectively set to `true` by default. If you'd like to allow unauthenticated access to specific API endpoints on a private instance, please explicitly set `:restrict_unauthenticated` to non-default value in `config/prod.secret.exs`.
|
||||
|
||||
Note: setting `restrict_unauthenticated/timelines/local` to `true` has no practical sense if `restrict_unauthenticated/timelines/federated` is set to `false` (since local public activities will still be delivered to unauthenticated users as part of federated timeline).
|
||||
|
||||
## Pleroma.Web.ApiSpec.CastAndValidate
|
||||
|
|
@ -1054,11 +1069,11 @@ Control favicons for instances.
|
|||
|
||||
Frontends in Pleroma are swappable - you can specify which one to use here.
|
||||
|
||||
For now, you can set a frontend with the key `primary` and the options of `name` and `ref`. This will then make Pleroma serve the frontend from a folder constructed by concatenating the instance static path, `frontends` and the name and ref.
|
||||
You can set a frontends for the key `primary` and `admin` and the options of `name` and `ref`. This will then make Pleroma serve the frontend from a folder constructed by concatenating the instance static path, `frontends` and the name and ref.
|
||||
|
||||
The key `primary` refers to the frontend that will be served by default for general requests. In the future, other frontends like the admin frontend will also be configurable here.
|
||||
The key `primary` refers to the frontend that will be served by default for general requests. The key `admin` refers to the frontend that will be served at the `/pleroma/admin` path.
|
||||
|
||||
If you don't set anything here, the bundled frontend will be used.
|
||||
If you don't set anything here, the bundled frontends will be used.
|
||||
|
||||
Example:
|
||||
|
||||
|
|
@ -1067,7 +1082,18 @@ config :pleroma, :frontends,
|
|||
primary: %{
|
||||
"name" => "pleroma",
|
||||
"ref" => "stable"
|
||||
},
|
||||
admin: %{
|
||||
"name" => "admin",
|
||||
"ref" => "develop"
|
||||
}
|
||||
```
|
||||
|
||||
This would serve the frontend from the the folder at `$instance_static/frontends/pleroma/stable`. You have to copy the frontend into this folder yourself. You can choose the name and ref any way you like, but they will be used by mix tasks to automate installation in the future, the name referring to the project and the ref referring to a commit.
|
||||
|
||||
## Ephemeral activities (Pleroma.Workers.PurgeExpiredActivity)
|
||||
|
||||
Settings to enable and configure expiration for ephemeral activities
|
||||
|
||||
* `:enabled` - enables ephemeral activities creation
|
||||
* `:min_lifetime` - minimum lifetime for ephemeral activities (in seconds). Default: 10 minutes.
|
||||
|
|
|
|||
|
|
@ -1,45 +1,61 @@
|
|||
# Static Directory
|
||||
|
||||
Static frontend files are shipped in `priv/static/` and tracked by version control in this repository. If you want to overwrite or update these without the possibility of merge conflicts, you can write your custom versions to `instance/static/`.
|
||||
Static frontend files are shipped with pleroma. If you want to overwrite or update these without problems during upgrades, you can write your custom versions to the static directory.
|
||||
|
||||
```
|
||||
You can find the location of the static directory in the [configuration](../cheatsheet/#instance).
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```elixir
|
||||
config :pleroma, :instance,
|
||||
static_dir: "instance/static/",
|
||||
static_dir: "/var/lib/pleroma/static/"
|
||||
```
|
||||
|
||||
For example, edit `instance/static/instance/panel.html` .
|
||||
=== "From Source"
|
||||
|
||||
```elixir
|
||||
config :pleroma, :instance,
|
||||
static_dir: "instance/static/"
|
||||
```
|
||||
|
||||
Alternatively, you can overwrite this value in your configuration to use a different static instance directory.
|
||||
|
||||
This document is written assuming `instance/static/`.
|
||||
This document is written using `$static_dir` as the value of the `config :pleroma, :instance, static_dir` setting.
|
||||
|
||||
Or, if you want to manage your custom file in git repository, basically remove the `instance/` entry from `.gitignore`.
|
||||
If you use a From Source installation and want to manage your custom files in the git repository, you can remove the `instance/` entry from `.gitignore`.
|
||||
|
||||
## robots.txt
|
||||
|
||||
By default, the `robots.txt` that ships in `priv/static/` is permissive. It allows well-behaved search engines to index all of your instance's URIs.
|
||||
There's a mix tasks to [generate a new robot.txt](../../administration/CLI_tasks/robots_txt/).
|
||||
|
||||
If you want to generate a restrictive `robots.txt`, you can run the following mix task. The generated `robots.txt` will be written in your instance static directory.
|
||||
For more complex things, you can write your own robots.txt to `$static_dir/robots.txt`.
|
||||
|
||||
E.g. if you want to block all crawlers except for [fediverse.network](https://fediverse.network/about) you can use
|
||||
|
||||
```
|
||||
mix pleroma.robots_txt disallow_all
|
||||
User-Agent: *
|
||||
Disallow: /
|
||||
|
||||
User-Agent: crawler-us-il-1.fediverse.network
|
||||
Allow: /
|
||||
|
||||
User-Agent: makhnovtchina.random.sh
|
||||
Allow: /
|
||||
```
|
||||
|
||||
## Thumbnail
|
||||
|
||||
Put on `instance/static/instance/thumbnail.jpeg` with your selfie or other neat picture. It will appear in [Pleroma Instances](http://distsn.org/pleroma-instances.html).
|
||||
Add `$static_dir/instance/thumbnail.jpeg` with your selfie or other neat picture. It will be available on `http://your-domain.tld/instance/thumbnail.jpeg` and can be used by external applications.
|
||||
|
||||
## Instance-specific panel
|
||||
|
||||

|
||||
|
||||
Create and Edit your file on `instance/static/instance/panel.html`.
|
||||
Create and Edit your file at `$static_dir/instance/panel.html`.
|
||||
|
||||
## Background
|
||||
|
||||
You can change the background of your Pleroma instance by uploading it to `instance/static/`, and then changing `background` in `config/prod.secret.exs` accordingly.
|
||||
You can change the background of your Pleroma instance by uploading it to `$static_dir/`, and then changing `background` in [your configuration](../cheatsheet/#frontend_configurations) accordingly.
|
||||
|
||||
If you put `instance/static/images/background.jpg`
|
||||
E.g. if you put `$static_dir/images/background.jpg`
|
||||
|
||||
```
|
||||
config :pleroma, :frontend_configurations,
|
||||
|
|
@ -50,12 +66,14 @@ config :pleroma, :frontend_configurations,
|
|||
|
||||
## Logo
|
||||
|
||||

|
||||
!!! important
|
||||
Note the extra `static` folder for the default logo.png location
|
||||
|
||||
If you want to give a brand to your instance, You can change the logo of your instance by uploading it to `instance/static/`.
|
||||
If you want to give a brand to your instance, You can change the logo of your instance by uploading it to the static directory `$static_dir/static/logo.png`.
|
||||
|
||||
Alternatively, you can specify the path with config.
|
||||
If you put `instance/static/static/mylogo-file.png`
|
||||
Alternatively, you can specify the path to your logo in [your configuration](../cheatsheet/#frontend_configurations).
|
||||
|
||||
E.g. if you put `$static_dir/static/mylogo-file.png`
|
||||
|
||||
```
|
||||
config :pleroma, :frontend_configurations,
|
||||
|
|
@ -66,4 +84,7 @@ config :pleroma, :frontend_configurations,
|
|||
|
||||
## Terms of Service
|
||||
|
||||
Terms of Service will be shown to all users on the registration page. It's the best place where to write down the rules for your instance. You can modify the rules by changing `instance/static/static/terms-of-service.html`.
|
||||
!!! important
|
||||
Note the extra `static` folder for the terms-of-service.html
|
||||
|
||||
Terms of Service will be shown to all users on the registration page. It's the best place where to write down the rules for your instance. You can modify the rules by adding and changing `$static_dir/static/terms-of-service.html`.
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ It assumes that you have administrative rights, either as root or a user with [s
|
|||
* `erlang-xmerl`
|
||||
* `git`
|
||||
* Development Tools
|
||||
* `cmake`
|
||||
|
||||
#### Optional packages used in this guide
|
||||
|
||||
|
|
@ -39,7 +40,7 @@ sudo apk upgrade
|
|||
* Install some tools, which are needed later:
|
||||
|
||||
```shell
|
||||
sudo apk add git build-base
|
||||
sudo apk add git build-base cmake
|
||||
```
|
||||
|
||||
### Install Elixir and Erlang
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ This guide will assume that you have administrative rights, either as root or a
|
|||
* `elixir`
|
||||
* `git`
|
||||
* `base-devel`
|
||||
* `cmake`
|
||||
|
||||
#### Optional packages used in this guide
|
||||
|
||||
|
|
@ -26,7 +27,7 @@ sudo pacman -Syu
|
|||
* Install some of the above mentioned programs:
|
||||
|
||||
```shell
|
||||
sudo pacman -S git base-devel elixir
|
||||
sudo pacman -S git base-devel elixir cmake
|
||||
```
|
||||
|
||||
### Install PostgreSQL
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ This guide will assume you are on Debian Stretch. This guide should also work wi
|
|||
* `erlang-nox`
|
||||
* `git`
|
||||
* `build-essential`
|
||||
* `cmake`
|
||||
|
||||
#### Optional packages used in this guide
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ sudo apt full-upgrade
|
|||
* Install some of the above mentioned programs:
|
||||
|
||||
```shell
|
||||
sudo apt install git build-essential postgresql postgresql-contrib
|
||||
sudo apt install git build-essential postgresql postgresql-contrib cmake
|
||||
```
|
||||
|
||||
### Install Elixir and Erlang
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
- `erlang-nox`
|
||||
- `git`
|
||||
- `build-essential`
|
||||
- `cmake`
|
||||
|
||||
#### このガイドで利用している追加パッケージ
|
||||
|
||||
|
|
@ -32,7 +33,7 @@ sudo apt full-upgrade
|
|||
|
||||
* 上記に挙げたパッケージをインストールしておきます。
|
||||
```
|
||||
sudo apt install git build-essential postgresql postgresql-contrib
|
||||
sudo apt install git build-essential postgresql postgresql-contrib cmake
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
210
docs/installation/freebsd_en.md
Normal file
210
docs/installation/freebsd_en.md
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
# Installing on FreeBSD
|
||||
|
||||
This document was written for FreeBSD 12.1, but should be work on future releases.
|
||||
|
||||
## Required software
|
||||
|
||||
This assumes the target system has `pkg(8)`.
|
||||
|
||||
```
|
||||
# pkg install elixir postgresql12-server postgresql12-client postgresql12-contrib git-lite sudo nginx gmake acme.sh cmake
|
||||
```
|
||||
|
||||
Copy the rc.d scripts to the right directory:
|
||||
|
||||
Setup the required services to automatically start at boot, using `sysrc(8)`.
|
||||
|
||||
```
|
||||
# sysrc nginx_enable=YES
|
||||
# sysrc postgresql_enable=YES
|
||||
```
|
||||
|
||||
## Initialize postgres
|
||||
|
||||
```
|
||||
# service postgresql initdb
|
||||
# service postgresql start
|
||||
```
|
||||
|
||||
## Configuring Pleroma
|
||||
|
||||
Create a user for Pleroma:
|
||||
|
||||
```
|
||||
# pw add user pleroma -m
|
||||
# echo 'export LC_ALL="en_US.UTF-8"' >> /home/pleroma/.profile
|
||||
# su -l pleroma
|
||||
```
|
||||
|
||||
Clone the repository:
|
||||
|
||||
```
|
||||
$ cd $HOME # Should be the same as /home/pleroma
|
||||
$ git clone -b stable https://git.pleroma.social/pleroma/pleroma.git
|
||||
```
|
||||
|
||||
Configure Pleroma. Note that you need a domain name at this point:
|
||||
|
||||
```
|
||||
$ cd /home/pleroma/pleroma
|
||||
$ mix deps.get # Enter "y" when asked to install Hex
|
||||
$ mix pleroma.instance gen # You will be asked a few questions here.
|
||||
$ cp config/generated_config.exs config/prod.secret.exs
|
||||
```
|
||||
|
||||
Since Postgres is configured, we can now initialize the database. There should
|
||||
now be a file in `config/setup_db.psql` that makes this easier. Edit it, and
|
||||
*change the password* to a password of your choice. Make sure it is secure, since
|
||||
it'll be protecting your database. As root, you can now initialize the database:
|
||||
|
||||
```
|
||||
# cd /home/pleroma/pleroma
|
||||
# sudo -Hu postgres -g postgres psql -f config/setup_db.psql
|
||||
```
|
||||
|
||||
Postgres allows connections from all users without a password by default. To
|
||||
fix this, edit `/var/db/postgres/data12/pg_hba.conf`. Change every `trust` to
|
||||
`password`.
|
||||
|
||||
Once this is done, restart Postgres with:
|
||||
```
|
||||
# service postgresql restart
|
||||
```
|
||||
|
||||
Run the database migrations.
|
||||
|
||||
Back as the pleroma user, run the following to implement any database migrations.
|
||||
|
||||
```
|
||||
# su -l pleroma
|
||||
$ cd /home/pleroma/pleroma
|
||||
$ MIX_ENV=prod mix ecto.migrate
|
||||
```
|
||||
|
||||
You will need to do this whenever you update with `git pull`:
|
||||
|
||||
## Configuring acme.sh
|
||||
|
||||
We'll be using acme.sh in Stateless Mode for TLS certificate renewal.
|
||||
|
||||
First, as root, allow the user `acme` to have access to the acme log file, as follows:
|
||||
|
||||
```
|
||||
# touch /var/log/acme.sh.log
|
||||
# chown acme:acme /var/log/acme.sh.log
|
||||
# chmod 600 /var/log/acme.sh.log
|
||||
```
|
||||
|
||||
Next, obtain your account fingerprint:
|
||||
|
||||
```
|
||||
# sudo -Hu acme -g acme acme.sh --register-account
|
||||
```
|
||||
|
||||
You need to add the following to your nginx configuration for the server
|
||||
running on port 80:
|
||||
|
||||
```
|
||||
location ~ ^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)$ {
|
||||
default_type text/plain;
|
||||
return 200 "$1.6fXAG9VyG0IahirPEU2ZerUtItW2DHzDzD9wZaEKpqd";
|
||||
}
|
||||
```
|
||||
|
||||
Replace the string after after `$1.` with your fingerprint.
|
||||
|
||||
Start nginx:
|
||||
|
||||
```
|
||||
# service nginx start
|
||||
```
|
||||
|
||||
It should now be possible to issue a cert (replace `example.com`
|
||||
with your domain name):
|
||||
|
||||
```
|
||||
# sudo -Hu acme -g acme acme.sh --issue -d example.com --stateless
|
||||
```
|
||||
|
||||
Let's add auto-renewal to `/etc/crontab`
|
||||
(replace `example.com` with your domain):
|
||||
|
||||
```
|
||||
/usr/local/bin/sudo -Hu acme -g acme /usr/local/sbin/acme.sh -r -d example.com --stateless
|
||||
```
|
||||
|
||||
### Configuring nginx
|
||||
|
||||
FreeBSD's default nginx configuration does not contain an include directive, which is
|
||||
typically used for multiple sites. Therefore, you will need to first create the required
|
||||
directory as follows:
|
||||
|
||||
|
||||
```
|
||||
# mkdir -p /usr/local/etc/nginx/sites-available
|
||||
```
|
||||
|
||||
Next, add an `include` directive to `/usr/local/etc/nginx/nginx.conf`, within the `http {}`
|
||||
block, as follows:
|
||||
|
||||
|
||||
```
|
||||
http {
|
||||
...
|
||||
include /usr/local/etc/nginx/sites-available/*;
|
||||
}
|
||||
```
|
||||
|
||||
As root, copy `/home/pleroma/pleroma/installation/pleroma.nginx` to
|
||||
`/usr/local/etc/nginx/sites-available/pleroma.nginx`.
|
||||
|
||||
Edit the defaults of `/usr/local/etc/nginx/sites-available/pleroma.nginx`:
|
||||
|
||||
* Change `ssl_trusted_certificate` to `/var/db/acme/certs/example.tld/example.tld.cer`.
|
||||
* Change `ssl_certificate` to `/var/db/acme/certs/example.tld/fullchain.cer`.
|
||||
* Change `ssl_certificate_key` to `/var/db/acme/certs/example.tld/example.tld.key`.
|
||||
* Change all references of `example.tld` to your instance's domain name.
|
||||
|
||||
## Creating a startup script for Pleroma
|
||||
|
||||
Pleroma will need to compile when it initially starts, which typically takes a longer
|
||||
period of time. Therefore, it is good practice to initially run pleroma from the
|
||||
command-line before utilizing the rc.d script. That is done as follows:
|
||||
|
||||
```
|
||||
# su -l pleroma
|
||||
$ cd $HOME/pleroma
|
||||
$ MIX_ENV=prod mix phx.server
|
||||
```
|
||||
|
||||
Copy the startup script to the correct location and make sure it's executable:
|
||||
|
||||
```
|
||||
# cp /home/pleroma/pleroma/installation/freebsd/rc.d/pleroma /usr/local/etc/rc.d/pleroma
|
||||
# chmod +x /usr/local/etc/rc.d/pleroma
|
||||
```
|
||||
|
||||
Update the `/etc/rc.conf` and start pleroma with the following commands:
|
||||
|
||||
```
|
||||
# sysrc pleroma_enable=YES
|
||||
# service pleroma start
|
||||
```
|
||||
|
||||
#### Create your first user
|
||||
|
||||
If your instance is up and running, you can create your first user with administrative rights with the following task:
|
||||
|
||||
```shell
|
||||
sudo -Hu pleroma MIX_ENV=prod mix pleroma.user new <username> <your@emailaddress> --admin
|
||||
```
|
||||
## Conclusion
|
||||
|
||||
Restart nginx with `# service nginx restart` and you should be up and running.
|
||||
|
||||
Make sure your time is in sync, or other instances will receive your posts with
|
||||
incorrect timestamps. You should have ntpd running.
|
||||
|
||||
## Questions
|
||||
|
||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
||||
|
|
@ -28,6 +28,7 @@ Gentoo quite pointedly does not come with a cron daemon installed, and as such i
|
|||
* `dev-db/postgresql`
|
||||
* `dev-lang/elixir`
|
||||
* `dev-vcs/git`
|
||||
* `dev-util/cmake`
|
||||
|
||||
#### Optional ebuilds used in this guide
|
||||
|
||||
|
|
@ -46,7 +47,7 @@ Gentoo quite pointedly does not come with a cron daemon installed, and as such i
|
|||
* Emerge all required the required and suggested software in one go:
|
||||
|
||||
```shell
|
||||
# emerge --ask dev-db/postgresql dev-lang/elixir dev-vcs/git www-servers/nginx app-crypt/certbot app-crypt/certbot-nginx
|
||||
# emerge --ask dev-db/postgresql dev-lang/elixir dev-vcs/git www-servers/nginx app-crypt/certbot app-crypt/certbot-nginx dev-util/cmake
|
||||
```
|
||||
|
||||
If you would not like to install the optional packages, remove them from this line.
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@ You will be running commands as root. If you aren't root already, please elevate
|
|||
|
||||
The system needs to have `curl` and `unzip` installed for downloading and unpacking release builds.
|
||||
|
||||
```sh tab="Alpine"
|
||||
=== "Alpine"
|
||||
```sh
|
||||
apk add curl unzip
|
||||
```
|
||||
|
||||
```sh tab="Debian/Ubuntu"
|
||||
=== "Debian/Ubuntu"
|
||||
```sh
|
||||
apt install curl unzip
|
||||
```
|
||||
|
||||
|
|
@ -110,7 +112,8 @@ OTP releases have different service files than from-source installs so they need
|
|||
|
||||
**Warning:** The service files assume pleroma user's home directory is `/opt/pleroma`, please make sure all paths fit your installation.
|
||||
|
||||
```sh tab="Alpine"
|
||||
=== "Alpine"
|
||||
```sh
|
||||
# Copy the service into a proper directory
|
||||
cp -f ~pleroma/installation/init.d/pleroma /etc/init.d/pleroma
|
||||
|
||||
|
|
@ -118,7 +121,8 @@ cp -f ~pleroma/installation/init.d/pleroma /etc/init.d/pleroma
|
|||
rc-service pleroma start
|
||||
```
|
||||
|
||||
```sh tab="Debian/Ubuntu"
|
||||
=== "Debian/Ubuntu"
|
||||
```sh
|
||||
# Copy the service into a proper directory
|
||||
cp ~pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ databases/postgresql11-client
|
|||
databases/postgresql11-server
|
||||
devel/git-base
|
||||
devel/git-docs
|
||||
devel/cmake
|
||||
lang/elixir
|
||||
security/acmesh
|
||||
security/sudo
|
||||
|
|
|
|||
|
|
@ -14,11 +14,12 @@ The following packages need to be installed:
|
|||
* git
|
||||
* postgresql-server
|
||||
* postgresql-contrib
|
||||
* cmake
|
||||
|
||||
To install them, run the following command (with doas or as root):
|
||||
|
||||
```
|
||||
pkg_add elixir gmake ImageMagick git postgresql-server postgresql-contrib
|
||||
pkg_add elixir gmake ImageMagick git postgresql-server postgresql-contrib cmake
|
||||
```
|
||||
|
||||
Pleroma requires a reverse proxy, OpenBSD has relayd in base (and is used in this guide) and packages/ports are available for nginx (www/nginx) and apache (www/apache-httpd). Independently of the reverse proxy, [acme-client(1)](https://man.openbsd.org/acme-client) can be used to get a certificate from Let's Encrypt.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ Matrix-kanava #freenode_#pleroma:matrix.org ovat hyviä paikkoja löytää apua
|
|||
|
||||
Asenna tarvittava ohjelmisto:
|
||||
|
||||
`# pkg_add git elixir gmake postgresql-server-10.3 postgresql-contrib-10.3`
|
||||
`# pkg_add git elixir gmake postgresql-server-10.3 postgresql-contrib-10.3 cmake`
|
||||
|
||||
Luo postgresql-tietokanta:
|
||||
|
||||
|
|
|
|||
|
|
@ -28,13 +28,15 @@ Other than things bundled in the OTP release Pleroma depends on:
|
|||
* nginx (could be swapped with another reverse proxy but this guide covers only it)
|
||||
* certbot (for Let's Encrypt certificates, could be swapped with another ACME client, but this guide covers only it)
|
||||
|
||||
```sh tab="Alpine"
|
||||
=== "Alpine"
|
||||
```
|
||||
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
|
||||
apk update
|
||||
apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot
|
||||
```
|
||||
|
||||
```sh tab="Debian/Ubuntu"
|
||||
=== "Debian/Ubuntu"
|
||||
```
|
||||
apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot
|
||||
```
|
||||
|
||||
|
|
@ -47,7 +49,8 @@ apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot
|
|||
|
||||
RUM indexes are an alternative indexing scheme that is not included in PostgreSQL by default. You can read more about them on the [Configuration page](../configuration/cheatsheet.md#rum-indexing-for-full-text-search). They are completely optional and most of the time are not worth it, especially if you are running a single user instance (unless you absolutely need ordered search results).
|
||||
|
||||
```sh tab="Alpine"
|
||||
=== "Alpine"
|
||||
```
|
||||
apk add git build-base postgresql-dev
|
||||
git clone https://github.com/postgrespro/rum /tmp/rum
|
||||
cd /tmp/rum
|
||||
|
|
@ -57,7 +60,8 @@ cd
|
|||
rm -r /tmp/rum
|
||||
```
|
||||
|
||||
```sh tab="Debian/Ubuntu"
|
||||
=== "Debian/Ubuntu"
|
||||
```
|
||||
# Available only on Buster/19.04
|
||||
apt install postgresql-11-rum
|
||||
```
|
||||
|
|
@ -65,11 +69,13 @@ apt install postgresql-11-rum
|
|||
#### (Optional) Performance configuration
|
||||
It is encouraged to check [Optimizing your PostgreSQL performance](../configuration/postgresql.md) document, for tips on PostgreSQL tuning.
|
||||
|
||||
```sh tab="Alpine"
|
||||
=== "Alpine"
|
||||
```
|
||||
rc-service postgresql restart
|
||||
```
|
||||
|
||||
```sh tab="Debian/Ubuntu"
|
||||
=== "Debian/Ubuntu"
|
||||
```
|
||||
systemctl restart postgresql
|
||||
```
|
||||
|
||||
|
|
@ -121,9 +127,6 @@ chown -R pleroma /etc/pleroma
|
|||
# Run the config generator
|
||||
su pleroma -s $SHELL -lc "./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql"
|
||||
|
||||
# Run the environment file generator.
|
||||
su pleroma -s $SHELL -lc "./bin/pleroma_ctl release_env gen"
|
||||
|
||||
# Create the postgres database
|
||||
su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"
|
||||
|
||||
|
|
@ -134,7 +137,7 @@ su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
|
|||
# su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
|
||||
|
||||
# Start the instance to verify that everything is working as expected
|
||||
su pleroma -s $SHELL -lc "export $(cat /opt/pleroma/config/pleroma.env); ./bin/pleroma daemon"
|
||||
su pleroma -s $SHELL -lc "./bin/pleroma daemon"
|
||||
|
||||
# Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly
|
||||
sleep 20 && curl http://localhost:4000/api/v1/instance
|
||||
|
|
@ -154,11 +157,13 @@ certbot certonly --standalone --preferred-challenges http -d yourinstance.tld
|
|||
|
||||
The location of nginx configs is dependent on the distro
|
||||
|
||||
```sh tab="Alpine"
|
||||
=== "Alpine"
|
||||
```
|
||||
cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/conf.d/pleroma.conf
|
||||
```
|
||||
|
||||
```sh tab="Debian/Ubuntu"
|
||||
=== "Debian/Ubuntu"
|
||||
```
|
||||
cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/sites-available/pleroma.conf
|
||||
ln -s /etc/nginx/sites-available/pleroma.conf /etc/nginx/sites-enabled/pleroma.conf
|
||||
```
|
||||
|
|
@ -178,11 +183,13 @@ nginx -t
|
|||
```
|
||||
#### Start nginx
|
||||
|
||||
```sh tab="Alpine"
|
||||
=== "Alpine"
|
||||
```
|
||||
rc-service nginx start
|
||||
```
|
||||
|
||||
```sh tab="Debian/Ubuntu"
|
||||
=== "Debian/Ubuntu"
|
||||
```
|
||||
systemctl start nginx
|
||||
```
|
||||
|
||||
|
|
@ -190,7 +197,8 @@ At this point if you open your (sub)domain in a browser you should see a 502 err
|
|||
|
||||
### Setting up a system service
|
||||
|
||||
```sh tab="Alpine"
|
||||
=== "Alpine"
|
||||
```
|
||||
# Copy the service into a proper directory
|
||||
cp /opt/pleroma/installation/init.d/pleroma /etc/init.d/pleroma
|
||||
|
||||
|
|
@ -199,11 +207,11 @@ rc-service pleroma start
|
|||
rc-update add pleroma
|
||||
```
|
||||
|
||||
```sh tab="Debian/Ubuntu"
|
||||
=== "Debian/Ubuntu"
|
||||
```
|
||||
# Copy the service into a proper directory
|
||||
cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
|
||||
|
||||
|
||||
# Start pleroma and enable it on boot
|
||||
systemctl start pleroma
|
||||
systemctl enable pleroma
|
||||
|
|
@ -227,7 +235,8 @@ $EDITOR path-to-nginx-config
|
|||
nginx -t
|
||||
```
|
||||
|
||||
```sh tab="Alpine"
|
||||
=== "Alpine"
|
||||
```
|
||||
# Restart nginx
|
||||
rc-service nginx restart
|
||||
|
||||
|
|
@ -248,7 +257,8 @@ chmod +x /etc/periodic/daily/renew-pleroma-cert
|
|||
run-parts --test /etc/periodic/daily
|
||||
```
|
||||
|
||||
```sh tab="Debian/Ubuntu"
|
||||
=== "Debian/Ubuntu"
|
||||
```
|
||||
# Restart nginx
|
||||
systemctl restart nginx
|
||||
|
||||
|
|
@ -279,3 +289,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**.
|
||||
|
||||
|
|
|
|||
27
installation/freebsd/rc.d/pleroma
Executable file
27
installation/freebsd/rc.d/pleroma
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
# PROVIDE: pleroma
|
||||
# REQUIRE: DAEMON postgresql
|
||||
# KEYWORD: shutdown
|
||||
|
||||
# sudo -u pleroma MIX_ENV=prod elixir --erl \"-detached\" -S mix phx.server
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name=pleroma
|
||||
rcvar=pleroma_enable
|
||||
|
||||
desc="Pleroma Social Media Platform"
|
||||
|
||||
load_rc_config ${name}
|
||||
|
||||
: ${pleroma_user:=pleroma}
|
||||
: ${pleroma_home:=$(getent passwd ${pleroma_user} | awk -F: '{print $6}')}
|
||||
: ${pleroma_chdir:="${pleroma_home}/pleroma"}
|
||||
: ${pleroma_env:="HOME=${pleroma_home} MIX_ENV=prod"}
|
||||
|
||||
command=/usr/local/bin/elixir
|
||||
command_args="--erl \"-detached\" -S /usr/local/bin/mix phx.server"
|
||||
procname="*beam.smp"
|
||||
|
||||
run_rc_command "$1"
|
||||
|
|
@ -8,7 +8,6 @@ pidfile="/var/run/pleroma.pid"
|
|||
directory=/opt/pleroma
|
||||
healthcheck_delay=60
|
||||
healthcheck_timer=30
|
||||
export $(cat /opt/pleroma/config/pleroma.env)
|
||||
|
||||
: ${pleroma_port:-4000}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@ defmodule Mix.Pleroma do
|
|||
:swoosh,
|
||||
:timex
|
||||
]
|
||||
@cachex_children ["object", "user"]
|
||||
@cachex_children ["object", "user", "scrubber"]
|
||||
@doc "Common functions to be reused in mix tasks"
|
||||
def start_pleroma do
|
||||
Pleroma.Config.Holder.save_default()
|
||||
Pleroma.Config.Oban.warn()
|
||||
Application.put_env(:phoenix, :serve_endpoints, false, persistent: true)
|
||||
|
||||
if Pleroma.Config.get(:env) != :test do
|
||||
|
|
|
|||
|
|
@ -91,20 +91,17 @@ defmodule Mix.Tasks.Pleroma.Benchmark do
|
|||
"Without conn and without pool" => fn ->
|
||||
{:ok, %Tesla.Env{}} =
|
||||
Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
|
||||
adapter: [pool: :no_pool, receive_conn: false]
|
||||
pool: :no_pool,
|
||||
receive_conn: false
|
||||
)
|
||||
end,
|
||||
"Without conn and with pool" => fn ->
|
||||
{:ok, %Tesla.Env{}} =
|
||||
Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
|
||||
adapter: [receive_conn: false]
|
||||
)
|
||||
Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [], receive_conn: false)
|
||||
end,
|
||||
"With reused conn and without pool" => fn ->
|
||||
{:ok, %Tesla.Env{}} =
|
||||
Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [],
|
||||
adapter: [pool: :no_pool]
|
||||
)
|
||||
Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500", [], pool: :no_pool)
|
||||
end,
|
||||
"With reused conn and with pool" => fn ->
|
||||
{:ok, %Tesla.Env{}} = Pleroma.HTTP.get("https://httpbin.org/stream-bytes/1500")
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ defmodule Mix.Tasks.Pleroma.Config do
|
|||
|
||||
@spec migrate_to_db(Path.t() | nil) :: any()
|
||||
def migrate_to_db(file_path \\ nil) do
|
||||
if Pleroma.Config.get([:configurable_from_database]) do
|
||||
with true <- Pleroma.Config.get([:configurable_from_database]),
|
||||
:ok <- Pleroma.Config.DeprecationWarnings.warn() do
|
||||
config_file =
|
||||
if file_path do
|
||||
file_path
|
||||
|
|
@ -46,7 +47,8 @@ defmodule Mix.Tasks.Pleroma.Config do
|
|||
|
||||
do_migrate_to_db(config_file)
|
||||
else
|
||||
migration_error()
|
||||
:error -> deprecation_error()
|
||||
_ -> migration_error()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -120,6 +122,10 @@ defmodule Mix.Tasks.Pleroma.Config do
|
|||
)
|
||||
end
|
||||
|
||||
defp deprecation_error do
|
||||
shell_error("Migration is not allowed until all deprecation warnings have been resolved.")
|
||||
end
|
||||
|
||||
if Code.ensure_loaded?(Config.Reader) do
|
||||
defp config_header, do: "import Config\r\n\r\n"
|
||||
defp read_file(config_file), do: Config.Reader.read_imports!(config_file)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
alias Pleroma.User
|
||||
require Logger
|
||||
require Pleroma.Constants
|
||||
import Ecto.Query
|
||||
import Mix.Pleroma
|
||||
use Mix.Task
|
||||
|
||||
|
|
@ -53,8 +54,6 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
end
|
||||
|
||||
def run(["prune_objects" | args]) do
|
||||
import Ecto.Query
|
||||
|
||||
{options, [], []} =
|
||||
OptionParser.parse(
|
||||
args,
|
||||
|
|
@ -94,15 +93,13 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
end
|
||||
|
||||
def run(["fix_likes_collections"]) do
|
||||
import Ecto.Query
|
||||
|
||||
start_pleroma()
|
||||
|
||||
from(object in Object,
|
||||
where: fragment("(?)->>'likes' is not null", object.data),
|
||||
select: %{id: object.id, likes: fragment("(?)->>'likes'", object.data)}
|
||||
)
|
||||
|> Pleroma.RepoStreamer.chunk_stream(100)
|
||||
|> Pleroma.Repo.chunk_stream(100, :batches)
|
||||
|> Stream.each(fn objects ->
|
||||
ids =
|
||||
objects
|
||||
|
|
@ -130,4 +127,38 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
|
||||
Maintenance.vacuum(args)
|
||||
end
|
||||
|
||||
def run(["ensure_expiration"]) do
|
||||
start_pleroma()
|
||||
days = Pleroma.Config.get([:mrf_activity_expiration, :days], 365)
|
||||
|
||||
Pleroma.Activity
|
||||
|> join(:inner, [a], o in Object,
|
||||
on:
|
||||
fragment(
|
||||
"(?->>'id') = COALESCE((?)->'object'->> 'id', (?)->>'object')",
|
||||
o.data,
|
||||
a.data,
|
||||
a.data
|
||||
)
|
||||
)
|
||||
|> where(local: true)
|
||||
|> where([a], fragment("(? ->> 'type'::text) = 'Create'", a.data))
|
||||
|> where([_a, o], fragment("?->>'type' = 'Note'", o.data))
|
||||
|> Pleroma.Repo.chunk_stream(100, :batches)
|
||||
|> Stream.each(fn activities ->
|
||||
Enum.each(activities, fn activity ->
|
||||
expires_at =
|
||||
activity.inserted_at
|
||||
|> DateTime.from_naive!("Etc/UTC")
|
||||
|> Timex.shift(days: days)
|
||||
|
||||
Pleroma.Workers.PurgeExpiredActivity.enqueue(%{
|
||||
activity_id: activity.id,
|
||||
expires_at: expires_at
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|> Stream.run()
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ defmodule Mix.Tasks.Pleroma.Ecto.Migrate do
|
|||
load_pleroma()
|
||||
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
|
||||
|
||||
if Application.get_env(:pleroma, Pleroma.Repo)[:ssl] do
|
||||
Application.ensure_all_started(:ssl)
|
||||
end
|
||||
|
||||
opts =
|
||||
if opts[:to] || opts[:step] || opts[:all],
|
||||
do: opts,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ defmodule Mix.Tasks.Pleroma.Ecto.Rollback do
|
|||
load_pleroma()
|
||||
{opts, _} = OptionParser.parse!(args, strict: @switches, aliases: @aliases)
|
||||
|
||||
if Application.get_env(:pleroma, Pleroma.Repo)[:ssl] do
|
||||
Application.ensure_all_started(:ssl)
|
||||
end
|
||||
|
||||
opts =
|
||||
if opts[:to] || opts[:step] || opts[:all],
|
||||
do: opts,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
|
|||
{options, [], []} = parse_global_opts(args)
|
||||
|
||||
url_or_path = options[:manifest] || default_manifest()
|
||||
manifest = fetch_and_decode(url_or_path)
|
||||
manifest = fetch_and_decode!(url_or_path)
|
||||
|
||||
Enum.each(manifest, fn {name, info} ->
|
||||
to_print = [
|
||||
|
|
@ -42,7 +42,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
|
|||
|
||||
url_or_path = options[:manifest] || default_manifest()
|
||||
|
||||
manifest = fetch_and_decode(url_or_path)
|
||||
manifest = fetch_and_decode!(url_or_path)
|
||||
|
||||
for pack_name <- pack_names do
|
||||
if Map.has_key?(manifest, pack_name) do
|
||||
|
|
@ -92,7 +92,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
|
|||
])
|
||||
)
|
||||
|
||||
files = fetch_and_decode(files_loc)
|
||||
files = fetch_and_decode!(files_loc)
|
||||
|
||||
IO.puts(IO.ANSI.format(["Unpacking ", :bright, pack_name]))
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
|
|||
|
||||
IO.puts("Downloading the pack and generating SHA256")
|
||||
|
||||
binary_archive = Tesla.get!(client(), src).body
|
||||
{:ok, %{body: binary_archive}} = Pleroma.HTTP.get(src)
|
||||
archive_sha = :crypto.hash(:sha256, binary_archive) |> Base.encode16()
|
||||
|
||||
IO.puts("SHA256 is #{archive_sha}")
|
||||
|
|
@ -243,14 +243,16 @@ defmodule Mix.Tasks.Pleroma.Emoji do
|
|||
IO.puts("Emoji packs have been reloaded.")
|
||||
end
|
||||
|
||||
defp fetch_and_decode(from) do
|
||||
defp fetch_and_decode!(from) do
|
||||
with {:ok, json} <- fetch(from) do
|
||||
Jason.decode!(json)
|
||||
else
|
||||
{:error, error} -> raise "#{from} cannot be fetched. Error: #{error} occur."
|
||||
end
|
||||
end
|
||||
|
||||
defp fetch("http" <> _ = from) do
|
||||
with {:ok, %{body: body}} <- Tesla.get(client(), from) do
|
||||
with {:ok, %{body: body}} <- Pleroma.HTTP.get(from) do
|
||||
{:ok, body}
|
||||
end
|
||||
end
|
||||
|
|
@ -269,13 +271,5 @@ defmodule Mix.Tasks.Pleroma.Emoji do
|
|||
)
|
||||
end
|
||||
|
||||
defp client do
|
||||
middleware = [
|
||||
{Tesla.Middleware.FollowRedirects, [max_redirects: 3]}
|
||||
]
|
||||
|
||||
Tesla.client(middleware)
|
||||
end
|
||||
|
||||
defp default_manifest, do: Pleroma.Config.get!([:emoji, :default_manifest])
|
||||
end
|
||||
|
|
|
|||
141
lib/mix/tasks/pleroma/frontend.ex
Normal file
141
lib/mix/tasks/pleroma/frontend.ex
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.Frontend do
|
||||
use Mix.Task
|
||||
|
||||
import Mix.Pleroma
|
||||
|
||||
@shortdoc "Manages bundled Pleroma frontends"
|
||||
|
||||
@moduledoc File.read!("docs/administration/CLI_tasks/frontend.md")
|
||||
|
||||
def run(["install", "none" | _args]) do
|
||||
shell_info("Skipping frontend installation because none was requested")
|
||||
"none"
|
||||
end
|
||||
|
||||
def run(["install", frontend | args]) do
|
||||
log_level = Logger.level()
|
||||
Logger.configure(level: :warn)
|
||||
start_pleroma()
|
||||
|
||||
{options, [], []} =
|
||||
OptionParser.parse(
|
||||
args,
|
||||
strict: [
|
||||
ref: :string,
|
||||
static_dir: :string,
|
||||
build_url: :string,
|
||||
build_dir: :string,
|
||||
file: :string
|
||||
]
|
||||
)
|
||||
|
||||
instance_static_dir =
|
||||
with nil <- options[:static_dir] do
|
||||
Pleroma.Config.get!([:instance, :static_dir])
|
||||
end
|
||||
|
||||
cmd_frontend_info = %{
|
||||
"name" => frontend,
|
||||
"ref" => options[:ref],
|
||||
"build_url" => options[:build_url],
|
||||
"build_dir" => options[:build_dir]
|
||||
}
|
||||
|
||||
config_frontend_info = Pleroma.Config.get([:frontends, :available, frontend], %{})
|
||||
|
||||
frontend_info =
|
||||
Map.merge(config_frontend_info, cmd_frontend_info, fn _key, config, cmd ->
|
||||
# This only overrides things that are actually set
|
||||
cmd || config
|
||||
end)
|
||||
|
||||
ref = frontend_info["ref"]
|
||||
|
||||
unless ref do
|
||||
raise "No ref given or configured"
|
||||
end
|
||||
|
||||
dest =
|
||||
Path.join([
|
||||
instance_static_dir,
|
||||
"frontends",
|
||||
frontend,
|
||||
ref
|
||||
])
|
||||
|
||||
fe_label = "#{frontend} (#{ref})"
|
||||
|
||||
tmp_dir = Path.join([instance_static_dir, "frontends", "tmp"])
|
||||
|
||||
with {_, :ok} <-
|
||||
{:download_or_unzip, download_or_unzip(frontend_info, tmp_dir, options[:file])},
|
||||
shell_info("Installing #{fe_label} to #{dest}"),
|
||||
:ok <- install_frontend(frontend_info, tmp_dir, dest) do
|
||||
File.rm_rf!(tmp_dir)
|
||||
shell_info("Frontend #{fe_label} installed to #{dest}")
|
||||
|
||||
Logger.configure(level: log_level)
|
||||
else
|
||||
{:download_or_unzip, _} ->
|
||||
shell_info("Could not download or unzip the frontend")
|
||||
|
||||
_e ->
|
||||
shell_info("Could not install the frontend")
|
||||
end
|
||||
end
|
||||
|
||||
defp download_or_unzip(frontend_info, temp_dir, file) do
|
||||
if file do
|
||||
with {:ok, zip} <- File.read(Path.expand(file)) do
|
||||
unzip(zip, temp_dir)
|
||||
end
|
||||
else
|
||||
download_build(frontend_info, temp_dir)
|
||||
end
|
||||
end
|
||||
|
||||
def unzip(zip, dest) do
|
||||
with {:ok, unzipped} <- :zip.unzip(zip, [:memory]) do
|
||||
File.rm_rf!(dest)
|
||||
File.mkdir_p!(dest)
|
||||
|
||||
Enum.each(unzipped, fn {filename, data} ->
|
||||
path = filename
|
||||
|
||||
new_file_path = Path.join(dest, path)
|
||||
|
||||
new_file_path
|
||||
|> Path.dirname()
|
||||
|> File.mkdir_p!()
|
||||
|
||||
File.write!(new_file_path, data)
|
||||
end)
|
||||
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
defp download_build(frontend_info, dest) do
|
||||
shell_info("Downloading pre-built bundle for #{frontend_info["name"]}")
|
||||
url = String.replace(frontend_info["build_url"], "${ref}", frontend_info["ref"])
|
||||
|
||||
with {:ok, %{status: 200, body: zip_body}} <-
|
||||
Pleroma.HTTP.get(url, [], pool: :media, recv_timeout: 120_000) do
|
||||
unzip(zip_body, dest)
|
||||
else
|
||||
e -> {:error, e}
|
||||
end
|
||||
end
|
||||
|
||||
defp install_frontend(frontend_info, source, dest) do
|
||||
from = frontend_info["build_dir"] || "dist"
|
||||
File.rm_rf!(dest)
|
||||
File.mkdir_p!(dest)
|
||||
File.cp_r!(Path.join([source, from]), dest)
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
|
@ -35,10 +35,16 @@ defmodule Mix.Tasks.Pleroma.Relay do
|
|||
def run(["list"]) do
|
||||
start_pleroma()
|
||||
|
||||
with {:ok, list} <- Relay.list(true) do
|
||||
list |> Enum.each(&shell_info(&1))
|
||||
with {:ok, list} <- Relay.list() do
|
||||
Enum.each(list, &print_relay_url/1)
|
||||
else
|
||||
{:error, e} -> shell_error("Error while fetching relay subscription list: #{inspect(e)}")
|
||||
end
|
||||
end
|
||||
|
||||
defp print_relay_url(%{followed_back: false} = relay) do
|
||||
shell_info("#{relay.actor} - no Accept received (relay didn't follow back)")
|
||||
end
|
||||
|
||||
defp print_relay_url(relay), do: shell_info(relay.actor)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,76 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.ReleaseEnv do
|
||||
use Mix.Task
|
||||
import Mix.Pleroma
|
||||
|
||||
@shortdoc "Generate Pleroma environment file."
|
||||
@moduledoc File.read!("docs/administration/CLI_tasks/release_environments.md")
|
||||
|
||||
def run(["gen" | rest]) do
|
||||
{options, [], []} =
|
||||
OptionParser.parse(
|
||||
rest,
|
||||
strict: [
|
||||
force: :boolean,
|
||||
path: :string
|
||||
],
|
||||
aliases: [
|
||||
p: :path,
|
||||
f: :force
|
||||
]
|
||||
)
|
||||
|
||||
file_path =
|
||||
get_option(
|
||||
options,
|
||||
:path,
|
||||
"Environment file path",
|
||||
"./config/pleroma.env"
|
||||
)
|
||||
|
||||
env_path = Path.expand(file_path)
|
||||
|
||||
proceed? =
|
||||
if File.exists?(env_path) do
|
||||
get_option(
|
||||
options,
|
||||
:force,
|
||||
"Environment file already exists. Do you want to overwrite the #{env_path} file? (y/n)",
|
||||
"n"
|
||||
) === "y"
|
||||
else
|
||||
true
|
||||
end
|
||||
|
||||
if proceed? do
|
||||
case do_generate(env_path) do
|
||||
{:error, reason} ->
|
||||
shell_error(
|
||||
File.Error.message(%{action: "write to file", reason: reason, path: env_path})
|
||||
)
|
||||
|
||||
_ ->
|
||||
shell_info("\nThe file generated: #{env_path}.\n")
|
||||
|
||||
shell_info("""
|
||||
WARNING: before start pleroma app please make sure to make the file read-only and non-modifiable.
|
||||
Example:
|
||||
chmod 0444 #{file_path}
|
||||
chattr +i #{file_path}
|
||||
""")
|
||||
end
|
||||
else
|
||||
shell_info("\nThe file is exist. #{env_path}.\n")
|
||||
end
|
||||
end
|
||||
|
||||
def do_generate(path) do
|
||||
content = "RELEASE_COOKIE=#{Base.encode32(:crypto.strong_rand_bytes(32))}"
|
||||
|
||||
File.mkdir_p!(Path.dirname(path))
|
||||
File.write(path, content)
|
||||
end
|
||||
end
|
||||
|
|
@ -179,7 +179,7 @@ defmodule Mix.Tasks.Pleroma.User do
|
|||
start_pleroma()
|
||||
|
||||
Pleroma.User.Query.build(%{nickname: "@#{instance}"})
|
||||
|> Pleroma.RepoStreamer.chunk_stream(500)
|
||||
|> Pleroma.Repo.chunk_stream(500, :batches)
|
||||
|> Stream.each(fn users ->
|
||||
users
|
||||
|> Enum.each(fn user ->
|
||||
|
|
@ -370,7 +370,7 @@ defmodule Mix.Tasks.Pleroma.User do
|
|||
start_pleroma()
|
||||
|
||||
Pleroma.User.Query.build(%{local: true})
|
||||
|> Pleroma.RepoStreamer.chunk_stream(500)
|
||||
|> Pleroma.Repo.chunk_stream(500, :batches)
|
||||
|> Stream.each(fn users ->
|
||||
users
|
||||
|> Enum.each(fn user ->
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ defmodule Pleroma.Activity do
|
|||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Activity.Queries
|
||||
alias Pleroma.ActivityExpiration
|
||||
alias Pleroma.Bookmark
|
||||
alias Pleroma.Notification
|
||||
alias Pleroma.Object
|
||||
|
|
@ -60,8 +59,6 @@ defmodule Pleroma.Activity do
|
|||
# typical case.
|
||||
has_one(:object, Object, on_delete: :nothing, foreign_key: :id)
|
||||
|
||||
has_one(:expiration, ActivityExpiration, on_delete: :delete_all)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
|
|
@ -304,14 +301,14 @@ defmodule Pleroma.Activity do
|
|||
|> Repo.all()
|
||||
end
|
||||
|
||||
def follow_requests_for_actor(%Pleroma.User{ap_id: ap_id}) do
|
||||
def follow_requests_for_actor(%User{ap_id: ap_id}) do
|
||||
ap_id
|
||||
|> Queries.by_object_id()
|
||||
|> Queries.by_type("Follow")
|
||||
|> where([a], fragment("? ->> 'state' = 'pending'", a.data))
|
||||
end
|
||||
|
||||
def following_requests_for_actor(%Pleroma.User{ap_id: ap_id}) do
|
||||
def following_requests_for_actor(%User{ap_id: ap_id}) do
|
||||
Queries.by_type("Follow")
|
||||
|> where([a], fragment("?->>'state' = 'pending'", a.data))
|
||||
|> where([a], a.actor == ^ap_id)
|
||||
|
|
@ -340,4 +337,10 @@ defmodule Pleroma.Activity do
|
|||
_ -> nil
|
||||
end
|
||||
end
|
||||
|
||||
@spec pinned_by_actor?(Activity.t()) :: boolean()
|
||||
def pinned_by_actor?(%Activity{} = activity) do
|
||||
actor = user_actor(activity)
|
||||
activity.id in actor.pinned_activities
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,67 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.ActivityExpiration do
|
||||
use Ecto.Schema
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.ActivityExpiration
|
||||
alias Pleroma.Repo
|
||||
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
|
||||
@type t :: %__MODULE__{}
|
||||
@min_activity_lifetime :timer.hours(1)
|
||||
|
||||
schema "activity_expirations" do
|
||||
belongs_to(:activity, Activity, type: FlakeId.Ecto.CompatType)
|
||||
field(:scheduled_at, :naive_datetime)
|
||||
end
|
||||
|
||||
def changeset(%ActivityExpiration{} = expiration, attrs) do
|
||||
expiration
|
||||
|> cast(attrs, [:scheduled_at])
|
||||
|> validate_required([:scheduled_at])
|
||||
|> validate_scheduled_at()
|
||||
end
|
||||
|
||||
def get_by_activity_id(activity_id) do
|
||||
ActivityExpiration
|
||||
|> where([exp], exp.activity_id == ^activity_id)
|
||||
|> Repo.one()
|
||||
end
|
||||
|
||||
def create(%Activity{} = activity, scheduled_at) do
|
||||
%ActivityExpiration{activity_id: activity.id}
|
||||
|> changeset(%{scheduled_at: scheduled_at})
|
||||
|> Repo.insert()
|
||||
end
|
||||
|
||||
def due_expirations(offset \\ 0) do
|
||||
naive_datetime =
|
||||
NaiveDateTime.utc_now()
|
||||
|> NaiveDateTime.add(offset, :millisecond)
|
||||
|
||||
ActivityExpiration
|
||||
|> where([exp], exp.scheduled_at < ^naive_datetime)
|
||||
|> Repo.all()
|
||||
end
|
||||
|
||||
def validate_scheduled_at(changeset) do
|
||||
validate_change(changeset, :scheduled_at, fn _, scheduled_at ->
|
||||
if not expires_late_enough?(scheduled_at) do
|
||||
[scheduled_at: "an ephemeral activity must live for at least one hour"]
|
||||
else
|
||||
[]
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
def expires_late_enough?(scheduled_at) do
|
||||
now = NaiveDateTime.utc_now()
|
||||
diff = NaiveDateTime.diff(scheduled_at, now, :millisecond)
|
||||
diff > @min_activity_lifetime
|
||||
end
|
||||
end
|
||||
|
|
@ -22,6 +22,7 @@ defmodule Pleroma.Application do
|
|||
def repository, do: @repository
|
||||
|
||||
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], "")}>"
|
||||
|
|
@ -30,6 +31,10 @@ defmodule Pleroma.Application do
|
|||
custom ->
|
||||
custom
|
||||
end
|
||||
else
|
||||
# fallback, if endpoint is not started yet
|
||||
"Pleroma Data Loader"
|
||||
end
|
||||
end
|
||||
|
||||
# See http://elixir-lang.org/docs/stable/elixir/Application.html
|
||||
|
|
@ -39,14 +44,19 @@ defmodule Pleroma.Application do
|
|||
# every time the application is restarted, so we disable module
|
||||
# conflicts at runtime
|
||||
Code.compiler_options(ignore_module_conflict: true)
|
||||
# Disable warnings_as_errors at runtime, it breaks Phoenix live reload
|
||||
# due to protocol consolidation warnings
|
||||
Code.compiler_options(warnings_as_errors: false)
|
||||
Pleroma.Telemetry.Logger.attach()
|
||||
Config.Holder.save_default()
|
||||
Pleroma.HTML.compile_scrubbers()
|
||||
Pleroma.Config.Oban.warn()
|
||||
Config.DeprecationWarnings.warn()
|
||||
Pleroma.Plugs.HTTPSecurityPlug.warn_if_disabled()
|
||||
Pleroma.ApplicationRequirements.verify!()
|
||||
setup_instrumenters()
|
||||
load_custom_modules()
|
||||
check_system_commands()
|
||||
Pleroma.Docs.JSON.compile()
|
||||
|
||||
adapter = Application.get_env(:tesla, :adapter)
|
||||
|
|
@ -249,4 +259,21 @@ defmodule Pleroma.Application do
|
|||
end
|
||||
|
||||
defp http_children(_, _), do: []
|
||||
|
||||
defp check_system_commands do
|
||||
filters = Config.get([Pleroma.Upload, :filters])
|
||||
|
||||
check_filter = fn filter, command_required ->
|
||||
with true <- filter in filters,
|
||||
false <- Pleroma.Utils.command_available?(command_required) do
|
||||
Logger.error(
|
||||
"#{filter} is specified in list of Pleroma.Upload filters, but the #{command_required} command is not found"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
check_filter.(Pleroma.Upload.Filters.Exiftool, "exiftool")
|
||||
check_filter.(Pleroma.Upload.Filters.Mogrify, "mogrify")
|
||||
check_filter.(Pleroma.Upload.Filters.Mogrifun, "mogrify")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ defmodule Pleroma.Chat do
|
|||
use Ecto.Schema
|
||||
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
|
||||
alias Pleroma.Chat
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
|
||||
|
|
@ -69,4 +71,12 @@ defmodule Pleroma.Chat do
|
|||
conflict_target: [:user_id, :recipient]
|
||||
)
|
||||
end
|
||||
|
||||
@spec for_user_query(FlakeId.Ecto.CompatType.t()) :: Ecto.Query.t()
|
||||
def for_user_query(user_id) do
|
||||
from(c in Chat,
|
||||
where: c.user_id == ^user_id,
|
||||
order_by: [desc: c.updated_at]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,12 +11,10 @@ defmodule Pleroma.Config do
|
|||
|
||||
def get([key], default), do: get(key, default)
|
||||
|
||||
def get([parent_key | keys], default) do
|
||||
case :pleroma
|
||||
|> Application.get_env(parent_key)
|
||||
|> get_in(keys) do
|
||||
nil -> default
|
||||
any -> any
|
||||
def get([_ | _] = path, default) do
|
||||
case fetch(path) do
|
||||
{:ok, value} -> value
|
||||
:error -> default
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -34,6 +32,24 @@ defmodule Pleroma.Config do
|
|||
end
|
||||
end
|
||||
|
||||
def fetch(key) when is_atom(key), do: fetch([key])
|
||||
|
||||
def fetch([root_key | keys]) do
|
||||
Enum.reduce_while(keys, Application.fetch_env(:pleroma, root_key), fn
|
||||
key, {:ok, config} when is_map(config) or is_list(config) ->
|
||||
case Access.fetch(config, key) do
|
||||
:error ->
|
||||
{:halt, :error}
|
||||
|
||||
value ->
|
||||
{:cont, value}
|
||||
end
|
||||
|
||||
_key, _config ->
|
||||
{:halt, :error}
|
||||
end)
|
||||
end
|
||||
|
||||
def put([key], value), do: put(key, value)
|
||||
|
||||
def put([parent_key | keys], value) do
|
||||
|
|
@ -50,18 +66,31 @@ defmodule Pleroma.Config do
|
|||
|
||||
def delete([key]), do: delete(key)
|
||||
|
||||
def delete([parent_key | keys]) do
|
||||
def delete([parent_key | keys] = path) do
|
||||
with {:ok, _} <- fetch(path) do
|
||||
{_, parent} =
|
||||
Application.get_env(:pleroma, parent_key)
|
||||
parent_key
|
||||
|> get()
|
||||
|> get_and_update_in(keys, fn _ -> :pop end)
|
||||
|
||||
Application.put_env(:pleroma, parent_key, parent)
|
||||
end
|
||||
end
|
||||
|
||||
def delete(key) do
|
||||
Application.delete_env(:pleroma, key)
|
||||
end
|
||||
|
||||
def restrict_unauthenticated_access?(resource, kind) do
|
||||
setting = get([:restrict_unauthenticated, resource, kind])
|
||||
|
||||
if setting in [nil, :if_instance_is_private] do
|
||||
!get!([:instance, :public])
|
||||
else
|
||||
setting
|
||||
end
|
||||
end
|
||||
|
||||
def oauth_consumer_strategies, do: get([:auth, :oauth_consumer_strategies], [])
|
||||
|
||||
def oauth_consumer_enabled?, do: oauth_consumer_strategies() != []
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
|||
require Logger
|
||||
alias Pleroma.Config
|
||||
|
||||
@type config_namespace() :: [atom()]
|
||||
@type config_namespace() :: atom() | [atom()]
|
||||
@type config_map() :: {config_namespace(), config_namespace(), String.t()}
|
||||
|
||||
@mrf_config_map [
|
||||
|
|
@ -26,6 +26,10 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
|||
!!!DEPRECATION WARNING!!!
|
||||
You are using the old configuration mechanism for the hellthread filter. Please check config.md.
|
||||
""")
|
||||
|
||||
:error
|
||||
else
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -47,15 +51,26 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
|||
|
||||
config :pleroma, :mrf_user_allowlist, #{inspect(rewritten, pretty: true)}
|
||||
""")
|
||||
|
||||
:error
|
||||
else
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
def warn do
|
||||
check_hellthread_threshold()
|
||||
mrf_user_allowlist()
|
||||
check_old_mrf_config()
|
||||
check_media_proxy_whitelist_config()
|
||||
check_welcome_message_config()
|
||||
with :ok <- check_hellthread_threshold(),
|
||||
:ok <- mrf_user_allowlist(),
|
||||
: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() do
|
||||
:ok
|
||||
else
|
||||
_ ->
|
||||
:error
|
||||
end
|
||||
end
|
||||
|
||||
def check_welcome_message_config do
|
||||
|
|
@ -72,6 +87,10 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
|||
\n* `config :pleroma, :instance, welcome_user_nickname` is now `config :pleroma, :welcome, :direct_message, :sender_nickname`
|
||||
\n* `config :pleroma, :instance, welcome_message` is now `config :pleroma, :welcome, :direct_message, :message`
|
||||
""")
|
||||
|
||||
:error
|
||||
else
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -99,8 +118,11 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
|||
end
|
||||
end)
|
||||
|
||||
if warning != "" do
|
||||
if warning == "" do
|
||||
:ok
|
||||
else
|
||||
Logger.warn(warning_preface <> warning)
|
||||
:error
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -113,6 +135,71 @@ defmodule Pleroma.Config.DeprecationWarnings do
|
|||
!!!DEPRECATION WARNING!!!
|
||||
Your config is using old format (only domain) for MediaProxy whitelist option. Setting should work for now, but you are advised to change format to scheme with port to prevent possible issues later.
|
||||
""")
|
||||
|
||||
:error
|
||||
else
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
def check_gun_pool_options do
|
||||
pool_config = Config.get(:connections_pool)
|
||||
|
||||
if timeout = pool_config[:await_up_timeout] do
|
||||
Logger.warn("""
|
||||
!!!DEPRECATION WARNING!!!
|
||||
Your config is using old setting name `await_up_timeout` instead of `connect_timeout`. Setting should work for now, but you are advised to change format to scheme with port to prevent possible issues later.
|
||||
""")
|
||||
|
||||
Config.put(:connections_pool, Keyword.put_new(pool_config, :connect_timeout, timeout))
|
||||
end
|
||||
|
||||
pools_configs = Config.get(:pools)
|
||||
|
||||
warning_preface = """
|
||||
!!!DEPRECATION WARNING!!!
|
||||
Your config is using old setting name `timeout` instead of `recv_timeout` in pool settings. Setting should work for now, but you are advised to change format to scheme with port to prevent possible issues later.
|
||||
"""
|
||||
|
||||
updated_config =
|
||||
Enum.reduce(pools_configs, [], fn {pool_name, config}, acc ->
|
||||
if timeout = config[:timeout] do
|
||||
Keyword.put(acc, pool_name, Keyword.put_new(config, :recv_timeout, timeout))
|
||||
else
|
||||
acc
|
||||
end
|
||||
end)
|
||||
|
||||
if updated_config != [] do
|
||||
pool_warnings =
|
||||
updated_config
|
||||
|> Keyword.keys()
|
||||
|> Enum.map(fn pool_name ->
|
||||
"\n* `:timeout` options in #{pool_name} pool is now `:recv_timeout`"
|
||||
end)
|
||||
|
||||
Logger.warn(Enum.join([warning_preface | pool_warnings]))
|
||||
|
||||
Config.put(:pools, updated_config)
|
||||
:error
|
||||
else
|
||||
:ok
|
||||
end
|
||||
end
|
||||
|
||||
@spec check_activity_expiration_config() :: :ok | nil
|
||||
def check_activity_expiration_config do
|
||||
warning_preface = """
|
||||
!!!DEPRECATION WARNING!!!
|
||||
Your config is using old namespace for activity expiration configuration. Setting should work for now, but you are advised to change to new namespace to prevent possible issues later:
|
||||
"""
|
||||
|
||||
move_namespace_and_warn(
|
||||
[
|
||||
{Pleroma.ActivityExpiration, Pleroma.Workers.PurgeExpiredActivity,
|
||||
"\n* `config :pleroma, Pleroma.ActivityExpiration` is now `config :pleroma, Pleroma.Workers.PurgeExpiredActivity`"}
|
||||
],
|
||||
warning_preface
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
34
lib/pleroma/config/oban.ex
Normal file
34
lib/pleroma/config/oban.ex
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
defmodule Pleroma.Config.Oban do
|
||||
require Logger
|
||||
|
||||
def warn do
|
||||
oban_config = Pleroma.Config.get(Oban)
|
||||
|
||||
crontab =
|
||||
[
|
||||
Pleroma.Workers.Cron.StatsWorker,
|
||||
Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker,
|
||||
Pleroma.Workers.Cron.ClearOauthTokenWorker
|
||||
]
|
||||
|> Enum.reduce(oban_config[:crontab], fn removed_worker, acc ->
|
||||
with acc when is_list(acc) <- acc,
|
||||
setting when is_tuple(setting) <-
|
||||
Enum.find(acc, fn {_, worker} -> worker == removed_worker end) 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)
|
||||
}
|
||||
"""
|
||||
|> Logger.warn()
|
||||
|
||||
List.delete(acc, setting)
|
||||
else
|
||||
_ -> acc
|
||||
end
|
||||
end)
|
||||
|
||||
Pleroma.Config.put(Oban, Keyword.put(oban_config, :crontab, crontab))
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.EctoType.ActivityPub.ObjectValidators.Emoji do
|
||||
use Ecto.Type
|
||||
|
||||
def type, do: :map
|
||||
|
||||
def cast(data) when is_map(data) do
|
||||
has_invalid_emoji? =
|
||||
Enum.find(data, fn
|
||||
{name, uri} when is_binary(name) and is_binary(uri) ->
|
||||
# based on ObjectValidators.Uri.cast()
|
||||
case URI.parse(uri) do
|
||||
%URI{host: nil} -> true
|
||||
%URI{host: ""} -> true
|
||||
%URI{scheme: scheme} when scheme in ["https", "http"] -> false
|
||||
_ -> true
|
||||
end
|
||||
|
||||
{_name, _uri} ->
|
||||
true
|
||||
end)
|
||||
|
||||
if has_invalid_emoji?, do: :error, else: {:ok, data}
|
||||
end
|
||||
|
||||
def cast(_data), do: :error
|
||||
|
||||
def dump(data), do: {:ok, data}
|
||||
|
||||
def load(data), do: {:ok, data}
|
||||
end
|
||||
|
|
@ -107,6 +107,8 @@ defmodule Pleroma.Emails.UserEmail do
|
|||
|> Enum.filter(&(&1.activity.data["type"] == "Create"))
|
||||
|> Enum.map(fn notification ->
|
||||
object = Pleroma.Object.normalize(notification.activity)
|
||||
|
||||
if not is_nil(object) do
|
||||
object = update_in(object.data["content"], &format_links/1)
|
||||
|
||||
%{
|
||||
|
|
@ -114,18 +116,25 @@ defmodule Pleroma.Emails.UserEmail do
|
|||
object: object,
|
||||
from: User.get_by_ap_id(notification.activity.actor)
|
||||
}
|
||||
end
|
||||
end)
|
||||
|> Enum.filter(& &1)
|
||||
|
||||
followers =
|
||||
notifications
|
||||
|> Enum.filter(&(&1.activity.data["type"] == "Follow"))
|
||||
|> Enum.map(fn notification ->
|
||||
from = User.get_by_ap_id(notification.activity.actor)
|
||||
|
||||
if not is_nil(from) do
|
||||
%{
|
||||
data: notification,
|
||||
object: Pleroma.Object.normalize(notification.activity),
|
||||
from: User.get_by_ap_id(notification.activity.actor)
|
||||
}
|
||||
end
|
||||
end)
|
||||
|> Enum.filter(& &1)
|
||||
|
||||
unless Enum.empty?(mentions) do
|
||||
styling = Config.get([__MODULE__, :styling])
|
||||
|
|
|
|||
|
|
@ -95,7 +95,11 @@ defmodule Pleroma.FollowingRelationship do
|
|||
|> where([r], r.state == ^:follow_accept)
|
||||
end
|
||||
|
||||
def followers_ap_ids(%User{} = user, from_ap_ids \\ nil) do
|
||||
def followers_ap_ids(user, from_ap_ids \\ nil)
|
||||
|
||||
def followers_ap_ids(_, []), do: []
|
||||
|
||||
def followers_ap_ids(%User{} = user, from_ap_ids) do
|
||||
query =
|
||||
user
|
||||
|> followers_query()
|
||||
|
|
@ -260,4 +264,12 @@ defmodule Pleroma.FollowingRelationship do
|
|||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@spec following_ap_ids(User.t()) :: [String.t()]
|
||||
def following_ap_ids(%User{} = user) do
|
||||
user
|
||||
|> following_query()
|
||||
|> select([r, u], u.ap_id)
|
||||
|> Repo.all()
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ defmodule Pleroma.Gun.Conn do
|
|||
opts =
|
||||
opts
|
||||
|> Enum.into(%{})
|
||||
|> Map.put_new(:await_up_timeout, pool_opts[:await_up_timeout] || 5_000)
|
||||
|> Map.put_new(:connect_timeout, pool_opts[:connect_timeout] || 5_000)
|
||||
|> Map.put_new(:supervise, false)
|
||||
|> maybe_add_tls_opts(uri)
|
||||
|
||||
|
|
@ -50,10 +50,10 @@ defmodule Pleroma.Gun.Conn do
|
|||
|
||||
with open_opts <- Map.delete(opts, :tls_opts),
|
||||
{:ok, conn} <- Gun.open(proxy_host, proxy_port, open_opts),
|
||||
{:ok, _} <- Gun.await_up(conn, opts[:await_up_timeout]),
|
||||
{:ok, protocol} <- Gun.await_up(conn, opts[:connect_timeout]),
|
||||
stream <- Gun.connect(conn, connect_opts),
|
||||
{:response, :fin, 200, _} <- Gun.await(conn, stream) do
|
||||
{:ok, conn}
|
||||
{:ok, conn, protocol}
|
||||
else
|
||||
error ->
|
||||
Logger.warn(
|
||||
|
|
@ -88,8 +88,8 @@ defmodule Pleroma.Gun.Conn do
|
|||
|> Map.put(:socks_opts, socks_opts)
|
||||
|
||||
with {:ok, conn} <- Gun.open(proxy_host, proxy_port, opts),
|
||||
{:ok, _} <- Gun.await_up(conn, opts[:await_up_timeout]) do
|
||||
{:ok, conn}
|
||||
{:ok, protocol} <- Gun.await_up(conn, opts[:connect_timeout]) do
|
||||
{:ok, conn, protocol}
|
||||
else
|
||||
error ->
|
||||
Logger.warn(
|
||||
|
|
@ -106,8 +106,8 @@ defmodule Pleroma.Gun.Conn do
|
|||
host = Pleroma.HTTP.AdapterHelper.parse_host(host)
|
||||
|
||||
with {:ok, conn} <- Gun.open(host, port, opts),
|
||||
{:ok, _} <- Gun.await_up(conn, opts[:await_up_timeout]) do
|
||||
{:ok, conn}
|
||||
{:ok, protocol} <- Gun.await_up(conn, opts[:connect_timeout]) do
|
||||
{:ok, conn, protocol}
|
||||
else
|
||||
error ->
|
||||
Logger.warn(
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ defmodule Pleroma.Gun.ConnectionPool do
|
|||
]
|
||||
end
|
||||
|
||||
@spec get_conn(URI.t(), keyword()) :: {:ok, pid()} | {:error, term()}
|
||||
def get_conn(uri, opts) do
|
||||
key = "#{uri.scheme}:#{uri.host}:#{uri.port}"
|
||||
|
||||
|
|
@ -54,12 +55,14 @@ defmodule Pleroma.Gun.ConnectionPool do
|
|||
|
||||
{:DOWN, ^ref, :process, ^worker_pid, reason} ->
|
||||
case reason do
|
||||
{:shutdown, error} -> error
|
||||
{:shutdown, {:error, _} = error} -> error
|
||||
{:shutdown, error} -> {:error, error}
|
||||
_ -> {:error, reason}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@spec release_conn(pid()) :: :ok
|
||||
def release_conn(conn_pid) do
|
||||
# :ets.fun2ms(fn {_, {worker_pid, {gun_pid, _, _, _}}} when gun_pid == conn_pid ->
|
||||
# worker_pid end)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
|
|||
|
||||
@impl true
|
||||
def handle_continue({:connect, [key, uri, opts, client_pid]}, _) do
|
||||
with {:ok, conn_pid} <- Gun.Conn.open(uri, opts),
|
||||
with {:ok, conn_pid, protocol} <- Gun.Conn.open(uri, opts),
|
||||
Process.link(conn_pid) do
|
||||
time = :erlang.monotonic_time(:millisecond)
|
||||
|
||||
|
|
@ -27,8 +27,12 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
|
|||
send(client_pid, {:conn_pid, conn_pid})
|
||||
|
||||
{:noreply,
|
||||
%{key: key, timer: nil, client_monitors: %{client_pid => Process.monitor(client_pid)}},
|
||||
:hibernate}
|
||||
%{
|
||||
key: key,
|
||||
timer: nil,
|
||||
client_monitors: %{client_pid => Process.monitor(client_pid)},
|
||||
protocol: protocol
|
||||
}, :hibernate}
|
||||
else
|
||||
err ->
|
||||
{:stop, {:shutdown, err}, nil}
|
||||
|
|
@ -53,14 +57,20 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
|
|||
end
|
||||
|
||||
@impl true
|
||||
def handle_call(:add_client, {client_pid, _}, %{key: key} = state) do
|
||||
def handle_call(:add_client, {client_pid, _}, %{key: key, protocol: protocol} = state) do
|
||||
time = :erlang.monotonic_time(:millisecond)
|
||||
|
||||
{{conn_pid, _, _, _}, _} =
|
||||
{{conn_pid, used_by, _, _}, _} =
|
||||
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)
|
||||
|
||||
:telemetry.execute(
|
||||
[:pleroma, :connection_pool, :client, :add],
|
||||
%{client_pid: client_pid, clients: used_by},
|
||||
%{key: state.key, protocol: protocol}
|
||||
)
|
||||
|
||||
state =
|
||||
if state.timer != nil do
|
||||
Process.cancel_timer(state[:timer])
|
||||
|
|
@ -83,7 +93,8 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
|
|||
end)
|
||||
|
||||
{ref, state} = pop_in(state.client_monitors[client_pid])
|
||||
Process.demonitor(ref)
|
||||
|
||||
Process.demonitor(ref, [:flush])
|
||||
|
||||
timer =
|
||||
if used_by == [] do
|
||||
|
|
@ -103,22 +114,27 @@ defmodule Pleroma.Gun.ConnectionPool.Worker do
|
|||
{:stop, :normal, state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info({:gun_up, _pid, _protocol}, state) do
|
||||
{:noreply, state, :hibernate}
|
||||
end
|
||||
|
||||
# Gracefully shutdown if the connection got closed without any streams left
|
||||
@impl true
|
||||
def handle_info({:gun_down, _pid, _protocol, _reason, []}, state) do
|
||||
{:stop, :normal, state}
|
||||
end
|
||||
|
||||
# Otherwise, shutdown with an error
|
||||
# Otherwise, wait for retry
|
||||
@impl true
|
||||
def handle_info({:gun_down, _pid, _protocol, _reason, _killed_streams} = down_message, state) do
|
||||
{:stop, {:error, down_message}, state}
|
||||
def handle_info({:gun_down, _pid, _protocol, _reason, _killed_streams}, state) do
|
||||
{:noreply, state, :hibernate}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info({:DOWN, _ref, :process, pid, reason}, state) do
|
||||
:telemetry.execute(
|
||||
[:pleroma, :connection_pool, :client_death],
|
||||
[:pleroma, :connection_pool, :client, :dead],
|
||||
%{client_pid: pid, reason: reason},
|
||||
%{key: state.key}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -100,20 +100,27 @@ defmodule Pleroma.HTML do
|
|||
end)
|
||||
end
|
||||
|
||||
def extract_first_external_url(_, nil), do: {:error, "No content"}
|
||||
|
||||
def extract_first_external_url(object, content) do
|
||||
def extract_first_external_url_from_object(%{data: %{"content" => content}} = object)
|
||||
when is_binary(content) do
|
||||
unless object.data["fake"] do
|
||||
key = "URL|#{object.id}"
|
||||
|
||||
Cachex.fetch!(:scrubber_cache, key, fn _key ->
|
||||
result =
|
||||
{:commit, {:ok, extract_first_external_url(content)}}
|
||||
end)
|
||||
else
|
||||
{:ok, extract_first_external_url(content)}
|
||||
end
|
||||
end
|
||||
|
||||
def extract_first_external_url_from_object(_), do: {:error, :no_content}
|
||||
|
||||
def extract_first_external_url(content) do
|
||||
content
|
||||
|> Floki.parse_fragment!()
|
||||
|> Floki.filter_out("a.mention,a.hashtag,a.attachment,a[rel~=\"tag\"]")
|
||||
|> Floki.attribute("a", "href")
|
||||
|> Floki.find("a:not(.mention,.hashtag,.attachment,[rel~=\"tag\"])")
|
||||
|> Enum.take(1)
|
||||
|> Floki.attribute("href")
|
||||
|> Enum.at(0)
|
||||
|
||||
{:commit, {:ok, result}}
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,12 +6,11 @@ defmodule Pleroma.HTTP.AdapterHelper do
|
|||
@moduledoc """
|
||||
Configure Tesla.Client with default and customized adapter options.
|
||||
"""
|
||||
@defaults [pool: :federation]
|
||||
@defaults [pool: :federation, connect_timeout: 5_000, recv_timeout: 5_000]
|
||||
|
||||
@type proxy_type() :: :socks4 | :socks5
|
||||
@type host() :: charlist() | :inet.ip_address()
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.HTTP.AdapterHelper
|
||||
require Logger
|
||||
|
||||
|
|
@ -20,7 +19,6 @@ defmodule Pleroma.HTTP.AdapterHelper do
|
|||
| {Connection.proxy_type(), Connection.host(), pos_integer()}
|
||||
|
||||
@callback options(keyword(), URI.t()) :: keyword()
|
||||
@callback get_conn(URI.t(), keyword()) :: {:ok, term()} | {:error, term()}
|
||||
|
||||
@spec format_proxy(String.t() | tuple() | nil) :: proxy() | nil
|
||||
def format_proxy(nil), do: nil
|
||||
|
|
@ -44,27 +42,10 @@ defmodule Pleroma.HTTP.AdapterHelper do
|
|||
@spec options(URI.t(), keyword()) :: keyword()
|
||||
def options(%URI{} = uri, opts \\ []) do
|
||||
@defaults
|
||||
|> put_timeout()
|
||||
|> Keyword.merge(opts)
|
||||
|> adapter_helper().options(uri)
|
||||
end
|
||||
|
||||
# For Hackney, this is the time a connection can stay idle in the pool.
|
||||
# For Gun, this is the timeout to receive a message from Gun.
|
||||
defp put_timeout(opts) do
|
||||
{config_key, default} =
|
||||
if adapter() == Tesla.Adapter.Gun do
|
||||
{:pools, Config.get([:pools, :default, :timeout], 5_000)}
|
||||
else
|
||||
{:hackney_pools, 10_000}
|
||||
end
|
||||
|
||||
timeout = Config.get([config_key, opts[:pool], :timeout], default)
|
||||
|
||||
Keyword.merge(opts, timeout: timeout)
|
||||
end
|
||||
|
||||
def get_conn(uri, opts), do: adapter_helper().get_conn(uri, opts)
|
||||
defp adapter, do: Application.get_env(:tesla, :adapter)
|
||||
|
||||
defp adapter_helper do
|
||||
|
|
|
|||
|
|
@ -5,57 +5,62 @@
|
|||
defmodule Pleroma.HTTP.AdapterHelper.Gun do
|
||||
@behaviour Pleroma.HTTP.AdapterHelper
|
||||
|
||||
alias Pleroma.Gun.ConnectionPool
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.HTTP.AdapterHelper
|
||||
|
||||
require Logger
|
||||
|
||||
@defaults [
|
||||
connect_timeout: 5_000,
|
||||
domain_lookup_timeout: 5_000,
|
||||
tls_handshake_timeout: 5_000,
|
||||
retry: 0,
|
||||
retry_timeout: 1000,
|
||||
await_up_timeout: 5_000
|
||||
retry: 1,
|
||||
retry_timeout: 1_000
|
||||
]
|
||||
|
||||
@type pool() :: :federation | :upload | :media | :default
|
||||
|
||||
@spec options(keyword(), URI.t()) :: keyword()
|
||||
def options(incoming_opts \\ [], %URI{} = uri) do
|
||||
proxy =
|
||||
Pleroma.Config.get([:http, :proxy_url])
|
||||
[:http, :proxy_url]
|
||||
|> Config.get()
|
||||
|> AdapterHelper.format_proxy()
|
||||
|
||||
config_opts = Pleroma.Config.get([:http, :adapter], [])
|
||||
config_opts = Config.get([:http, :adapter], [])
|
||||
|
||||
@defaults
|
||||
|> Keyword.merge(config_opts)
|
||||
|> add_scheme_opts(uri)
|
||||
|> AdapterHelper.maybe_add_proxy(proxy)
|
||||
|> Keyword.merge(incoming_opts)
|
||||
|> put_timeout()
|
||||
end
|
||||
|
||||
defp add_scheme_opts(opts, %{scheme: "http"}), do: opts
|
||||
|
||||
defp add_scheme_opts(opts, %{scheme: "https"}) do
|
||||
opts
|
||||
|> Keyword.put(:certificates_verification, true)
|
||||
Keyword.put(opts, :certificates_verification, true)
|
||||
end
|
||||
|
||||
@spec get_conn(URI.t(), keyword()) :: {:ok, keyword()} | {:error, atom()}
|
||||
def get_conn(uri, opts) do
|
||||
case ConnectionPool.get_conn(uri, opts) do
|
||||
{:ok, conn_pid} -> {:ok, Keyword.merge(opts, conn: conn_pid, close_conn: false)}
|
||||
err -> err
|
||||
defp put_timeout(opts) do
|
||||
{recv_timeout, opts} = Keyword.pop(opts, :recv_timeout, pool_timeout(opts[:pool]))
|
||||
# this is the timeout to receive a message from Gun
|
||||
# `:timeout` key is used in Tesla
|
||||
Keyword.put(opts, :timeout, recv_timeout)
|
||||
end
|
||||
|
||||
@spec pool_timeout(pool()) :: non_neg_integer()
|
||||
def pool_timeout(pool) do
|
||||
default = Config.get([:pools, :default, :recv_timeout], 5_000)
|
||||
|
||||
Config.get([:pools, pool, :recv_timeout], default)
|
||||
end
|
||||
|
||||
@prefix Pleroma.Gun.ConnectionPool
|
||||
def limiter_setup do
|
||||
wait = Pleroma.Config.get([:connections_pool, :connection_acquisition_wait])
|
||||
retries = Pleroma.Config.get([:connections_pool, :connection_acquisition_retries])
|
||||
wait = Config.get([:connections_pool, :connection_acquisition_wait])
|
||||
retries = Config.get([:connections_pool, :connection_acquisition_retries])
|
||||
|
||||
:pools
|
||||
|> Pleroma.Config.get([])
|
||||
|> Config.get([])
|
||||
|> Enum.each(fn {name, opts} ->
|
||||
max_running = Keyword.get(opts, :size, 50)
|
||||
max_waiting = Keyword.get(opts, :max_waiting, 10)
|
||||
|
|
@ -69,7 +74,6 @@ defmodule Pleroma.HTTP.AdapterHelper.Gun do
|
|||
case result do
|
||||
:ok -> :ok
|
||||
{:error, :existing} -> :ok
|
||||
e -> raise e
|
||||
end
|
||||
end)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@ defmodule Pleroma.HTTP.AdapterHelper.Hackney do
|
|||
@behaviour Pleroma.HTTP.AdapterHelper
|
||||
|
||||
@defaults [
|
||||
connect_timeout: 10_000,
|
||||
recv_timeout: 20_000,
|
||||
follow_redirect: true,
|
||||
force_redirect: true,
|
||||
pool: :federation
|
||||
force_redirect: true
|
||||
]
|
||||
|
||||
@spec options(keyword(), URI.t()) :: keyword()
|
||||
|
|
@ -19,11 +16,21 @@ defmodule Pleroma.HTTP.AdapterHelper.Hackney do
|
|||
|> Keyword.merge(config_opts)
|
||||
|> Keyword.merge(connection_opts)
|
||||
|> add_scheme_opts(uri)
|
||||
|> maybe_add_with_body()
|
||||
|> Pleroma.HTTP.AdapterHelper.maybe_add_proxy(proxy)
|
||||
end
|
||||
|
||||
defp add_scheme_opts(opts, %URI{scheme: "https"}) do
|
||||
Keyword.put(opts, :ssl_options, versions: [:"tlsv1.2", :"tlsv1.1", :tlsv1])
|
||||
end
|
||||
|
||||
defp add_scheme_opts(opts, _), do: opts
|
||||
|
||||
@spec get_conn(URI.t(), keyword()) :: {:ok, keyword()}
|
||||
def get_conn(_uri, opts), do: {:ok, opts}
|
||||
defp maybe_add_with_body(opts) do
|
||||
if opts[:max_body] do
|
||||
Keyword.put(opts, :with_body, true)
|
||||
else
|
||||
opts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ defmodule Pleroma.HTTP.ExAws do
|
|||
|
||||
@impl true
|
||||
def request(method, url, body \\ "", headers \\ [], http_opts \\ []) do
|
||||
http_opts = Keyword.put_new(http_opts, :pool, :upload)
|
||||
|
||||
case HTTP.request(method, url, body, headers, http_opts) do
|
||||
{:ok, env} ->
|
||||
{:ok, %{status_code: env.status, headers: env.headers, body: env.body}}
|
||||
|
|
|
|||
|
|
@ -60,10 +60,8 @@ defmodule Pleroma.HTTP do
|
|||
{:ok, Env.t()} | {:error, any()}
|
||||
def request(method, url, body, headers, options) when is_binary(url) do
|
||||
uri = URI.parse(url)
|
||||
adapter_opts = AdapterHelper.options(uri, options[:adapter] || [])
|
||||
adapter_opts = AdapterHelper.options(uri, options || [])
|
||||
|
||||
case AdapterHelper.get_conn(uri, adapter_opts) do
|
||||
{:ok, adapter_opts} ->
|
||||
options = put_in(options[:adapter], adapter_opts)
|
||||
params = options[:params] || []
|
||||
request = build_request(method, headers, options, url, body, params)
|
||||
|
|
@ -79,11 +77,6 @@ defmodule Pleroma.HTTP do
|
|||
adapter,
|
||||
adapter_opts
|
||||
)
|
||||
|
||||
# Connection release is handled in a custom FollowRedirects middleware
|
||||
err ->
|
||||
err
|
||||
end
|
||||
end
|
||||
|
||||
@spec request(Client.t(), keyword()) :: {:ok, Env.t()} | {:error, any()}
|
||||
|
|
@ -110,7 +103,7 @@ defmodule Pleroma.HTTP do
|
|||
end
|
||||
|
||||
defp adapter_middlewares(Tesla.Adapter.Gun) do
|
||||
[Pleroma.HTTP.Middleware.FollowRedirects]
|
||||
[Tesla.Middleware.FollowRedirects, Pleroma.Tesla.Middleware.ConnectionPool]
|
||||
end
|
||||
|
||||
defp adapter_middlewares(_), do: []
|
||||
|
|
|
|||
|
|
@ -34,9 +34,11 @@ defmodule Pleroma.HTTP.RequestBuilder do
|
|||
@spec headers(Request.t(), Request.headers()) :: Request.t()
|
||||
def headers(request, headers) do
|
||||
headers_list =
|
||||
if Pleroma.Config.get([:http, :send_user_agent]) do
|
||||
with true <- Pleroma.Config.get([:http, :send_user_agent]),
|
||||
nil <- Enum.find(headers, fn {key, _val} -> String.downcase(key) == "user-agent" end) do
|
||||
[{"user-agent", Pleroma.Application.user_agent()} | headers]
|
||||
else
|
||||
_ ->
|
||||
headers
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ defmodule Pleroma.HTTP.Tzdata do
|
|||
|
||||
@impl true
|
||||
def get(url, headers, options) do
|
||||
options = Keyword.put_new(options, :pool, :default)
|
||||
|
||||
with {:ok, %Tesla.Env{} = env} <- HTTP.get(url, headers, options) do
|
||||
{:ok, {env.status, env.headers, env.body}}
|
||||
end
|
||||
|
|
@ -18,6 +20,8 @@ defmodule Pleroma.HTTP.Tzdata do
|
|||
|
||||
@impl true
|
||||
def head(url, headers, options) do
|
||||
options = Keyword.put_new(options, :pool, :default)
|
||||
|
||||
with {:ok, %Tesla.Env{} = env} <- HTTP.head(url, headers, options) do
|
||||
{:ok, {env.status, env.headers}}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ defmodule Pleroma.Instances.Instance do
|
|||
import Ecto.Query
|
||||
import Ecto.Changeset
|
||||
|
||||
require Logger
|
||||
|
||||
schema "instances" do
|
||||
field(:host, :string)
|
||||
field(:unreachable_since, :naive_datetime_usec)
|
||||
|
|
@ -145,25 +147,34 @@ defmodule Pleroma.Instances.Instance do
|
|||
|
||||
favicon
|
||||
end
|
||||
rescue
|
||||
e ->
|
||||
Logger.warn("Instance.get_or_update_favicon(\"#{host}\") error: #{inspect(e)}")
|
||||
nil
|
||||
end
|
||||
|
||||
defp scrape_favicon(%URI{} = instance_uri) do
|
||||
try do
|
||||
with {:ok, %Tesla.Env{body: html}} <-
|
||||
Pleroma.HTTP.get(to_string(instance_uri), [{:Accept, "text/html"}]),
|
||||
favicon_rel <-
|
||||
html
|
||||
|> Floki.parse_document!()
|
||||
|> Floki.attribute("link[rel=icon]", "href")
|
||||
|> List.first(),
|
||||
favicon <- URI.merge(instance_uri, favicon_rel) |> to_string(),
|
||||
true <- is_binary(favicon) do
|
||||
Pleroma.HTTP.get(to_string(instance_uri), [{"accept", "text/html"}],
|
||||
adapter: [pool: :media]
|
||||
),
|
||||
{_, [favicon_rel | _]} when is_binary(favicon_rel) <-
|
||||
{:parse,
|
||||
html |> Floki.parse_document!() |> Floki.attribute("link[rel=icon]", "href")},
|
||||
{_, favicon} when is_binary(favicon) <-
|
||||
{:merge, URI.merge(instance_uri, favicon_rel) |> to_string()} do
|
||||
favicon
|
||||
else
|
||||
_ -> nil
|
||||
end
|
||||
rescue
|
||||
_ -> nil
|
||||
e ->
|
||||
Logger.warn(
|
||||
"Instance.scrape_favicon(\"#{to_string(instance_uri)}\") error: #{inspect(e)}"
|
||||
)
|
||||
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ defmodule Pleroma.JobQueueMonitor do
|
|||
|
||||
@impl true
|
||||
def init(state) do
|
||||
:telemetry.attach("oban-monitor-failure", [:oban, :failure], &handle_event/4, nil)
|
||||
:telemetry.attach("oban-monitor-success", [:oban, :success], &handle_event/4, nil)
|
||||
:telemetry.attach("oban-monitor-failure", [:oban, :job, :exception], &handle_event/4, nil)
|
||||
:telemetry.attach("oban-monitor-success", [:oban, :job, :stop], &handle_event/4, nil)
|
||||
|
||||
{:ok, state}
|
||||
end
|
||||
|
|
@ -25,8 +25,11 @@ defmodule Pleroma.JobQueueMonitor do
|
|||
GenServer.call(__MODULE__, :stats)
|
||||
end
|
||||
|
||||
def handle_event([:oban, status], %{duration: duration}, meta, _) do
|
||||
GenServer.cast(__MODULE__, {:process_event, status, duration, meta})
|
||||
def handle_event([:oban, :job, event], %{duration: duration}, meta, _) do
|
||||
GenServer.cast(
|
||||
__MODULE__,
|
||||
{:process_event, mapping_status(event), duration, meta}
|
||||
)
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
@ -75,4 +78,7 @@ defmodule Pleroma.JobQueueMonitor do
|
|||
|> Map.update!(:processed_jobs, &(&1 + 1))
|
||||
|> Map.update!(status, &(&1 + 1))
|
||||
end
|
||||
|
||||
defp mapping_status(:stop), do: :success
|
||||
defp mapping_status(:exception), do: :failure
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ defmodule Pleroma.MFA.Token do
|
|||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.OAuth.Authorization
|
||||
alias Pleroma.Web.OAuth.Token, as: OAuthToken
|
||||
|
||||
@expires 300
|
||||
|
||||
@type t() :: %__MODULE__{}
|
||||
|
||||
schema "mfa_tokens" do
|
||||
field(:token, :string)
|
||||
field(:valid_until, :naive_datetime_usec)
|
||||
|
|
@ -24,6 +25,7 @@ defmodule Pleroma.MFA.Token do
|
|||
timestamps()
|
||||
end
|
||||
|
||||
@spec get_by_token(String.t()) :: {:ok, t()} | {:error, :not_found}
|
||||
def get_by_token(token) do
|
||||
from(
|
||||
t in __MODULE__,
|
||||
|
|
@ -33,33 +35,40 @@ defmodule Pleroma.MFA.Token do
|
|||
|> Repo.find_resource()
|
||||
end
|
||||
|
||||
def validate(token) do
|
||||
with {:fetch_token, {:ok, token}} <- {:fetch_token, get_by_token(token)},
|
||||
{:expired, false} <- {:expired, is_expired?(token)} do
|
||||
@spec validate(String.t()) :: {:ok, t()} | {:error, :not_found} | {:error, :expired_token}
|
||||
def validate(token_str) do
|
||||
with {:ok, token} <- get_by_token(token_str),
|
||||
false <- expired?(token) do
|
||||
{:ok, token}
|
||||
else
|
||||
{:expired, _} -> {:error, :expired_token}
|
||||
{:fetch_token, _} -> {:error, :not_found}
|
||||
error -> {:error, error}
|
||||
end
|
||||
end
|
||||
|
||||
def create_token(%User{} = user) do
|
||||
%__MODULE__{}
|
||||
|> change
|
||||
|> assign_user(user)
|
||||
|> put_token
|
||||
|> put_valid_until
|
||||
|> Repo.insert()
|
||||
defp expired?(%__MODULE__{valid_until: valid_until}) do
|
||||
with true <- NaiveDateTime.diff(NaiveDateTime.utc_now(), valid_until) > 0 do
|
||||
{:error, :expired_token}
|
||||
end
|
||||
end
|
||||
|
||||
def create_token(user, authorization) do
|
||||
@spec create(User.t(), Authorization.t() | nil) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
|
||||
def create(user, authorization \\ nil) do
|
||||
with {:ok, token} <- do_create(user, authorization) do
|
||||
Pleroma.Workers.PurgeExpiredToken.enqueue(%{
|
||||
token_id: token.id,
|
||||
valid_until: DateTime.from_naive!(token.valid_until, "Etc/UTC"),
|
||||
mod: __MODULE__
|
||||
})
|
||||
|
||||
{:ok, token}
|
||||
end
|
||||
end
|
||||
|
||||
defp do_create(user, authorization) do
|
||||
%__MODULE__{}
|
||||
|> change
|
||||
|> change()
|
||||
|> assign_user(user)
|
||||
|> assign_authorization(authorization)
|
||||
|> put_token
|
||||
|> put_valid_until
|
||||
|> maybe_assign_authorization(authorization)
|
||||
|> put_token()
|
||||
|> put_valid_until()
|
||||
|> Repo.insert()
|
||||
end
|
||||
|
||||
|
|
@ -69,15 +78,19 @@ defmodule Pleroma.MFA.Token do
|
|||
|> validate_required([:user])
|
||||
end
|
||||
|
||||
defp assign_authorization(changeset, authorization) do
|
||||
defp maybe_assign_authorization(changeset, %Authorization{} = authorization) do
|
||||
changeset
|
||||
|> put_assoc(:authorization, authorization)
|
||||
|> validate_required([:authorization])
|
||||
end
|
||||
|
||||
defp maybe_assign_authorization(changeset, _), do: changeset
|
||||
|
||||
defp put_token(changeset) do
|
||||
token = Pleroma.Web.OAuth.Token.Utils.generate_token()
|
||||
|
||||
changeset
|
||||
|> change(%{token: OAuthToken.Utils.generate_token()})
|
||||
|> change(%{token: token})
|
||||
|> validate_required([:token])
|
||||
|> unique_constraint(:token)
|
||||
end
|
||||
|
|
@ -89,18 +102,4 @@ defmodule Pleroma.MFA.Token do
|
|||
|> change(%{valid_until: expires_in})
|
||||
|> validate_required([:valid_until])
|
||||
end
|
||||
|
||||
def is_expired?(%__MODULE__{valid_until: valid_until}) do
|
||||
NaiveDateTime.diff(NaiveDateTime.utc_now(), valid_until) > 0
|
||||
end
|
||||
|
||||
def is_expired?(_), do: false
|
||||
|
||||
def delete_expired_tokens do
|
||||
from(
|
||||
q in __MODULE__,
|
||||
where: fragment("?", q.valid_until) < ^Timex.now()
|
||||
)
|
||||
|> Repo.delete_all()
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ defmodule Pleroma.MigrationHelper.NotificationBackfill do
|
|||
query
|
||||
|> Repo.chunk_stream(100)
|
||||
|> Enum.each(fn notification ->
|
||||
type =
|
||||
notification.activity
|
||||
|> type_from_activity()
|
||||
if notification.activity do
|
||||
type = type_from_activity(notification.activity)
|
||||
|
||||
notification
|
||||
|> Ecto.Changeset.change(%{type: type})
|
||||
|> Repo.update()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
@ -72,8 +72,7 @@ defmodule Pleroma.MigrationHelper.NotificationBackfill do
|
|||
"pleroma:emoji_reaction"
|
||||
|
||||
"Create" ->
|
||||
activity
|
||||
|> type_from_activity_object()
|
||||
type_from_activity_object(activity)
|
||||
|
||||
t ->
|
||||
raise "No notification type for activity type #{t}"
|
||||
|
|
|
|||
|
|
@ -320,6 +320,19 @@ defmodule Pleroma.ModerationLog do
|
|||
|> insert_log_entry_with_message()
|
||||
end
|
||||
|
||||
@spec insert_log(%{actor: User, action: String.t(), subject_id: String.t()}) ::
|
||||
{:ok, ModerationLog} | {:error, any}
|
||||
def insert_log(%{actor: %User{} = actor, action: "chat_message_delete", subject_id: subject_id}) do
|
||||
%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor.nickname},
|
||||
"action" => "chat_message_delete",
|
||||
"subject_id" => subject_id
|
||||
}
|
||||
}
|
||||
|> insert_log_entry_with_message()
|
||||
end
|
||||
|
||||
@spec insert_log_entry_with_message(ModerationLog) :: {:ok, ModerationLog} | {:error, any}
|
||||
defp insert_log_entry_with_message(entry) do
|
||||
entry.data["message"]
|
||||
|
|
@ -627,6 +640,17 @@ defmodule Pleroma.ModerationLog do
|
|||
"@#{actor_nickname} updated users: #{users_to_nicknames_string(subjects)}"
|
||||
end
|
||||
|
||||
@spec get_log_entry_message(ModerationLog) :: String.t()
|
||||
def get_log_entry_message(%ModerationLog{
|
||||
data: %{
|
||||
"actor" => %{"nickname" => actor_nickname},
|
||||
"action" => "chat_message_delete",
|
||||
"subject_id" => subject_id
|
||||
}
|
||||
}) do
|
||||
"@#{actor_nickname} deleted chat message ##{subject_id}"
|
||||
end
|
||||
|
||||
defp nicknames_to_string(nicknames) do
|
||||
nicknames
|
||||
|> Enum.map(&"@#{&1}")
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ defmodule Pleroma.Notification do
|
|||
alias Pleroma.Repo
|
||||
alias Pleroma.ThreadMute
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.CommonAPI.Utils
|
||||
alias Pleroma.Web.Push
|
||||
alias Pleroma.Web.Streamer
|
||||
|
|
@ -441,6 +442,7 @@ defmodule Pleroma.Notification do
|
|||
|> Multi.insert(:notification, %Notification{
|
||||
user_id: user.id,
|
||||
activity: activity,
|
||||
seen: mark_as_read?(activity, user),
|
||||
type: type_from_activity(activity)
|
||||
})
|
||||
|> Marker.multi_set_last_read_id(user, "notifications")
|
||||
|
|
@ -634,6 +636,11 @@ defmodule Pleroma.Notification do
|
|||
|
||||
def skip?(_, _, _), do: false
|
||||
|
||||
def mark_as_read?(activity, target_user) do
|
||||
user = Activity.user_actor(activity)
|
||||
User.mutes_user?(target_user, user) || CommonAPI.thread_muted?(target_user, activity)
|
||||
end
|
||||
|
||||
def for_user_and_activity(user, activity) do
|
||||
from(n in __MODULE__,
|
||||
where: n.user_id == ^user.id,
|
||||
|
|
@ -641,4 +648,16 @@ defmodule Pleroma.Notification do
|
|||
)
|
||||
|> Repo.one()
|
||||
end
|
||||
|
||||
@spec mark_context_as_read(User.t(), String.t()) :: {integer(), nil | [term()]}
|
||||
def mark_context_as_read(%User{id: id}, context) do
|
||||
from(
|
||||
n in Notification,
|
||||
join: a in assoc(n, :activity),
|
||||
where: n.user_id == ^id,
|
||||
where: n.seen == false,
|
||||
where: fragment("?->>'context'", a.data) == ^context
|
||||
)
|
||||
|> Repo.update_all(set: [seen: true])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -255,6 +255,10 @@ defmodule Pleroma.Object do
|
|||
end
|
||||
end
|
||||
|
||||
defp poll_is_multiple?(%Object{data: %{"anyOf" => [_ | _]}}), do: true
|
||||
|
||||
defp poll_is_multiple?(_), do: false
|
||||
|
||||
def decrease_replies_count(ap_id) do
|
||||
Object
|
||||
|> where([o], fragment("?->>'id' = ?::text", o.data, ^to_string(ap_id)))
|
||||
|
|
@ -281,10 +285,10 @@ defmodule Pleroma.Object do
|
|||
def increase_vote_count(ap_id, name, actor) do
|
||||
with %Object{} = object <- Object.normalize(ap_id),
|
||||
"Question" <- object.data["type"] do
|
||||
multiple = Map.has_key?(object.data, "anyOf")
|
||||
key = if poll_is_multiple?(object), do: "anyOf", else: "oneOf"
|
||||
|
||||
options =
|
||||
(object.data["anyOf"] || object.data["oneOf"] || [])
|
||||
object.data[key]
|
||||
|> Enum.map(fn
|
||||
%{"name" => ^name} = option ->
|
||||
Kernel.update_in(option["replies"]["totalItems"], &(&1 + 1))
|
||||
|
|
@ -296,11 +300,8 @@ defmodule Pleroma.Object do
|
|||
voters = [actor | object.data["voters"] || []] |> Enum.uniq()
|
||||
|
||||
data =
|
||||
if multiple do
|
||||
Map.put(object.data, "anyOf", options)
|
||||
else
|
||||
Map.put(object.data, "oneOf", options)
|
||||
end
|
||||
object.data
|
||||
|> Map.put(key, options)
|
||||
|> Map.put("voters", voters)
|
||||
|
||||
object
|
||||
|
|
|
|||
|
|
@ -44,18 +44,11 @@ defmodule Pleroma.Object.Containment do
|
|||
nil
|
||||
end
|
||||
|
||||
# TODO: We explicitly allow 'tag' URIs through, due to references to legacy OStatus
|
||||
# objects being present in the test suite environment. Once these objects are
|
||||
# removed, please also remove this.
|
||||
if Mix.env() == :test do
|
||||
defp compare_uris(_, %URI{scheme: "tag"}), do: :ok
|
||||
end
|
||||
|
||||
defp compare_uris(%URI{host: host} = _id_uri, %URI{host: host} = _other_uri), do: :ok
|
||||
defp compare_uris(_id_uri, _other_uri), do: :error
|
||||
|
||||
@doc """
|
||||
Checks that an imported AP object's actor matches the domain it came from.
|
||||
Checks that an imported AP object's actor matches the host it came from.
|
||||
"""
|
||||
def contain_origin(_id, %{"actor" => nil}), do: :error
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.Object.Fetcher do
|
|||
alias Pleroma.Repo
|
||||
alias Pleroma.Signature
|
||||
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
||||
alias Pleroma.Web.ActivityPub.ObjectValidator
|
||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||
alias Pleroma.Web.Federator
|
||||
|
||||
|
|
@ -23,21 +24,38 @@ defmodule Pleroma.Object.Fetcher do
|
|||
Ecto.Changeset.put_change(changeset, :updated_at, updated_at)
|
||||
end
|
||||
|
||||
defp maybe_reinject_internal_fields(data, %{data: %{} = old_data}) do
|
||||
defp maybe_reinject_internal_fields(%{data: %{} = old_data}, new_data) do
|
||||
internal_fields = Map.take(old_data, Pleroma.Constants.object_internal_fields())
|
||||
|
||||
Map.merge(data, internal_fields)
|
||||
Map.merge(new_data, internal_fields)
|
||||
end
|
||||
|
||||
defp maybe_reinject_internal_fields(data, _), do: data
|
||||
defp maybe_reinject_internal_fields(_, new_data), do: new_data
|
||||
|
||||
@spec reinject_object(struct(), map()) :: {:ok, Object.t()} | {:error, any()}
|
||||
defp reinject_object(struct, data) do
|
||||
Logger.debug("Reinjecting object #{data["id"]}")
|
||||
defp reinject_object(%Object{data: %{"type" => "Question"}} = object, new_data) do
|
||||
Logger.debug("Reinjecting object #{new_data["id"]}")
|
||||
|
||||
with data <- Transmogrifier.fix_object(data),
|
||||
data <- maybe_reinject_internal_fields(data, struct),
|
||||
changeset <- Object.change(struct, %{data: data}),
|
||||
with data <- maybe_reinject_internal_fields(object, new_data),
|
||||
{:ok, data, _} <- ObjectValidator.validate(data, %{}),
|
||||
changeset <- Object.change(object, %{data: data}),
|
||||
changeset <- touch_changeset(changeset),
|
||||
{:ok, object} <- Repo.insert_or_update(changeset),
|
||||
{:ok, object} <- Object.set_cache(object) do
|
||||
{:ok, object}
|
||||
else
|
||||
e ->
|
||||
Logger.error("Error while processing object: #{inspect(e)}")
|
||||
{:error, e}
|
||||
end
|
||||
end
|
||||
|
||||
defp reinject_object(%Object{} = object, new_data) do
|
||||
Logger.debug("Reinjecting object #{new_data["id"]}")
|
||||
|
||||
with new_data <- Transmogrifier.fix_object(new_data),
|
||||
data <- maybe_reinject_internal_fields(object, new_data),
|
||||
changeset <- Object.change(object, %{data: data}),
|
||||
changeset <- touch_changeset(changeset),
|
||||
{:ok, object} <- Repo.insert_or_update(changeset),
|
||||
{:ok, object} <- Object.set_cache(object) do
|
||||
|
|
@ -51,8 +69,8 @@ defmodule Pleroma.Object.Fetcher do
|
|||
|
||||
def refetch_object(%Object{data: %{"id" => id}} = object) do
|
||||
with {:local, false} <- {:local, Object.local?(object)},
|
||||
{:ok, data} <- fetch_and_contain_remote_object_from_id(id),
|
||||
{:ok, object} <- reinject_object(object, data) do
|
||||
{:ok, new_data} <- fetch_and_contain_remote_object_from_id(id),
|
||||
{:ok, object} <- reinject_object(object, new_data) do
|
||||
{:ok, object}
|
||||
else
|
||||
{:local, true} -> {:ok, object}
|
||||
|
|
@ -80,8 +98,8 @@ defmodule Pleroma.Object.Fetcher do
|
|||
{:containment, _} ->
|
||||
{:error, "Object containment failed."}
|
||||
|
||||
{:transmogrifier, {:error, {:reject, nil}}} ->
|
||||
{:reject, nil}
|
||||
{:transmogrifier, {:error, {:reject, e}}} ->
|
||||
{:reject, e}
|
||||
|
||||
{:transmogrifier, _} = e ->
|
||||
{:error, e}
|
||||
|
|
@ -106,8 +124,8 @@ defmodule Pleroma.Object.Fetcher do
|
|||
defp prepare_activity_params(data) do
|
||||
%{
|
||||
"type" => "Create",
|
||||
"to" => data["to"],
|
||||
"cc" => data["cc"],
|
||||
"to" => data["to"] || [],
|
||||
"cc" => data["cc"] || [],
|
||||
# Should we seriously keep this attributedTo thing?
|
||||
"actor" => data["actor"] || data["attributedTo"],
|
||||
"object" => data
|
||||
|
|
@ -145,12 +163,12 @@ defmodule Pleroma.Object.Fetcher do
|
|||
date: date
|
||||
})
|
||||
|
||||
[{"signature", signature}]
|
||||
{"signature", signature}
|
||||
end
|
||||
|
||||
defp sign_fetch(headers, id, date) do
|
||||
if Pleroma.Config.get([:activitypub, :sign_object_fetches]) do
|
||||
headers ++ make_signature(id, date)
|
||||
[make_signature(id, date) | headers]
|
||||
else
|
||||
headers
|
||||
end
|
||||
|
|
@ -158,7 +176,7 @@ defmodule Pleroma.Object.Fetcher do
|
|||
|
||||
defp maybe_date_fetch(headers, date) do
|
||||
if Pleroma.Config.get([:activitypub, :sign_object_fetches]) do
|
||||
headers ++ [{"date", date}]
|
||||
[{"date", date} | headers]
|
||||
else
|
||||
headers
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ defmodule Pleroma.Plugs.FrontendStatic do
|
|||
opts
|
||||
|> Keyword.put(:from, "__unconfigured_frontend_static_plug")
|
||||
|> Plug.Static.init()
|
||||
|> Map.put(:frontend_type, opts[:frontend_type])
|
||||
end
|
||||
|
||||
def call(conn, opts) do
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ defmodule Pleroma.Plugs.RemoteIp do
|
|||
This is a shim to call [`RemoteIp`](https://git.pleroma.social/pleroma/remote_ip) but with runtime configuration.
|
||||
"""
|
||||
|
||||
import Plug.Conn
|
||||
|
||||
@behaviour Plug
|
||||
|
||||
@headers ~w[
|
||||
|
|
@ -26,11 +28,12 @@ defmodule Pleroma.Plugs.RemoteIp do
|
|||
|
||||
def init(_), do: nil
|
||||
|
||||
def call(conn, _) do
|
||||
def call(%{remote_ip: original_remote_ip} = conn, _) do
|
||||
config = Pleroma.Config.get(__MODULE__, [])
|
||||
|
||||
if Keyword.get(config, :enabled, false) do
|
||||
RemoteIp.call(conn, remote_ip_opts(config))
|
||||
%{remote_ip: new_remote_ip} = conn = RemoteIp.call(conn, remote_ip_opts(config))
|
||||
assign(conn, :remote_ip_found, original_remote_ip != new_remote_ip)
|
||||
else
|
||||
conn
|
||||
end
|
||||
|
|
|
|||
|
|
@ -49,7 +49,21 @@ defmodule Pleroma.Repo do
|
|||
end
|
||||
end
|
||||
|
||||
def chunk_stream(query, chunk_size) do
|
||||
@doc """
|
||||
Returns a lazy enumerable that emits all entries from the data store matching the given query.
|
||||
|
||||
`returns_as` use to group records. use the `batches` option to fetch records in bulk.
|
||||
|
||||
## Examples
|
||||
|
||||
# fetch records one-by-one
|
||||
iex> Pleroma.Repo.chunk_stream(Pleroma.Activity.Queries.by_actor(ap_id), 500)
|
||||
|
||||
# fetch records in bulk
|
||||
iex> Pleroma.Repo.chunk_stream(Pleroma.Activity.Queries.by_actor(ap_id), 500, :batches)
|
||||
"""
|
||||
@spec chunk_stream(Ecto.Query.t(), integer(), atom()) :: Enumerable.t()
|
||||
def chunk_stream(query, chunk_size, returns_as \\ :one) do
|
||||
# We don't actually need start and end funcitons of resource streaming,
|
||||
# but it seems to be the only way to not fetch records one-by-one and
|
||||
# have individual records be the elements of the stream, instead of
|
||||
|
|
@ -69,7 +83,12 @@ defmodule Pleroma.Repo do
|
|||
|
||||
records ->
|
||||
last_id = List.last(records).id
|
||||
|
||||
if returns_as == :one do
|
||||
{records, last_id}
|
||||
else
|
||||
{[records], last_id}
|
||||
end
|
||||
end
|
||||
end,
|
||||
fn _ -> :ok end
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.RepoStreamer do
|
||||
alias Pleroma.Repo
|
||||
import Ecto.Query
|
||||
|
||||
def chunk_stream(query, chunk_size) do
|
||||
Stream.unfold(0, fn
|
||||
:halt ->
|
||||
{[], :halt}
|
||||
|
||||
last_id ->
|
||||
query
|
||||
|> order_by(asc: :id)
|
||||
|> where([r], r.id > ^last_id)
|
||||
|> limit(^chunk_size)
|
||||
|> Repo.all()
|
||||
|> case do
|
||||
[] ->
|
||||
{[], :halt}
|
||||
|
||||
records ->
|
||||
last_id = List.last(records).id
|
||||
{records, last_id}
|
||||
end
|
||||
end)
|
||||
|> Stream.take_while(fn
|
||||
[] -> false
|
||||
_ -> true
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
|
@ -7,6 +7,7 @@ defmodule Pleroma.ReverseProxy.Client.Hackney do
|
|||
|
||||
@impl true
|
||||
def request(method, url, headers, body, opts \\ []) do
|
||||
opts = Keyword.put(opts, :ssl_options, versions: [:"tlsv1.2", :"tlsv1.1", :tlsv1])
|
||||
:hackney.request(method, url, headers, body, opts)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ defmodule Pleroma.ReverseProxy.Client.Tesla do
|
|||
url,
|
||||
body,
|
||||
headers,
|
||||
Keyword.put(opts, :adapter, opts)
|
||||
opts
|
||||
) do
|
||||
if is_map(response.body) and method != :head do
|
||||
{:ok, response.status, response.headers, response.body}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,15 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Stats do
|
||||
use GenServer
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
alias Pleroma.CounterCache
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
|
||||
use GenServer
|
||||
@interval :timer.seconds(60)
|
||||
|
||||
def start_link(_) do
|
||||
GenServer.start_link(
|
||||
|
|
@ -18,6 +21,12 @@ defmodule Pleroma.Stats do
|
|||
)
|
||||
end
|
||||
|
||||
@impl true
|
||||
def init(_args) do
|
||||
if Pleroma.Config.get(:env) == :test, do: :ok = Ecto.Adapters.SQL.Sandbox.checkout(Repo)
|
||||
{:ok, nil, {:continue, :calculate_stats}}
|
||||
end
|
||||
|
||||
@doc "Performs update stats"
|
||||
def force_update do
|
||||
GenServer.call(__MODULE__, :force_update)
|
||||
|
|
@ -29,7 +38,11 @@ defmodule Pleroma.Stats do
|
|||
end
|
||||
|
||||
@doc "Returns stats data"
|
||||
@spec get_stats() :: %{domain_count: integer(), status_count: integer(), user_count: integer()}
|
||||
@spec get_stats() :: %{
|
||||
domain_count: non_neg_integer(),
|
||||
status_count: non_neg_integer(),
|
||||
user_count: non_neg_integer()
|
||||
}
|
||||
def get_stats do
|
||||
%{stats: stats} = GenServer.call(__MODULE__, :get_state)
|
||||
|
||||
|
|
@ -44,25 +57,14 @@ defmodule Pleroma.Stats do
|
|||
peers
|
||||
end
|
||||
|
||||
def init(_args) do
|
||||
{:ok, calculate_stat_data()}
|
||||
end
|
||||
|
||||
def handle_call(:force_update, _from, _state) do
|
||||
new_stats = calculate_stat_data()
|
||||
{:reply, new_stats, new_stats}
|
||||
end
|
||||
|
||||
def handle_call(:get_state, _from, state) do
|
||||
{:reply, state, state}
|
||||
end
|
||||
|
||||
def handle_cast(:run_update, _state) do
|
||||
new_stats = calculate_stat_data()
|
||||
|
||||
{:noreply, new_stats}
|
||||
end
|
||||
|
||||
@spec calculate_stat_data() :: %{
|
||||
peers: list(),
|
||||
stats: %{
|
||||
domain_count: non_neg_integer(),
|
||||
status_count: non_neg_integer(),
|
||||
user_count: non_neg_integer()
|
||||
}
|
||||
}
|
||||
def calculate_stat_data do
|
||||
peers =
|
||||
from(
|
||||
|
|
@ -97,6 +99,7 @@ defmodule Pleroma.Stats do
|
|||
}
|
||||
end
|
||||
|
||||
@spec get_status_visibility_count(String.t() | nil) :: map()
|
||||
def get_status_visibility_count(instance \\ nil) do
|
||||
if is_nil(instance) do
|
||||
CounterCache.get_sum()
|
||||
|
|
@ -104,4 +107,36 @@ defmodule Pleroma.Stats do
|
|||
CounterCache.get_by_instance(instance)
|
||||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_continue(:calculate_stats, _) do
|
||||
stats = calculate_stat_data()
|
||||
Process.send_after(self(), :run_update, @interval)
|
||||
{:noreply, stats}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_call(:force_update, _from, _state) do
|
||||
new_stats = calculate_stat_data()
|
||||
{:reply, new_stats, new_stats}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_call(:get_state, _from, state) do
|
||||
{:reply, state, state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_cast(:run_update, _state) do
|
||||
new_stats = calculate_stat_data()
|
||||
|
||||
{:noreply, new_stats}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info(:run_update, _) do
|
||||
new_stats = calculate_stat_data()
|
||||
Process.send_after(self(), :run_update, @interval)
|
||||
{:noreply, new_stats}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ defmodule Pleroma.Telemetry.Logger do
|
|||
[:pleroma, :connection_pool, :reclaim, :start],
|
||||
[:pleroma, :connection_pool, :reclaim, :stop],
|
||||
[:pleroma, :connection_pool, :provision_failure],
|
||||
[:pleroma, :connection_pool, :client_death]
|
||||
[:pleroma, :connection_pool, :client, :dead],
|
||||
[:pleroma, :connection_pool, :client, :add]
|
||||
]
|
||||
def attach do
|
||||
:telemetry.attach_many("pleroma-logger", @events, &handle_event/4, [])
|
||||
|
|
@ -62,7 +63,7 @@ defmodule Pleroma.Telemetry.Logger do
|
|||
end
|
||||
|
||||
def handle_event(
|
||||
[:pleroma, :connection_pool, :client_death],
|
||||
[:pleroma, :connection_pool, :client, :dead],
|
||||
%{client_pid: client_pid, reason: reason},
|
||||
%{key: key},
|
||||
_
|
||||
|
|
@ -73,4 +74,17 @@ defmodule Pleroma.Telemetry.Logger do
|
|||
}"
|
||||
end)
|
||||
end
|
||||
|
||||
def handle_event(
|
||||
[:pleroma, :connection_pool, :client, :add],
|
||||
%{clients: [_, _ | _] = clients},
|
||||
%{key: key, protocol: :http},
|
||||
_
|
||||
) do
|
||||
Logger.info(fn ->
|
||||
"Pool worker for #{key}: #{length(clients)} clients are using an HTTP1 connection at the same time, head-of-line blocking might occur."
|
||||
end)
|
||||
end
|
||||
|
||||
def handle_event([:pleroma, :connection_pool, :client, :add], _, _, _), do: :ok
|
||||
end
|
||||
|
|
|
|||
50
lib/pleroma/tesla/middleware/connection_pool.ex
Normal file
50
lib/pleroma/tesla/middleware/connection_pool.ex
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Tesla.Middleware.ConnectionPool do
|
||||
@moduledoc """
|
||||
Middleware to get/release connections from `Pleroma.Gun.ConnectionPool`
|
||||
"""
|
||||
|
||||
@behaviour Tesla.Middleware
|
||||
|
||||
alias Pleroma.Gun.ConnectionPool
|
||||
|
||||
@impl Tesla.Middleware
|
||||
def call(%Tesla.Env{url: url, opts: opts} = env, next, _) do
|
||||
uri = URI.parse(url)
|
||||
|
||||
# Avoid leaking connections when the middleware is called twice
|
||||
# with body_as: :chunks. We assume only the middleware can set
|
||||
# opts[:adapter][:conn]
|
||||
if opts[:adapter][:conn] do
|
||||
ConnectionPool.release_conn(opts[:adapter][:conn])
|
||||
end
|
||||
|
||||
case ConnectionPool.get_conn(uri, opts[:adapter]) do
|
||||
{:ok, conn_pid} ->
|
||||
adapter_opts = Keyword.merge(opts[:adapter], conn: conn_pid, close_conn: false)
|
||||
opts = Keyword.put(opts, :adapter, adapter_opts)
|
||||
env = %{env | opts: opts}
|
||||
|
||||
case Tesla.run(env, next) do
|
||||
{:ok, env} ->
|
||||
unless opts[:adapter][:body_as] == :chunks do
|
||||
ConnectionPool.release_conn(conn_pid)
|
||||
{_, res} = pop_in(env.opts[:adapter][:conn])
|
||||
{:ok, res}
|
||||
else
|
||||
{:ok, env}
|
||||
end
|
||||
|
||||
err ->
|
||||
ConnectionPool.release_conn(conn_pid)
|
||||
err
|
||||
end
|
||||
|
||||
err ->
|
||||
err
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2015-2020 Tymon Tobolski <https://github.com/teamon/tesla/blob/master/lib/tesla/middleware/follow_redirects.ex>
|
||||
# Copyright © 2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.HTTP.Middleware.FollowRedirects do
|
||||
@moduledoc """
|
||||
Pool-aware version of https://github.com/teamon/tesla/blob/master/lib/tesla/middleware/follow_redirects.ex
|
||||
|
||||
Follow 3xx redirects
|
||||
## Options
|
||||
- `:max_redirects` - limit number of redirects (default: `5`)
|
||||
"""
|
||||
|
||||
alias Pleroma.Gun.ConnectionPool
|
||||
|
||||
@behaviour Tesla.Middleware
|
||||
|
||||
@max_redirects 5
|
||||
@redirect_statuses [301, 302, 303, 307, 308]
|
||||
|
||||
@impl Tesla.Middleware
|
||||
def call(env, next, opts \\ []) do
|
||||
max = Keyword.get(opts, :max_redirects, @max_redirects)
|
||||
|
||||
redirect(env, next, max)
|
||||
end
|
||||
|
||||
defp redirect(env, next, left) do
|
||||
opts = env.opts[:adapter]
|
||||
|
||||
case Tesla.run(env, next) do
|
||||
{:ok, %{status: status} = res} when status in @redirect_statuses and left > 0 ->
|
||||
release_conn(opts)
|
||||
|
||||
case Tesla.get_header(res, "location") do
|
||||
nil ->
|
||||
{:ok, res}
|
||||
|
||||
location ->
|
||||
location = parse_location(location, res)
|
||||
|
||||
case get_conn(location, opts) do
|
||||
{:ok, opts} ->
|
||||
%{env | opts: Keyword.put(env.opts, :adapter, opts)}
|
||||
|> new_request(res.status, location)
|
||||
|> redirect(next, left - 1)
|
||||
|
||||
e ->
|
||||
e
|
||||
end
|
||||
end
|
||||
|
||||
{:ok, %{status: status}} when status in @redirect_statuses ->
|
||||
release_conn(opts)
|
||||
{:error, {__MODULE__, :too_many_redirects}}
|
||||
|
||||
{:error, _} = e ->
|
||||
release_conn(opts)
|
||||
e
|
||||
|
||||
other ->
|
||||
unless opts[:body_as] == :chunks do
|
||||
release_conn(opts)
|
||||
end
|
||||
|
||||
other
|
||||
end
|
||||
end
|
||||
|
||||
defp get_conn(location, opts) do
|
||||
uri = URI.parse(location)
|
||||
|
||||
case ConnectionPool.get_conn(uri, opts) do
|
||||
{:ok, conn} ->
|
||||
{:ok, Keyword.merge(opts, conn: conn)}
|
||||
|
||||
e ->
|
||||
e
|
||||
end
|
||||
end
|
||||
|
||||
defp release_conn(opts) do
|
||||
ConnectionPool.release_conn(opts[:conn])
|
||||
end
|
||||
|
||||
# The 303 (See Other) redirect was added in HTTP/1.1 to indicate that the originally
|
||||
# requested resource is not available, however a related resource (or another redirect)
|
||||
# available via GET is available at the specified location.
|
||||
# https://tools.ietf.org/html/rfc7231#section-6.4.4
|
||||
defp new_request(env, 303, location), do: %{env | url: location, method: :get, query: []}
|
||||
|
||||
# The 307 (Temporary Redirect) status code indicates that the target
|
||||
# resource resides temporarily under a different URI and the user agent
|
||||
# MUST NOT change the request method (...)
|
||||
# https://tools.ietf.org/html/rfc7231#section-6.4.7
|
||||
defp new_request(env, 307, location), do: %{env | url: location}
|
||||
|
||||
defp new_request(env, _, location), do: %{env | url: location, query: []}
|
||||
|
||||
defp parse_location("https://" <> _rest = location, _env), do: location
|
||||
defp parse_location("http://" <> _rest = location, _env), do: location
|
||||
|
||||
defp parse_location(location, env) do
|
||||
env.url
|
||||
|> URI.parse()
|
||||
|> URI.merge(location)
|
||||
|> URI.to_string()
|
||||
end
|
||||
end
|
||||
|
|
@ -56,6 +56,15 @@ defmodule Pleroma.Upload do
|
|||
}
|
||||
defstruct [:id, :name, :tempfile, :content_type, :path]
|
||||
|
||||
defp get_description(opts, upload) do
|
||||
case {opts[:description], Pleroma.Config.get([Pleroma.Upload, :default_description])} do
|
||||
{description, _} when is_binary(description) -> description
|
||||
{_, :filename} -> upload.name
|
||||
{_, str} when is_binary(str) -> str
|
||||
_ -> ""
|
||||
end
|
||||
end
|
||||
|
||||
@spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()}
|
||||
def store(upload, opts \\ []) do
|
||||
opts = get_opts(opts)
|
||||
|
|
@ -63,7 +72,7 @@ defmodule Pleroma.Upload do
|
|||
with {:ok, upload} <- prepare_upload(upload, opts),
|
||||
upload = %__MODULE__{upload | path: upload.path || "#{upload.id}/#{upload.name}"},
|
||||
{:ok, upload} <- Pleroma.Upload.Filter.filter(opts.filters, upload),
|
||||
description = Map.get(opts, :description) || upload.name,
|
||||
description = get_description(opts, upload),
|
||||
{_, true} <-
|
||||
{:description_limit,
|
||||
String.length(description) <= Pleroma.Config.get([:instance, :description_limit])},
|
||||
|
|
|
|||
|
|
@ -15,7 +15,11 @@ defmodule Pleroma.Upload.Filter do
|
|||
|
||||
require Logger
|
||||
|
||||
@callback filter(Pleroma.Upload.t()) :: :ok | {:ok, Pleroma.Upload.t()} | {:error, any()}
|
||||
@callback filter(Pleroma.Upload.t()) ::
|
||||
{:ok, :filtered}
|
||||
| {:ok, :noop}
|
||||
| {:ok, :filtered, Pleroma.Upload.t()}
|
||||
| {:error, any()}
|
||||
|
||||
@spec filter([module()], Pleroma.Upload.t()) :: {:ok, Pleroma.Upload.t()} | {:error, any()}
|
||||
|
||||
|
|
@ -25,10 +29,13 @@ defmodule Pleroma.Upload.Filter do
|
|||
|
||||
def filter([filter | rest], upload) do
|
||||
case filter.filter(upload) do
|
||||
:ok ->
|
||||
{:ok, :filtered} ->
|
||||
filter(rest, upload)
|
||||
|
||||
{:ok, upload} ->
|
||||
{:ok, :filtered, upload} ->
|
||||
filter(rest, upload)
|
||||
|
||||
{:ok, :noop} ->
|
||||
filter(rest, upload)
|
||||
|
||||
error ->
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ defmodule Pleroma.Upload.Filter.AnonymizeFilename do
|
|||
def filter(%Upload{name: name} = upload) do
|
||||
extension = List.last(String.split(name, "."))
|
||||
name = predefined_name(extension) || random(extension)
|
||||
{:ok, %Upload{upload | name: name}}
|
||||
{:ok, :filtered, %Upload{upload | name: name}}
|
||||
end
|
||||
|
||||
def filter(_), do: {:ok, :noop}
|
||||
|
||||
@spec predefined_name(String.t()) :: String.t() | nil
|
||||
defp predefined_name(extension) do
|
||||
with name when not is_nil(name) <- Config.get([__MODULE__, :text]),
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ defmodule Pleroma.Upload.Filter.Dedupe do
|
|||
|> Base.encode16(case: :lower)
|
||||
|
||||
filename = shasum <> "." <> extension
|
||||
{:ok, %Upload{upload | id: shasum, path: filename}}
|
||||
{:ok, :filtered, %Upload{upload | id: shasum, path: filename}}
|
||||
end
|
||||
|
||||
def filter(_), do: :ok
|
||||
def filter(_), do: {:ok, :noop}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,10 +9,22 @@ defmodule Pleroma.Upload.Filter.Exiftool do
|
|||
"""
|
||||
@behaviour Pleroma.Upload.Filter
|
||||
|
||||
@spec filter(Pleroma.Upload.t()) :: {:ok, any()} | {:error, String.t()}
|
||||
|
||||
# webp is not compatible with exiftool at this time
|
||||
def filter(%Pleroma.Upload{content_type: "image/webp"}), do: {:ok, :noop}
|
||||
|
||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||
System.cmd("exiftool", ["-overwrite_original", "-gps:all=", file], parallelism: true)
|
||||
:ok
|
||||
try do
|
||||
case System.cmd("exiftool", ["-overwrite_original", "-gps:all=", file], parallelism: true) do
|
||||
{_response, 0} -> {:ok, :filtered}
|
||||
{error, 1} -> {:error, error}
|
||||
end
|
||||
rescue
|
||||
_e in ErlangError ->
|
||||
{:error, "exiftool command not found"}
|
||||
end
|
||||
end
|
||||
|
||||
def filter(_), do: :ok
|
||||
def filter(_), do: {:ok, :noop}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ defmodule Pleroma.Upload.Filter.Mogrifun do
|
|||
@behaviour Pleroma.Upload.Filter
|
||||
alias Pleroma.Upload.Filter
|
||||
|
||||
@moduledoc """
|
||||
This module is just an example of an Upload filter. It's not supposed to be used in production.
|
||||
"""
|
||||
|
||||
@filters [
|
||||
{"implode", "1"},
|
||||
{"-raise", "20"},
|
||||
|
|
@ -34,11 +38,16 @@ defmodule Pleroma.Upload.Filter.Mogrifun do
|
|||
[{"fill", "yellow"}, {"tint", "40"}]
|
||||
]
|
||||
|
||||
@spec filter(Pleroma.Upload.t()) :: {:ok, atom()} | {:error, String.t()}
|
||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||
try do
|
||||
Filter.Mogrify.do_filter(file, [Enum.random(@filters)])
|
||||
|
||||
:ok
|
||||
{:ok, :filtered}
|
||||
rescue
|
||||
_e in ErlangError ->
|
||||
{:error, "mogrify command not found"}
|
||||
end
|
||||
end
|
||||
|
||||
def filter(_), do: :ok
|
||||
def filter(_), do: {:ok, :noop}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,14 +8,18 @@ defmodule Pleroma.Upload.Filter.Mogrify do
|
|||
@type conversion :: action :: String.t() | {action :: String.t(), opts :: String.t()}
|
||||
@type conversions :: conversion() | [conversion()]
|
||||
|
||||
@spec filter(Pleroma.Upload.t()) :: {:ok, :atom} | {:error, String.t()}
|
||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||
filters = Pleroma.Config.get!([__MODULE__, :args])
|
||||
|
||||
do_filter(file, filters)
|
||||
:ok
|
||||
try do
|
||||
do_filter(file, Pleroma.Config.get!([__MODULE__, :args]))
|
||||
{:ok, :filtered}
|
||||
rescue
|
||||
_e in ErlangError ->
|
||||
{:error, "mogrify command not found"}
|
||||
end
|
||||
end
|
||||
|
||||
def filter(_), do: :ok
|
||||
def filter(_), do: {:ok, :noop}
|
||||
|
||||
def do_filter(file, filters) do
|
||||
file
|
||||
|
|
|
|||
|
|
@ -46,12 +46,23 @@ defmodule Pleroma.Uploaders.S3 do
|
|||
|
||||
op =
|
||||
if streaming do
|
||||
op =
|
||||
upload.tempfile
|
||||
|> ExAws.S3.Upload.stream_file()
|
||||
|> ExAws.S3.upload(bucket, s3_name, [
|
||||
{:acl, :public_read},
|
||||
{:content_type, upload.content_type}
|
||||
])
|
||||
|
||||
if Application.get_env(:tesla, :adapter) == Tesla.Adapter.Gun do
|
||||
# set s3 upload timeout to respect :upload pool timeout
|
||||
# timeout should be slightly larger, so s3 can retry upload on fail
|
||||
timeout = Pleroma.HTTP.AdapterHelper.Gun.pool_timeout(:upload) + 1_000
|
||||
opts = Keyword.put(op.opts, :timeout, timeout)
|
||||
Map.put(op, :opts, opts)
|
||||
else
|
||||
op
|
||||
end
|
||||
else
|
||||
{:ok, file_data} = File.read(upload.tempfile)
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue