Conflicts: lib/pleroma/web/activity_pub/transmogrifier.ex lib/pleroma/user.exstable
commit
bdfa3a6fa8
@ -0,0 +1,403 @@
|
||||
Attribution-NonCommercial-NoDerivatives 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-NonCommercial-NoDerivatives 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-NonCommercial-NoDerivatives 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. 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.
|
||||
|
||||
c. 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.
|
||||
|
||||
d. 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.
|
||||
|
||||
e. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
f. 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.
|
||||
|
||||
g. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
h. NonCommercial means not primarily intended for or directed towards
|
||||
commercial advantage or monetary compensation. For purposes of
|
||||
this Public License, the exchange of the Licensed Material for
|
||||
other material subject to Copyright and Similar Rights by digital
|
||||
file-sharing or similar means is NonCommercial provided there is
|
||||
no payment of monetary compensation in connection with the
|
||||
exchange.
|
||||
|
||||
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, for NonCommercial purposes only; and
|
||||
|
||||
b. produce and reproduce, but not Share, Adapted Material
|
||||
for NonCommercial purposes only.
|
||||
|
||||
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, including when
|
||||
the Licensed Material is used other than for NonCommercial
|
||||
purposes.
|
||||
|
||||
|
||||
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, 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.
|
||||
|
||||
For the avoidance of doubt, You do not have permission under
|
||||
this Public License to Share Adapted Material.
|
||||
|
||||
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.
|
||||
|
||||
|
||||
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 for NonCommercial purposes
|
||||
only and provided You do not Share Adapted Material;
|
||||
|
||||
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.
|
||||
|
@ -0,0 +1,427 @@
|
||||
Attribution-ShareAlike 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-ShareAlike 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-ShareAlike 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. BY-SA Compatible License means a license listed at
|
||||
creativecommons.org/compatiblelicenses, approved by Creative
|
||||
Commons as essentially the equivalent of this Public License.
|
||||
|
||||
d. 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.
|
||||
|
||||
e. 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.
|
||||
|
||||
f. 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.
|
||||
|
||||
g. License Elements means the license attributes listed in the name
|
||||
of a Creative Commons Public License. The License Elements of this
|
||||
Public License are Attribution and ShareAlike.
|
||||
|
||||
h. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
i. 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.
|
||||
|
||||
j. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
k. 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.
|
||||
|
||||
l. 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.
|
||||
|
||||
m. 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. Additional offer from the Licensor -- Adapted Material.
|
||||
Every recipient of Adapted Material from You
|
||||
automatically receives an offer from the Licensor to
|
||||
exercise the Licensed Rights in the Adapted Material
|
||||
under the conditions of the Adapter's License You apply.
|
||||
|
||||
c. 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.
|
||||
|
||||
b. ShareAlike.
|
||||
|
||||
In addition to the conditions in Section 3(a), if You Share
|
||||
Adapted Material You produce, the following conditions also apply.
|
||||
|
||||
1. The Adapter's License You apply must be a Creative Commons
|
||||
license with the same License Elements, this version or
|
||||
later, or a BY-SA Compatible License.
|
||||
|
||||
2. You must include the text of, or the URI or hyperlink to, the
|
||||
Adapter's License You apply. You may satisfy this condition
|
||||
in any reasonable manner based on the medium, means, and
|
||||
context in which You Share Adapted Material.
|
||||
|
||||
3. You may not offer or impose any additional or different terms
|
||||
or conditions on, or apply any Effective Technological
|
||||
Measures to, Adapted Material that restrict exercise of the
|
||||
rights granted under the Adapter's License You apply.
|
||||
|
||||
|
||||
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,
|
||||
including for purposes of Section 3(b); 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.
|
@ -0,0 +1,112 @@
|
||||
# Changelog
|
||||
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]
|
||||
### Added
|
||||
- LDAP authentication
|
||||
- External OAuth provider authentication
|
||||
- A [job queue](https://git.pleroma.social/pleroma/pleroma_job_queue) for federation, emails, web push, etc.
|
||||
- [Prometheus](https://prometheus.io/) metrics
|
||||
- Support for Mastodon's remote interaction
|
||||
- Mix Tasks: `mix pleroma.database remove_embedded_objects`
|
||||
- Federation: Support for reports
|
||||
- Configuration: `safe_dm_mentions` option
|
||||
- Configuration: `link_name` option
|
||||
- Configuration: `fetch_initial_posts` option
|
||||
- Configuration: `notify_email` option
|
||||
- Configuration: Media proxy `whitelist` option
|
||||
- Pleroma API: User subscriptions
|
||||
- Pleroma API: Healthcheck endpoint
|
||||
- Admin API: Endpoints for listing/revoking invite tokens
|
||||
- Admin API: Endpoints for making users follow/unfollow each other
|
||||
- Mastodon API: [Scheduled statuses](https://docs.joinmastodon.org/api/rest/scheduled-statuses/)
|
||||
- Mastodon API: `/api/v1/notifications/destroy_multiple` (glitch-soc extension)
|
||||
- Mastodon API: `/api/v1/pleroma/accounts/:id/favourites` (API extension)
|
||||
- Mastodon API: [Reports](https://docs.joinmastodon.org/api/rest/reports/)
|
||||
- ActivityPub C2S: OAuth endpoints
|
||||
- Metadata RelMe provider
|
||||
- Emoji packs and emoji pack manager
|
||||
|
||||
### Changed
|
||||
- **Breaking:** Configuration: move from Pleroma.Mailer to Pleroma.Emails.Mailer
|
||||
- Enforcement of OAuth scopes
|
||||
- Add multiple use/time expiring invite token
|
||||
- Restyled OAuth pages to fit with Pleroma's default theme
|
||||
- Link/mention/hashtag detection is now handled by [auto_linker](https://git.pleroma.social/pleroma/auto_linker)
|
||||
- NodeInfo: Return `safe_dm_mentions` feature flag
|
||||
- Federation: Expand the audience of delete activities to all recipients of the deleted object
|
||||
- Federation: Removed `inReplyToStatusId` from objects
|
||||
- Configuration: Dedupe enabled by default
|
||||
- Configuration: Added `extra_cookie_attrs` for setting non-standard cookie attributes. Defaults to ["SameSite=Lax"] so that remote follows work.
|
||||
- Pleroma API: Support for emoji tags in `/api/pleroma/emoji` resulting in a breaking API change
|
||||
- Timelines: Messages involving people you have blocked will be excluded from the timeline in all cases instead of just repeats.
|
||||
- Mastodon API: Support for `exclude_types`, `limit` and `min_id` in `/api/v1/notifications`
|
||||
- Mastodon API: Add `languages` and `registrations` to `/api/v1/instance`
|
||||
- Mastodon API: Provide plaintext versions of cw/content in the Status entity
|
||||
- Mastodon API: Add `pleroma.conversation_id`, `pleroma.in_reply_to_account_acct` fields to the Status entity
|
||||
- Mastodon API: Add `pleroma.tags`, `pleroma.relationship{}`, `pleroma.is_moderator`, `pleroma.is_admin`, `pleroma.confirmation_pending`, `pleroma.hide_followers`, `pleroma.hide_follows`, `pleroma.hide_favorites` fields to the User entity
|
||||
- Mastodon API: Add `pleroma.show_role`, `pleroma.no_rich_text` fields to the Source subentity
|
||||
- Mastodon API: Add support for updating `no_rich_text`, `hide_followers`, `hide_follows`, `hide_favorites`, `show_role` in `PATCH /api/v1/update_credentials`
|
||||
- Mastodon API: Add `pleroma.is_seen` to the Notification entity
|
||||
- Mastodon API: Add `pleroma.local` to the Status entity
|
||||
- Mastodon API: Add `preview` parameter to `POST /api/v1/statuses`
|
||||
- Mastodon API: Add `with_muted` parameter to timeline endpoints
|
||||
- Mastodon API: Actual reblog hiding instead of a dummy
|
||||
- Mastodon API: Remove attachment limit in the Status entity
|
||||
- Deps: Updated Cowboy to 2.6
|
||||
- Deps: Updated Ecto to 3.0.7
|
||||
- Don't ship finmoji by default, they can be installed as an emoji pack
|
||||
- Mastodon API: Added support max_id & since_id for bookmark timeline endpoints.
|
||||
|
||||
### Fixed
|
||||
- Followers counter not being updated when a follower is blocked
|
||||
- Deactivated users being able to request an access token
|
||||
- Limit on request body in rich media/relme parsers being ignored resulting in a possible memory leak
|
||||
- proper Twitter Card generation instead of a dummy
|
||||
- NodeInfo: Include admins in `staffAccounts`
|
||||
- ActivityPub: Crashing when requesting empty local user's outbox
|
||||
- Federation: Handling of objects without `summary` property
|
||||
- Federation: Add a language tag to activities as required by ActivityStreams 2.0
|
||||
- Federation: Do not federate avatar/banner if set to default allowing other servers/clients to use their defaults
|
||||
- Federation: Cope with missing or explicitly nulled address lists
|
||||
- Federation: Explicitly ensure activities addressed to `as:Public` become addressed to the followers collection
|
||||
- Federation: Better cope with actors which do not declare a followers collection and use `as:Public` with these semantics
|
||||
- Federation: Follow requests from remote users who have been blocked will be automatically rejected if appropriate
|
||||
- MediaProxy: Parse name from content disposition headers even for non-whitelisted types
|
||||
- MediaProxy: S3 link encoding
|
||||
- Rich Media: Reject any data which cannot be explicitly encoded into JSON
|
||||
- Pleroma API: Importing follows from Mastodon 2.8+
|
||||
- Twitter API: Exposing default scope, `no_rich_text` of the user to anyone
|
||||
- Twitter API: Returning the `role` object in user entity despite `show_role = false`
|
||||
- Mastodon API: `/api/v1/favourites` serving only public activities
|
||||
- Mastodon API: Reblogs having `in_reply_to_id` - `null` even when they are replies
|
||||
- Mastodon API: Streaming API broadcasting wrong activity id
|
||||
- Mastodon API: 500 errors when requesting a card for a private conversation
|
||||
- Mastodon API: Handling of `reblogs` in `/api/v1/accounts/:id/follow`
|
||||
- Mastodon API: Correct `reblogged`, `favourited`, and `bookmarked` values in the reblog status JSON
|
||||
- Mastodon API: Exposing default scope of the user to anyone
|
||||
|
||||
## [0.9.9999] - 2019-04-05
|
||||
### Security
|
||||
- Mastodon API: Fix content warnings skipping HTML sanitization
|
||||
|
||||
## [0.9.999] - 2019-03-13
|
||||
Frontend changes only.
|
||||
### Added
|
||||
- Added floating action button for posting status on mobile
|
||||
### Changed
|
||||
- Changed user-settings icon to a pencil
|
||||
### Fixed
|
||||
- Keyboard shortcuts activating when typing a message
|
||||
- Gaps when scrolling down on a timeline after showing new
|
||||
|
||||
## [0.9.99] - 2019-03-08
|
||||
### Changed
|
||||
- Update the frontend to the 0.9.99 tag
|
||||
### Fixed
|
||||
- Sign the date header in federation to fix Mastodon federation.
|
||||
|
||||
## [0.9.9] - 2019-02-22
|
||||
This is our first stable release.
|
@ -0,0 +1,41 @@
|
||||
Unless otherwise stated this repository is copyright © 2017-2019
|
||||
Pleroma Authors <https://pleroma.social/>, and is distributed under
|
||||
The GNU Affero General Public License Version 3, you should have received a
|
||||
copy of the license file as AGPL-3.
|
||||
|
||||
---
|
||||
|
||||
The following files are copyright © 2019 shitposter.club, and are distributed
|
||||
under the Creative Commons Attribution-ShareAlike 4.0 International license,
|
||||
you should have received a copy of the license file as CC-BY-SA-4.0.
|
||||
|
||||
priv/static/images/pleroma-fox-tan.png
|
||||
priv/static/images/pleroma-fox-tan-smol.png
|
||||
priv/static/images/pleroma-tan.png
|
||||
|
||||
---
|
||||
|
||||
The following files are copyright © 2017-2019 Pleroma Authors
|
||||
<https://pleroma.social/>, and are distributed under the Creative Commons
|
||||
Attribution-ShareAlike 4.0 International license, you should have received
|
||||
a copy of the license file as CC-BY-SA-4.0.
|
||||
|
||||
priv/static/images/avi.png
|
||||
priv/static/images/banner.png
|
||||
priv/static/instance/thumbnail.jpeg
|
||||
|
||||
---
|
||||
|
||||
All photos published on Unsplash can be used for free. You can use them for
|
||||
commercial and noncommercial purposes. You do not need to ask permission from
|
||||
or provide credit to the photographer or Unsplash, although it is appreciated
|
||||
when possible.
|
||||
|
||||
More precisely, Unsplash grants you an irrevocable, nonexclusive, worldwide
|
||||
copyright license to download, copy, modify, distribute, perform, and use
|
||||
photos from Unsplash for free, including for commercial purposes, without
|
||||
permission from or attributing the photographer or Unsplash. This license
|
||||
does not include the right to compile photos from Unsplash to replicate
|
||||
a similar or competing service.
|
||||
|
||||
priv/static/images/city.jpg
|
@ -1,25 +0,0 @@
|
||||
# Differences in Mastodon API responses from vanilla Mastodon
|
||||
|
||||
A Pleroma instance can be identified by "<Mastodon version> (compatible; Pleroma <version>)" present in `version` field in response from `/api/v1/instance`
|
||||
|
||||
## Flake IDs
|
||||
|
||||
Pleroma uses 128-bit ids as opposed to Mastodon's 64 bits. However just like Mastodon's ids they are sortable strings
|
||||
|
||||
## Attachment cap
|
||||
|
||||
Some apps operate under the assumption that no more than 4 attachments can be returned or uploaded. Pleroma however does not enforce any limits on attachment count neither when returning the status object nor when posting.
|
||||
|
||||
## Timelines
|
||||
|
||||
Adding the parameter `with_muted=true` to the timeline queries will also return activities by muted (not by blocked!) users.
|
||||
|
||||
## Statuses
|
||||
|
||||
Has these additional fields under the `pleroma` object:
|
||||
|
||||
- `local`: true if the post was made on the local instance.
|
||||
|
||||
## Accounts
|
||||
|
||||
- `/api/v1/accounts/:id`: The `id` parameter can also be the `nickname` of the user. This only works in this endpoint, not the deeper nested ones for following etc.
|
@ -0,0 +1,17 @@
|
||||
# Backup/Restore your instance
|
||||
|
||||
## Backup
|
||||
|
||||
1. Stop the Pleroma service.
|
||||
2. Go to the working directory of Pleroma (default is `/opt/pleroma`)
|
||||
3. Run `sudo -Hu postgres pg_dump -d <pleroma_db> --format=custom -f </path/to/backup_location/pleroma.pgdump>`
|
||||
4. Copy `pleroma.pgdump`, `config/prod.secret.exs` and the `uploads` folder to your backup destination. If you have other modifications, copy those changes too.
|
||||
5. Restart the Pleroma service.
|
||||
|
||||
## Restore
|
||||
|
||||
1. Stop the Pleroma service.
|
||||
2. Go to the working directory of Pleroma (default is `/opt/pleroma`)
|
||||
3. Copy the above mentioned files back to their original position.
|
||||
4. Run `sudo -Hu postgres pg_restore -d <pleroma_db> -v -1 </path/to/backup_location/pleroma.pgdump>`
|
||||
5. Restart the Pleroma service.
|
@ -0,0 +1,9 @@
|
||||
# Updating your instance
|
||||
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.
|
||||
4. Stop the Pleroma service.
|
||||
5. Run `mix ecto.migrate`[^1]. 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.
|
@ -0,0 +1,82 @@
|
||||
# Differences in Mastodon API responses from vanilla Mastodon
|
||||
|
||||
A Pleroma instance can be identified by "<Mastodon version> (compatible; Pleroma <version>)" present in `version` field in response from `/api/v1/instance`
|
||||
|
||||
## Flake IDs
|
||||
|
||||
Pleroma uses 128-bit ids as opposed to Mastodon's 64 bits. However just like Mastodon's ids they are sortable strings
|
||||
|
||||
## Attachment cap
|
||||
|
||||
Some apps operate under the assumption that no more than 4 attachments can be returned or uploaded. Pleroma however does not enforce any limits on attachment count neither when returning the status object nor when posting.
|
||||
|
||||
## Timelines
|
||||
|
||||
Adding the parameter `with_muted=true` to the timeline queries will also return activities by muted (not by blocked!) users.
|
||||
|
||||
## Statuses
|
||||
|
||||
Has these additional fields under the `pleroma` object:
|
||||
|
||||
- `local`: true if the post was made on the local instance.
|
||||
- `conversation_id`: the ID of the conversation the status is associated with (if any)
|
||||
- `in_reply_to_account_acct`: the `acct` property of User entity for replied user (if any)
|
||||
- `content`: a map consisting of alternate representations of the `content` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`
|
||||
- `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being it's mimetype. Currently the only alternate representation supported is `text/plain`
|
||||
|
||||
## Attachments
|
||||
|
||||
Has these additional fields under the `pleroma` object:
|
||||
|
||||
- `mime_type`: mime type of the attachment.
|
||||
|
||||
## Accounts
|
||||
|
||||
- `/api/v1/accounts/:id`: The `id` parameter can also be the `nickname` of the user. This only works in this endpoint, not the deeper nested ones for following etc.
|
||||
|
||||
Has these additional fields under the `pleroma` object:
|
||||
|
||||
- `tags`: Lists an array of tags for the user
|
||||
- `relationship{}`: Includes fields as documented for Mastodon API https://docs.joinmastodon.org/api/entities/#relationship
|
||||
- `is_moderator`: boolean, nullable, true if user is a moderator
|
||||
- `is_admin`: boolean, nullable, true if user is an admin
|
||||
- `confirmation_pending`: boolean, true if a new user account is waiting on email confirmation to be activated
|
||||
- `hide_followers`: boolean, true when the user has follower hiding enabled
|
||||
- `hide_follows`: boolean, true when the user has follow hiding enabled
|
||||
|
||||
### Source
|
||||
|
||||
Has these additional fields under the `pleroma` object:
|
||||
|
||||
- `show_role`: boolean, nullable, true when the user wants his role (e.g admin, moderator) to be shown
|
||||
- `no_rich_text` - boolean, nullable, true when html tags are stripped from all statuses requested from the API
|
||||
|
||||
## Account Search
|
||||
|
||||
Behavior has changed:
|
||||
|
||||
- `/api/v1/accounts/search`: Does not require authentication
|
||||
|
||||
## Notifications
|
||||
|
||||
Has these additional fields under the `pleroma` object:
|
||||
|
||||
- `is_seen`: true if the notification was read by the user
|
||||
|
||||
## POST `/api/v1/statuses`
|
||||
|
||||
Additional parameters can be added to the JSON body/Form data:
|
||||
|
||||
- `preview`: boolean, if set to `true` the post won't be actually posted, but the status entitiy would still be rendered back. This could be useful for previewing rich text/custom emoji, for example.
|
||||
- `content_type`: string, contain the MIME type of the status, it is transformed into HTML by the backend. You can get the list of the supported MIME types with the nodeinfo endpoint.
|
||||
|
||||
## PATCH `/api/v1/update_credentials`
|
||||
|
||||
Additional parameters can be added to the JSON body/Form data:
|
||||
|
||||
- `no_rich_text` - if true, html tags are stripped from all statuses requested from the API
|
||||
- `hide_followers` - if true, user's followers will be hidden
|
||||
- `hide_follows` - if true, user's follows will be hidden
|
||||
- `hide_favorites` - if true, user's favorites timeline will be hidden
|
||||
- `show_role` - if true, user's role (e.g admin, moderator) will be exposed to anyone in the API
|
||||
- `default_scope` - the scope returned under `privacy` key in Source subentity
|
@ -0,0 +1,22 @@
|
||||
# Prometheus Metrics
|
||||
|
||||
Pleroma includes support for exporting metrics via the [prometheus_ex](https://github.com/deadtrickster/prometheus.ex) library.
|
||||
|
||||
## `/api/pleroma/app_metrics`
|
||||
### Exports Prometheus application metrics
|
||||
* Method: `GET`
|
||||
* Authentication: not required
|
||||
* Params: none
|
||||
* Response: JSON
|
||||
|
||||
## Grafana
|
||||
### Config example
|
||||
The following is a config example to use with [Grafana](https://grafana.com)
|
||||
|
||||
```
|
||||
- job_name: 'beam'
|
||||
metrics_path: /api/pleroma/app_metrics
|
||||
scheme: https
|
||||
static_configs:
|
||||
- targets: ['pleroma.soykaf.com']
|
||||
```
|
@ -0,0 +1,17 @@
|
||||
# General tips for customizing Pleroma FE
|
||||
There are some configuration scripts for Pleroma BE and FE:
|
||||
|
||||
1. `config/prod.secret.exs`
|
||||
1. `config/config.exs`
|
||||
1. `priv/static/static/config.json`
|
||||
|
||||
The `prod.secret.exs` affects first. `config.exs` is for fallback or default. `config.json` is for GNU-social-BE-Pleroma-FE instances.
|
||||
|
||||
Usually all you have to do is:
|
||||
|
||||
1. Copy the section in the `config/config.exs` which you want to activate.
|
||||
1. Paste into `config/prod.secret.exs`.
|
||||
1. Edit `config/prod.secret.exs`.
|
||||
1. Restart the Pleroma daemon.
|
||||
|
||||
`prod.secret.exs` is for the `MIX_ENV=prod` environment. `dev.secret.exs` is for the `MIX_ENV=dev` environment respectively.
|
@ -0,0 +1,68 @@
|
||||
# Custom Emoji
|
||||
|
||||
Before you add your own custom emoji, check if they are available in an existing pack.
|
||||
See `Mix.Tasks.Pleroma.Emoji` for information about emoji packs.
|
||||
|
||||
To add custom emoji:
|
||||
* Create the `STATIC-DIR/emoji/` directory if it doesn't exist
|
||||
(`STATIC-DIR` is configurable, `instance/static/` by default)
|
||||
* Create a directory with whatever name you want (custom is a good name to show the purpose of it).
|
||||
This will create a local emoji pack.
|
||||
* Put your `.png` emoji files in that directory. In case of conflicts, you can create an `emoji.txt`
|
||||
file in that directory and specify a custom shortcode using the following format:
|
||||
`shortcode, file-path, tag1, tag2, etc`. One emoji per line. Note that if you do so,
|
||||
you'll have to list all other emojis in the pack too.
|
||||
* Either restart pleroma or connect to the iex session pleroma's running and
|
||||
run `Pleroma.Emoji.reload/0` in it.
|
||||
|
||||
Example:
|
||||
|
||||
image files (in `instance/static/emoji/custom`): `happy.png` and `sad.png`
|
||||
|
||||
content of `emoji.txt`:
|
||||
```
|
||||
happy, /emoji/custom/happy.png, Tag1,Tag2
|
||||
sad, /emoji/custom/sad.png, Tag1
|
||||
foo, /emoji/custom/foo.png
|
||||
```
|
||||
|
||||
The files should be PNG (APNG is okay with `.png` for `image/png` Content-type) and under 50kb for compatibility with mastodon.
|
||||
|
||||
Default file extentions and locations for emojis are set in `config.exs`. To use different locations or file-extentions, add the `shortcode_globs` to your secrets file (`prod.secret.exs` or `dev.secret.exs`) and edit it. Note that not all fediverse-software will show emojis with other file extentions:
|
||||
```elixir
|
||||
config :pleroma, :emoji, shortcode_globs: ["/emoji/custom/**/*.png", "/emoji/custom/**/*.gif"]
|
||||
```
|
||||
|
||||
## Emoji tags (groups)
|
||||
|
||||
Default tags are set in `config.exs`. To set your own tags, copy the structure to your secrets file (`prod.secret.exs` or `dev.secret.exs`) and edit it.
|
||||
```elixir
|
||||
config :pleroma, :emoji,
|
||||
shortcode_globs: ["/emoji/custom/**/*.png"],
|
||||
groups: [
|
||||
Finmoji: "/finmoji/128px/*-128.png",
|
||||
Custom: ["/emoji/*.png", "/emoji/custom/*.png"]
|
||||
]
|
||||
```
|
||||
|
||||
Order of the `groups` matters, so to override default tags just put your group on top of the list. E.g:
|
||||
```elixir
|
||||
config :pleroma, :emoji,
|
||||
shortcode_globs: ["/emoji/custom/**/*.png"],
|
||||
groups: [
|
||||
"Finmoji special": "/finmoji/128px/a_trusted_friend-128.png", # special file
|
||||
"Cirno": "/emoji/custom/cirno*.png", # png files in /emoji/custom/ which start with `cirno`
|
||||
"Special group": "/emoji/custom/special_folder/*.png", # png files in /emoji/custom/special_folder/
|
||||
"Another group": "/emoji/custom/special_folder/*/.png", # png files in /emoji/custom/special_folder/ subfolders
|
||||
Finmoji: "/finmoji/128px/*-128.png",
|
||||
Custom: ["/emoji/*.png", "/emoji/custom/*.png"]
|
||||
]
|
||||
```
|
||||
|
||||
Priority of tags assigns in emoji.txt and custom.txt:
|
||||
|
||||
`tag in file > special group setting in config.exs > default setting in config.exs`
|
||||
|
||||
Priority for globs:
|
||||
|
||||
`special group setting in config.exs > default setting in config.exs`
|
@ -0,0 +1,32 @@
|
||||
# How to activate mediaproxy
|
||||
## Explanation
|
||||
|
||||
Without the `mediaproxy` function, Pleroma don't store any remote content like pictures, video etc. locally. So every time you open Pleroma, the content is loaded from the source server, from where the post is coming. This can result in slowly loading content or/and increased bandwidth usage on the source server.
|
||||
With the `mediaproxy` function you can use the cache ability of nginx, to cache these content, so user can access it faster, cause it's loaded from your server.
|
||||
|
||||
## Activate it
|
||||
|
||||
* Edit your nginx config and add the following location:
|
||||
```
|
||||
location /proxy {
|
||||
proxy_cache pleroma_media_cache;
|
||||
proxy_cache_lock on;
|
||||
proxy_pass http://localhost:4000;
|
||||
}
|
||||
```
|
||||
Also add the following on top of the configuration, outside of the `server` block:
|
||||
```
|
||||
proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=10g inactive=720m use_temp_path=off;
|
||||
```
|
||||
If you came here from one of the installation guides, take a look at the example configuration `/installation/pleroma.nginx`, where this part is already included.
|
||||
|
||||
* Append the following to your `prod.secret.exs` or `dev.secret.exs` (depends on which mode your instance is running):
|
||||
```
|
||||
config :pleroma, :media_proxy,
|
||||
enabled: true,
|
||||
redirect_on_failure: true
|
||||
#base_url: "https://cache.pleroma.social"
|
||||
```
|
||||
If you want to use a subdomain to serve the files, uncomment `base_url`, change the url and add a comma after `true` in the previous line.
|
||||
|
||||
* Restart nginx and Pleroma
|
@ -0,0 +1,12 @@
|
||||
# How to configure upstream proxy for federation
|
||||
If you want to proxify all http requests (e.g. for TOR) that pleroma makes to an upstream proxy server, edit you config file (`dev.secret.exs` or `prod.secret.exs`) and add the following:
|
||||
|
||||
```
|
||||
config :pleroma, :http,
|
||||
proxy_url: "127.0.0.1:8123"
|
||||
```
|
||||
|
||||
The other way to do it, for example, with Tor you would most likely add something like this:
|
||||
```
|
||||
config :pleroma, :http, proxy_url: {:socks5, :localhost, 9050}
|
||||
```
|
@ -0,0 +1,31 @@
|
||||
# How to activate user recommendation (Who to follow panel)
|
||||
![who-to-follow-panel-small](/uploads/9de1b1300436c32461d272945f1bc23e/who-to-follow-panel-small.png)
|
||||
|
||||
To show the *who to follow* panel, edit `config/prod.secret.exs` in the Pleroma backend. Following code activates the *who to follow* panel:
|
||||
|
||||
```elixir
|
||||
config :pleroma, :suggestions,
|
||||
enabled: true,
|
||||
third_party_engine:
|
||||
"http://vinayaka.distsn.org/cgi-bin/vinayaka-user-match-suggestions-api.cgi?{{host}}+{{user}}",
|
||||
timeout: 300_000,
|
||||
limit: 23,
|
||||
web: "https://vinayaka.distsn.org/?{{host}}+{{user}}"
|
||||
|
||||
```
|
||||
|
||||
`config/config.exs` already includes this code, but `enabled:` is `false`.
|
||||
|
||||
`/api/v1/suggestions` is also provided when *who to follow* panel is enabled.
|
||||
|
||||
For advanced customization, following code shows the newcomers of the fediverse at the *who to follow* panel:
|
||||
|
||||
```elixir
|
||||
config :pleroma, :suggestions,
|
||||
enabled: true,
|
||||
third_party_engine:
|
||||
"http://vinayaka.distsn.org/cgi-bin/vinayaka-user-new-suggestions-api.cgi?{{host}}+{{user}}",
|
||||
timeout: 60_000,
|
||||
limit: 23,
|
||||
web: "https://vinayaka.distsn.org/user-new.html"
|
||||
```
|
@ -0,0 +1,196 @@
|
||||
# I2P Federation and Accessability
|
||||
|
||||
This guide is going to focus on the Pleroma federation aspect. The actual installation is neatly explained in the official documentation, and more likely to remain up-to-date.
|
||||
It might be added to this guide if there will be a need for that.
|
||||
|
||||
We're going to use I2PD for its lightweightness over the official client.
|
||||
Follow the documentation according to your distro: https://i2pd.readthedocs.io/en/latest/user-guide/install/#installing
|
||||
|
||||
How to run it: https://i2pd.readthedocs.io/en/latest/user-guide/run/
|
||||
|
||||
## I2P Federation
|
||||
|
||||
There are 2 ways to go about this.
|
||||
One using the config, and one using external software (fedproxy). The external software works better so far.
|
||||
|
||||
### Using the Config
|
||||
|
||||
**Warning:** So far, everytime I followed this way of federating using I2P, the rest of my federation stopped working. I'm leaving this here in case it will help with making it work.
|
||||
|
||||
Assuming you're running in prod, cd to your Pleroma folder and append the following to `config/prod.secret.exs`:
|
||||
```
|
||||
config :pleroma, :http, proxy_url: {:socks5, :localhost, 4447}
|
||||
```
|
||||
And then run the following:
|
||||
```
|
||||
su pleroma
|
||||
MIX_ENV=prod mix deps.get
|
||||
MIX_ENV=prod mix ecto.migrate
|
||||
exit
|
||||
```
|
||||
You can restart I2PD here and finish if you don't wish to make your instance viewable or accessible over I2P.
|
||||
```
|
||||
systemctl stop i2pd.service --no-block
|
||||
systemctl start i2pd.service
|
||||
```
|
||||
*Notice:* The stop command initiates a graceful shutdown process, i2pd stops after finishing to route transit tunnels (maximum 10 minutes).
|
||||
|
||||
You can change the socks proxy port in `/etc/i2pd/i2pd.conf`.
|
||||
|
||||
### Using Fedproxy
|
||||
|
||||
Fedproxy passes through clearnet requests direct to where they are going. It doesn't force anything over Tor.
|
||||
|
||||
To use [fedproxy](https://github.com/majestrate/fedproxy) you'll need to install Golang.
|
||||
```
|
||||
apt install golang
|
||||
```
|
||||
Use a different user than pleroma or root. Run the following to add the Gopath to your ~/.bashrc.
|
||||
```
|
||||
echo "export GOPATH=/home/ren/.go" >> ~/.bashrc
|
||||
```
|
||||
Restart that bash session (you can exit and log back in).
|
||||
Run the following to get fedproxy.
|
||||
```
|
||||
go get -u github.com/majestrate/fedproxy$
|
||||
cp $(GOPATH)/bin/fedproxy /usr/local/bin/fedproxy
|
||||
```
|
||||
And then the following to start it for I2P only.
|
||||
```
|
||||
fedproxy 127.0.0.1:2000 127.0.0.1:4447
|
||||
```
|
||||
If you want to also use it for Tor, add `127.0.0.1:9050` to that command.
|
||||
You'll also need to modify your Pleroma config.
|
||||
|
||||
Assuming you're running in prod, cd to your Pleroma folder and append the following to `config/prod.secret.exs`:
|
||||
```
|
||||
config :pleroma, :http, proxy_url: {:socks5, :localhost, 2000}
|
||||
```
|
||||
And then run the following:
|
||||
```
|
||||
su pleroma
|
||||
MIX_ENV=prod mix deps.get
|
||||
MIX_ENV=prod mix ecto.migrate
|
||||
exit
|
||||
```
|
||||
You can restart I2PD here and finish if you don't wish to make your instance viewable or accessible over I2P.
|
||||
|
||||
```
|
||||
systemctl stop i2pd.service --no-block
|
||||
systemctl start i2pd.service
|
||||
```
|
||||
*Notice:* The stop command initiates a graceful shutdown process, i2pd stops after finishing to route transit tunnels (maximum 10 minutes).
|
||||
|
||||
You can change the socks proxy port in `/etc/i2pd/i2pd.conf`.
|
||||
|
||||
## I2P Instance Access
|
||||
|
||||
Make your instance accessible using I2P.
|
||||
|
||||
Add the following to your I2PD config `/etc/i2pd/tunnels.conf`:
|
||||
```
|
||||
[pleroma]
|
||||
type = http
|
||||
host = 127.0.0.1
|
||||
port = 14447
|
||||
keys = pleroma.dat
|
||||
```
|
||||
Restart I2PD:
|
||||
```
|
||||
systemctl stop i2pd.service --no-block
|
||||
systemctl start i2pd.service
|
||||
```
|
||||
*Notice:* The stop command initiates a graceful shutdown process, i2pd stops after finishing to route transit tunnels (maximum 10 minutes).
|
||||
|
||||
Now you'll have to find your address.
|
||||
To do that you can download and use I2PD tools.[^1]
|
||||
Or you'll need to access your web-console on localhost:7070.
|
||||
If you don't have a GUI, you'll have to SSH tunnel into it like this:
|
||||
`ssh -L 7070:127.0.0.1:7070 user@ip -p port`.
|
||||
Now you can access it at localhost:7070.
|
||||
Go to I2P tunnels page. Look for Server tunnels and you will see an address that ends with `.b32.i2p` next to "pleroma".
|
||||
This is your site's address.
|
||||
|
||||
### I2P-only Instance
|
||||
|
||||
If creating an I2P-only instance, open `config/prod.secret.exs` and under "config :pleroma, Pleroma.Web.Endpoint," edit "https" and "port: 443" to the following:
|
||||
```
|
||||
url: [host: "i2paddress", scheme: "http", port: 80],
|
||||
```
|
||||
In addition to that, replace the existing nginx config's contents with the example below.
|
||||
|
||||
### Existing Instance (Clearnet Instance)
|
||||
|
||||
If not an I2P-only instance, add the nginx config below to your existing config at `/etc/nginx/sites-enabled/pleroma.nginx`.
|
||||
|
||||
And for both cases, disable CSP in Pleroma's config (STS is disabled by default) so you can define those yourself seperately from the clearnet (if your instance is also on the clearnet).
|
||||
Copy the following into the `config/prod.secret.exs` in your Pleroma folder (/home/pleroma/pleroma/):
|
||||
```
|
||||
config :pleroma, :http_security,
|
||||
enabled: false
|
||||
```
|
||||
|
||||
Use this as the Nginx config:
|
||||
```
|
||||
proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=10g inactive=720m use_temp_path=off;
|
||||
# The above already exists in a clearnet instance's config.
|
||||
# If not, add it.
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:14447;
|
||||
server_name youri2paddress;
|
||||
|
||||
# Comment to enable logs
|
||||
access_log /dev/null;
|
||||
error_log /dev/null;
|
||||
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/activity+json application/atom+xml;
|
||||
|
||||
client_max_body_size 16m;
|
||||
|
||||
location / {
|
||||
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Permitted-Cross-Domain-Policies none;
|
||||
add_header X-Frame-Options DENY;
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header Referrer-Policy same-origin;
|
||||
add_header X-Download-Options noopen;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $http_host;
|
||||
|
||||
proxy_pass http://localhost:4000;
|
||||
|
||||
client_max_body_size 16m;
|
||||
}
|
||||
|
||||
location /proxy {
|
||||
proxy_cache pleroma_media_cache;
|
||||
proxy_cache_lock on;
|
||||
proxy_ignore_client_abort on;
|
||||
proxy_pass http://localhost:4000;
|
||||
}
|
||||
}
|
||||
```
|
||||
reload Nginx:
|
||||
```
|
||||
systemctl stop i2pd.service --no-block
|
||||
systemctl start i2pd.service
|
||||
```
|
||||
*Notice:* The stop command initiates a graceful shutdown process, i2pd stops after finishing to route transit tunnels (maximum 10 minutes).
|
||||
|
||||
You should now be able to both access your instance using I2P and federate with other I2P instances!
|
||||
|
||||
[^1]: [I2PD tools](https://github.com/purplei2p/i2pd-tools) to print information about a router info file or an I2P private key, generate an I2P private key, and generate vanity addresses.
|
||||
|
||||
### Possible Issues
|
||||
|
||||
Will be added when encountered.
|
@ -0,0 +1,119 @@
|
||||
# Message Rewrite Facility
|
||||
The Message Rewrite Facility (MRF) is a subsystem that is implemented as a series of hooks that allows the administrator to rewrite or discard messages.
|
||||
|
||||
Possible uses include:
|
||||
|
||||
* marking incoming messages with media from a given account or instance as sensitive
|
||||
* rejecting messages from a specific instance
|
||||
* removing/unlisting messages from the public timelines
|
||||
* removing media from messages
|
||||
* sending only public messages to a specific instance
|
||||
|
||||
The MRF provides user-configurable policies. The default policy is `NoOpPolicy`, which disables the MRF functionality. Pleroma also includes an easy to use policy called `SimplePolicy` which maps messages matching certain pre-defined criterion to actions built into the policy module.
|
||||
It is possible to use multiple, active MRF policies at the same time.
|
||||
|
||||
## Quarantine Instances
|
||||
|
||||
You have the ability to prevent from private / followers-only messages from federating with specific instances. Which means they will only get the public or unlisted messages from your instance.
|
||||
|
||||
If, for example, you're using `MIX_ENV=prod` aka using production mode, you would open your configuration file located in `config/prod.secret.exs` and edit or add the option under your `:instance` config object. Then you would specify the instance within quotes.
|
||||
```
|
||||
config :pleroma, :instance,
|
||||
[...]
|
||||
quarantined_instances: ["instance.example", "other.example"]
|
||||
```
|
||||
|
||||
## Using `SimplePolicy`
|
||||
|
||||
`SimplePolicy` is capable of handling most common admin tasks.
|
||||
|
||||
To use `SimplePolicy`, you must enable it. Do so by adding the following to your `:instance` config object, so that it looks like this:
|
||||
|
||||
```
|
||||
config :pleroma, :instance,
|
||||
[...]
|
||||
rewrite_policy: Pleroma.Web.ActivityPub.MRF.SimplePolicy
|
||||
```
|
||||
|
||||
Once `SimplePolicy` is enabled, you can configure various groups in the `:mrf_simple` config object. These groups are:
|
||||
|
||||
* `media_removal`: Servers in this group will have media stripped from incoming messages.
|
||||
* `media_nsfw`: Servers in this group will have the #nsfw tag and sensitive setting injected into incoming messages which contain media.
|
||||
* `reject`: Servers in this group will have their messages rejected.
|
||||
* `federated_timeline_removal`: Servers in this group will have their messages unlisted from the public timelines by flipping the `to` and `cc` fields.
|
||||
|
||||
Servers should be configured as lists.
|
||||
|
||||
### Example
|
||||
|
||||
This example will enable `SimplePolicy`, block media from `illegalporn.biz`, mark media as NSFW from `porn.biz` and `porn.business`, reject messages from `spam.com` and remove messages from `spam.university` from the federated timeline:
|
||||
|
||||
```
|
||||
config :pleroma, :instance,
|
||||
rewrite_policy: [Pleroma.Web.ActivityPub.MRF.SimplePolicy]
|
||||
|
||||
config :pleroma, :mrf_simple,
|
||||
media_removal: ["illegalporn.biz"],
|
||||
media_nsfw: ["porn.biz", "porn.business"],
|
||||
reject: ["spam.com"],
|
||||
federated_timeline_removal: ["spam.university"]
|
||||
|
||||
```
|
||||
|
||||
### Use with Care
|
||||
|
||||
The effects of MRF policies can be very drastic. It is important to use this functionality carefully. Always try to talk to an admin before writing an MRF policy concerning their instance.
|
||||
|
||||
## Writing your own MRF Policy
|
||||
|
||||
As discussed above, the MRF system is a modular system that supports pluggable policies. This means that an admin may write a custom MRF policy in Elixir or any other language that runs on the Erlang VM, by specifying the module name in the `rewrite_policy` config setting.
|
||||
|
||||
For example, here is a sample policy module which rewrites all messages to "new message content":
|
||||
|
||||
```elixir
|
||||
# This is a sample MRF policy which rewrites all Notes to have "new message
|
||||
# content."
|
||||
defmodule Site.RewritePolicy do
|
||||
@behavior Pleroma.Web.ActivityPub.MRF
|
||||
|
||||
# Catch messages which contain Note objects with actual data to filter.
|
||||
# Capture the object as `object`, the message content as `content` and the
|
||||
# message itself as `message`.
|
||||
@impl true
|
||||
def filter(%{"type" => Create", "object" => {"type" => "Note", "content" => content} = object} = message)
|
||||
when is_binary(content) do
|
||||
# Subject / CW is stored as summary instead of `name` like other AS2 objects
|
||||
# because of Mastodon doing it that way.
|
||||
summary = object["summary"]
|
||||
|
||||
# Message edits go here.
|
||||
content = "new message content"
|
||||
|
||||
# Assemble the mutated object.
|
||||
object =
|
||||
object
|
||||
|> Map.put("content", content)
|
||||
|> Map.put("summary", summary)
|
||||
|
||||
# Assemble the mutated message.
|
||||
message = Map.put(message, "object", object)
|
||||
{:ok, message}
|
||||
end
|
||||
|
||||
# Let all other messages through without modifying them.
|
||||
@impl true
|
||||
def filter(message), do: {:ok, message}
|
||||
end
|
||||
```
|
||||
|
||||
If you save this file as `lib/site/mrf/rewrite_policy.ex`, it will be included when you next rebuild Pleroma. You can enable it in the configuration like so:
|
||||
|
||||
```
|
||||
config :pleroma, :instance,
|
||||
rewrite_policy: [
|
||||
Pleroma.Web.ActivityPub.MRF.SimplePolicy,
|
||||
Site.RewritePolicy
|
||||
]
|
||||
```
|
||||
|
||||
Please note that the Pleroma developers consider custom MRF policy modules to fall under the purview of the AGPL. As such, you are obligated to release the sources to your custom MRF policy modules upon request.
|
@ -0,0 +1,159 @@
|
||||
# Easy Onion Federation (Tor)
|
||||
Tor can free people from the necessity of a domain, in addition to helping protect their privacy. As Pleroma's goal is to empower the people and let as many as possible host an instance with as little resources as possible, the ability to host an instance with a small, cheap computer like a RaspberryPi along with Tor, would be a great way to achieve that.
|
||||
In addition, federating with such instances will also help furthering that goal.
|
||||
|
||||
This is a guide to show you how it can be easily done.
|
||||
|
||||
This guide assumes you already got Pleroma working, and that it's running on the default port 4000.
|
||||
Currently only has an Nginx example.
|
||||
|
||||
To install Tor on Debian / Ubuntu:
|
||||
```
|
||||
apt -yq install tor
|
||||
```
|
||||
If using an old server version (older than Debian Stretch or Ubuntu 18.04), install from backports or PPA.
|
||||
I recommend using a newer server version instead.
|
||||
|
||||
To have the newest, V3 onion addresses (which I recommend) in Debian, install Tor from backports.
|
||||
If you do not have backports, uncomment the stretch-backports links at the end of `/etc/apt/sources.list`.
|
||||
Then install:
|
||||
```
|
||||
apt update
|
||||
apt -t stretch-backports -yq install tor
|
||||
```
|
||||
**WARNING:** Onion instances not using a Tor version supporting V3 addresses will not be able to federate with you.
|
||||
|
||||
Create the hidden service for your Pleroma instance in `/etc/tor/torrc`:
|
||||
```
|
||||
HiddenServiceDir /var/lib/tor/pleroma_hidden_service/
|
||||
HiddenServicePort 80 127.0.0.1:8099
|
||||
HiddenServiceVersion 3 # Remove if Tor version is below 0.3 ( tor --version )
|
||||
```
|
||||
Restart Tor to generate an adress:
|
||||
```
|
||||
systemctl restart tor@default.service
|
||||
```
|
||||
Get the address:
|
||||
```
|
||||
cat /var/lib/tor/pleroma_hidden_service/hostname
|
||||
```
|
||||
|
||||
# Federation
|
||||
|
||||
Next, edit your Pleroma config.
|
||||
If running in prod, cd to your Pleroma directory, edit `config/prod.secret.exs`
|
||||
and append this line:
|
||||
```
|
||||
config :pleroma, :http, proxy_url: {:socks5, :localhost, 9050}
|
||||
```
|
||||
In your Pleroma directory, assuming you're running prod,
|
||||
run the following:
|
||||
```
|
||||
su pleroma
|
||||
MIX_ENV=prod mix deps.get
|
||||
MIX_ENV=prod mix ecto.migrate
|
||||
exit
|
||||
```
|
||||
restart Pleroma (if using systemd):
|
||||
```
|
||||
systemctl restart pleroma
|
||||
```
|
||||
|
||||
# Tor Instance Access
|
||||
|
||||
Make your instance accessible using Tor.
|
||||
|
||||
## Tor-only Instance
|
||||
If creating a Tor-only instance, open `config/prod.secret.exs` and under "config :pleroma, Pleroma.Web.Endpoint," edit "https" and "port: 443" to the following:
|
||||
```
|
||||
url: [host: "onionaddress", scheme: "http", port: 80],
|
||||
```
|
||||
In addition to that, replace the existing nginx config's contents with the example below.
|
||||
|
||||
## Existing Instance (Clearnet Instance)
|
||||
If not a Tor-only instance,
|
||||
add the nginx config below to your existing config at `/etc/nginx/sites-enabled/pleroma.nginx`.
|
||||
|
||||
---
|
||||
For both cases, disable CSP in Pleroma's config (STS is disabled by default) so you can define those yourself seperately from the clearnet (if your instance is also on the clearnet).
|
||||
Copy the following into the `config/prod.secret.exs` in your Pleroma folder (/home/pleroma/pleroma/):
|
||||
```
|
||||
config :pleroma, :http_security,
|
||||
enabled: false
|
||||
```
|
||||
|
||||
Use this as the Nginx config:
|
||||
```
|
||||
proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=10g inactive=720m use_temp_path=off;
|
||||
# The above already exists in a clearnet instance's config.
|
||||
# If not, add it.
|
||||
|
||||
server {
|
||||
listen 127.0.0.1:8099;
|
||||
server_name youronionaddress;
|
||||
|
||||
# Comment to enable logs
|
||||
access_log /dev/null;
|
||||
error_log /dev/null;
|
||||
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_buffers 16 8k;
|
||||
gzip_http_version 1.1;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/activity+json application/atom+xml;
|
||||
|
||||
client_max_body_size 16m;
|
||||
|
||||
location / {
|
||||
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Permitted-Cross-Domain-Policies none;
|
||||
add_header X-Frame-Options DENY;
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header Referrer-Policy same-origin;
|
||||
add_header X-Download-Options noopen;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $http_host;
|
||||
|
||||
proxy_pass http://localhost:4000;
|
||||
|
||||
client_max_body_size 16m;
|
||||
}
|
||||
|
||||
location /proxy {
|
||||
proxy_cache pleroma_media_cache;
|
||||
proxy_cache_lock on;
|
||||
proxy_ignore_client_abort on;
|
||||
proxy_pass http://localhost:4000;
|
||||
}
|
||||
}
|
||||
```
|
||||
reload Nginx:
|
||||
```
|
||||
systemctl reload nginx
|
||||
```
|
||||
|
||||
You should now be able to both access your instance using Tor and federate with other Tor instances!
|
||||
|
||||
---
|
||||
|
||||
### Possible Issues
|
||||
|
||||
* In Debian, make sure your hidden service folder `/var/lib/tor/pleroma_hidden_service/` and its contents, has debian-tor as both owner and group by using
|
||||
```
|
||||
ls -la /var/lib/tor/
|
||||
```
|
||||
If it's not, run:
|
||||
```
|
||||
chown -R debian-tor:debian-tor /var/lib/tor/pleroma_hidden_service/
|
||||
```
|
||||
* Make sure *only* the owner has *only* read and write permissions.
|
||||
If not, run:
|
||||
```
|
||||
chmod -R 600 /var/lib/tor/pleroma_hidden_service/
|
||||
```
|
||||
* If you have trouble logging in to the Mastodon Frontend when using Tor, use the Tor Browser Bundle.
|
@ -0,0 +1,35 @@
|
||||
# Small customizations
|
||||
Replace `dev.secret.exs` with `prod.secret.exs` according to your setup.
|
||||
|
||||
# Thumbnail
|
||||
|
||||
Replace `priv/static/instance/thumbnail.jpeg` with your selfie or other neat picture. It will appear in [Pleroma Instances](http://distsn.org/pleroma-instances.html).
|
||||
|
||||
# Instance-specific panel
|
||||
|
||||
![instance-specific panel demo](/uploads/296b19ec806b130e0b49b16bfe29ce8a/image.png)
|
||||
|
||||
To show the instance specific panel, set `show_instance_panel` to `true` in `config/dev.secret.exs`. You can modify its content by editing `priv/static/instance/panel.html`.
|
||||
|
||||
# Background
|
||||
|
||||
You can change the background of your Pleroma instance by uploading it to `priv/static/static`, and then changing `"background"` in `config/dev.secret.exs` accordingly.
|
||||
|
||||
# Logo
|
||||
|
||||
![logo modification demo](/uploads/c70b14de60fa74245e7f0dcfa695ebff/image.png)
|
||||
|
||||
If you want to give a brand to your instance, look no further. You can change the logo of your instance by uploading it to `priv/static/static`, and then changing `logo` in `config/dev.secret.exs` accordingly.
|
||||
|
||||
# Theme
|
||||
|
||||
All users of your instance will be able to change the theme they use by going to the settings (the cog in the top-right hand corner). However, if you wish to change the default theme, you can do so by editing `theme` in `config/dev.secret.exs` accordingly.
|
||||
|
||||
# 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 `priv/static/static/terms-of-service.html`.
|
||||
|
||||
# Message Visibility
|
||||
|
||||
To enable message visibility options when posting like in the Mastodon frontend, set
|
||||
`scope_options_enabled` to `true` in `config/dev.secret.exs`.
|
@ -0,0 +1,20 @@
|
||||
# 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/`.
|
||||
|
||||
```
|
||||
config :pleroma, :instance,
|
||||
static_dir: "instance/static/",
|
||||
```
|
||||
|
||||
You can overwrite this value in your configuration to use a different static instance directory.
|
||||
|
||||
## 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.
|
||||
|
||||
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.
|
||||
|
||||
```
|
||||
mix pleroma.robots_txt disallow_all
|
||||
```
|
@ -0,0 +1,198 @@
|
||||
# Installing on NetBSD
|
||||
|
||||
## Required software
|
||||
|
||||
pkgin should have been installed by the NetBSD installer if you selected
|
||||
the right options. If it isn't installed, install it using pkg_add.
|
||||
|
||||
Note that `postgresql11-contrib` is needed for the Postgres extensions
|
||||
Pleroma uses.
|
||||
|
||||
The `mksh` shell is needed to run the Elixir `mix` script.
|
||||
|
||||
`# pkgin install acmesh elixir git-base git-docs mksh nginx postgresql11-server postgresql11-client postgresql11-contrib sudo`
|
||||
|
||||
You can also build these packages using pkgsrc:
|
||||
```
|
||||
databases/postgresql11-contrib
|
||||
databases/postgresql11-client
|
||||
databases/postgresql11-server
|
||||
devel/git-base
|
||||
devel/git-docs
|
||||
lang/elixir
|
||||
security/acmesh
|
||||
security/sudo
|
||||
shells/mksh
|
||||
www/nginx
|
||||
```
|
||||
|
||||
Copy the rc.d scripts to the right directory:
|
||||
|
||||
```
|
||||
# cp /usr/pkg/share/examples/rc.d/nginx /usr/pkg/share/examples/rc.d/pgsql /etc/rc.d
|
||||
```
|
||||
|
||||
Add nginx and Postgres to `/etc/rc.conf`:
|
||||
|
||||
```
|
||||
nginx=YES
|
||||
pgsql=YES
|
||||
```
|
||||
|
||||
## Configuring postgres
|
||||
|
||||
First, run `# /etc/rc.d/pgsql start`. Then, `$ sudo -Hu pgsql -g pgsql createdb`.
|
||||
|
||||
## Configuring Pleroma
|
||||
|
||||
Create a user for Pleroma:
|
||||
|
||||
```
|
||||
# groupadd pleroma
|
||||
# useradd -d /home/pleroma -m -g pleroma -s /usr/pkg/bin/mksh pleroma
|
||||
# echo 'export LC_ALL="en_GB.UTF-8"' >> /home/pleroma/.profile
|
||||
# su -l pleroma -c $SHELL
|
||||
```
|
||||
|
||||
Clone the repository:
|
||||
|
||||
```
|
||||
$ cd /home/pleroma
|
||||
$ git clone 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
|
||||
$ mix pleroma.instance gen # You will be asked a few questions here.
|
||||
```
|
||||
|
||||
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. Now initialize the database:
|
||||
|
||||
```
|
||||
$ sudo -Hu pgsql -g pgsql psql -f config/setup_db.psql
|
||||
```
|
||||
|
||||
Postgres allows connections from all users without a password by default. To
|
||||
fix this, edit `/usr/pkg/pgsql/data/pg_hba.conf`. Change every `trust` to
|
||||
`password`.
|
||||
|
||||
Once this is done, restart Postgres with `# /etc/rc.d/pgsql restart`.
|
||||
|
||||
Run the database migrations.
|
||||
You will need to do this whenever you update with `git pull`:
|
||||
|
||||
```
|
||||
$ MIX_ENV=prod mix ecto.migrate
|
||||
```
|
||||
|
||||
## Configuring nginx
|
||||
|
||||
Install the example configuration file
|
||||
`/home/pleroma/pleroma/installation/pleroma.nginx` to
|
||||
`/usr/pkg/etc/nginx.conf`.
|
||||
|
||||
Note that it will need to be wrapped in a `http {}` block. You should add
|
||||
settings for the nginx daemon outside of the http block, for example:
|
||||
|
||||
```
|
||||
user nginx nginx;
|
||||
error_log /var/log/nginx/error.log;
|
||||
worker_processes 4;
|
||||
|
||||
events {
|
||||
}
|
||||
```
|
||||
|
||||
Edit the defaults:
|
||||
|
||||
* Change `ssl_certificate` and `ssl_trusted_certificate` to
|
||||
`/etc/nginx/tls/fullchain`.
|
||||
* Change `ssl_certificate_key` to `/etc/nginx/tls/key`.
|
||||
* Change `example.tld` to your instance's domain name.
|
||||
|
||||
## Configuring acme.sh
|
||||
|
||||
We'll be using acme.sh in Stateless Mode for TLS certificate renewal.
|
||||
|
||||
First, get your account fingerprint:
|
||||
|
||||
```
|
||||
$ sudo -Hu nginx -g nginx 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:
|
||||
|
||||
```
|
||||
# /etc/rc.d/nginx start
|
||||
```
|
||||
|
||||
It should now be possible to issue a cert (replace `example.com`
|
||||
with your domain name):
|
||||
|
||||
```
|
||||
$ sudo -Hu nginx -g nginx acme.sh --issue -d example.com --stateless
|
||||
```
|
||||
|
||||
Let's add auto-renewal to `/etc/daily.local`
|
||||
(replace `example.com` with your domain):
|
||||
|
||||
```
|
||||
/usr/pkg/bin/sudo -Hu nginx -g nginx \
|
||||
/usr/pkg/sbin/acme.sh -r \
|
||||
-d example.com \
|
||||
--cert-file /etc/nginx/tls/cert \
|
||||
--key-file /etc/nginx/tls/key \
|
||||
--ca-file /etc/nginx/tls/ca \
|
||||
--fullchain-file /etc/nginx/tls/fullchain \
|
||||
--stateless
|
||||
```
|
||||
|
||||
## Creating a startup script for Pleroma
|
||||
|
||||
Copy the startup script to the correct location and make sure it's executable:
|
||||
|
||||
```
|
||||
# cp /home/pleroma/pleroma/installation/netbsd/rc.d/pleroma /etc/rc.d/pleroma
|
||||
# chmod +x /etc/rc.d/pleroma
|
||||
```
|
||||
|
||||
Add the following to `/etc/rc.conf`:
|
||||
|
||||
```
|
||||
pleroma=YES
|
||||
pleroma_home="/home/pleroma"
|
||||
pleroma_user="pleroma"
|
||||
```
|
||||
|
||||
Run `# /etc/rc.d/pleroma start` to start Pleroma.
|
||||
|
||||
## Conclusion
|
||||
|
||||
Restart nginx with `# /etc/rc.d/nginx restart` and you should be up and running.
|
||||
|
||||
If you need further help, contact niaa on freenode.
|
||||
|
||||
Make sure your time is in sync, or other instances will receive your posts with
|
||||
incorrect timestamps. You should have ntpd running.
|
||||
|
||||
## Instances running NetBSD
|
||||
|
||||
* <https://catgirl.science>
|
@ -0,0 +1,222 @@
|
||||
# Installing on OpenBSD
|
||||
This guide describes the installation and configuration of pleroma (and the required software to run it) on a single OpenBSD 6.4 server.
|
||||
For any additional information regarding commands and configuration files mentioned here, check the man pages [online](https://man.openbsd.org/) or directly on your server with the man command.
|
||||
|
||||
#### Required software
|
||||
The following packages need to be installed:
|
||||
* elixir
|
||||
* gmake
|
||||
* ImageMagick
|
||||
* git
|
||||
* postgresql-server
|
||||
* postgresql-contrib
|
||||
|
||||
To install them, run the following command (with doas or as root):
|
||||
`pkg_add elixir gmake ImageMagick git postgresql-server postgresql-contrib`
|
||||
|
||||
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.
|
||||
|
||||
#### Creating the pleroma user
|
||||
Pleroma will be run by a dedicated user, \_pleroma. Before creating it, insert the following lines in login.conf:
|
||||
```
|
||||
pleroma:\
|
||||
:datasize-max=1536M:\
|
||||
:datasize-cur=1536M:\
|
||||
:openfiles-max=4096
|
||||
```
|
||||
This creates a "pleroma" login class and sets higher values than default for datasize and openfiles (see [login.conf(5)](https://man.openbsd.org/login.conf)), this is required to avoid having pleroma crash some time after starting.
|
||||
|
||||
Create the \_pleroma user, assign it the pleroma login class and create its home directory (/home/\_pleroma/): `useradd -m -L pleroma _pleroma`
|
||||
|
||||
#### Clone pleroma's directory
|
||||
Enter a shell as the \_pleroma user. As root, run `su _pleroma -;cd`. Then clone the repository with `git clone https://git.pleroma.social/pleroma/pleroma.git`. Pleroma is now installed in /home/\_pleroma/pleroma/, it will be configured and started at the end of this guide.
|
||||
|
||||
#### Postgresql
|
||||
Start a shell as the \_postgresql user (as root run `su _postgresql -` then run the `initdb` command to initialize postgresql:
|
||||
If you wish to not use the default location for postgresql's data (/var/postgresql/data), add the following switch at the end of the command: `-D <path>` and modify the `datadir` variable in the /etc/rc.d/postgresql script.
|
||||
|
||||
When this is done, enable postgresql so that it starts on boot and start it. As root, run:
|
||||
```
|
||||
rcctl enable postgresql
|
||||
rcctl start postgresql
|
||||
```
|
||||
To check that it started properly and didn't fail right after starting, you can run `ps aux | grep postgres`, there should be multiple lines of output.
|
||||
|
||||
#### httpd
|
||||
httpd will have three fuctions:
|
||||
* redirect requests trying to reach the instance over http to the https URL
|
||||
* serve a robots.txt file
|
||||
* get Let's Encrypt certificates, with acme-client
|
||||
|
||||
Insert the following config in httpd.conf:
|
||||
```
|
||||
# $OpenBSD: httpd.conf,v 1.17 2017/04/16 08:50:49 ajacoutot Exp $
|
||||
|
||||
ext_inet="<IPv4 address>"
|
||||
ext_inet6="<IPv6 address>"
|
||||
|
||||
server "default" {
|
||||
listen on $ext_inet port 80 # Comment to disable listening on IPv4
|
||||
listen on $ext_inet6 port 80 # Comment to disable listening on IPv6
|
||||
listen on 127.0.0.1 port 80 # Do NOT comment this line
|
||||
|
||||
log syslog
|
||||
directory no index
|
||||
|
||||
location "/.well-known/acme-challenge/*" {
|
||||
root "/acme"
|
||||
request strip 2
|
||||
}
|
||||
|
||||
location "/robots.txt" { root "/htdocs/local/" }
|
||||
location "/*" { block return 302 "https://$HTTP_HOST$REQUEST_URI" }
|
||||
}
|
||||
|
||||
types {
|
||||
include "/usr/share/misc/mime.types"
|
||||
}
|
||||
```
|
||||
Do not forget to change *\<IPv4/6 address\>* to your server's address(es). If httpd should only listen on one protocol family, comment one of the two first *listen* options.
|
||||
|
||||
Create the /var/www/htdocs/local/ folder and write the content of your robots.txt in /var/www/htdocs/local/robots.txt.
|
||||
Check the configuration with `httpd -n`, if it is OK enable and start httpd (as root):
|
||||
```
|
||||
rcctl enable httpd
|
||||
rcctl start httpd
|
||||
```
|
||||
|
||||
#### acme-client
|
||||
acme-client is used to get SSL/TLS certificates from Let's Encrypt.
|
||||
Insert the following configuration in /etc/acme-client.conf:
|
||||
```
|
||||
#
|
||||
# $OpenBSD: acme-client.conf,v 1.4 2017/03/22 11:14:14 benno Exp $
|
||||
#
|
||||
|
||||
authority letsencrypt-<domain name> {
|
||||
#agreement url "https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf"
|
||||
api url "https://acme-v01.api.letsencrypt.org/directory"
|
||||
account key "/etc/acme/letsencrypt-privkey-<domain name>.pem"
|
||||
}
|
||||
|
||||
domain <domain name> {
|
||||
domain key "/etc/ssl/private/<domain name>.key"
|
||||
domain certificate "/etc/ssl/<domain name>.crt"
|
||||
domain full chain certificate "/etc/ssl/<domain name>.fullchain.pem"
|
||||
sign with letsencrypt-<domain name>
|
||||
challengedir "/var/www/acme/"
|
||||
}
|
||||
```
|
||||
Replace *\<domain name\>* by the domain name you'll use for your instance. As root, run `acme-client -n` to check the config, then `acme-client -ADv <domain name>` to create account and domain keys, and request a certificate for the first time.
|
||||
Make acme-client run everyday by adding it in /etc/daily.local. As root, run the following command: `echo "acme-client <domain name>" >> /etc/daily.local`.
|
||||
|
||||
Relayd will look for certificates and keys based on the address it listens on (see next part), the easiest way to make them available to relayd is to create a link, as root run:
|
||||
```
|
||||
ln -s /etc/ssl/<domain name>.fullchain.pem /etc/ssl/<IP address>.crt
|
||||
ln -s /etc/ssl/private/<domain name>.key /etc/ssl/private/<IP address>.key
|
||||
```
|
||||
This will have to be done for each IPv4 and IPv6 address relayd listens on.
|
||||
|
||||
#### relayd
|
||||
relayd will be used as the reverse proxy sitting in front of pleroma.
|
||||
Insert the following configuration in /etc/relayd.conf:
|
||||
```
|
||||
# $OpenBSD: relayd.conf,v 1.4 2018/03/23 09:55:06 claudio Exp $
|
||||
|
||||
ext_inet="<IPv4 address>"
|
||||
ext_inet6="<IPv6 address>"
|
||||
|
||||
table <pleroma_server> { 127.0.0.1 }
|
||||
table <httpd_server> { 127.0.0.1 }
|
||||
|
||||
http protocol plerup { # Protocol for upstream pleroma server
|
||||
#tcp { nodelay, sack, socket buffer 65536, backlog 128 } # Uncomment and adjust as you see fit
|
||||
tls ciphers "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305"
|
||||
tls ecdhe secp384r1
|
||||
|
||||
# Forward some paths to the local server (as pleroma won't respond to them as you might want)
|
||||
pass request quick path "/robots.txt" forward to <httpd_server>
|
||||
|
||||
# Append a bunch of headers
|
||||
match request header append "X-Forwarded-For" value "$REMOTE_ADDR" # This two header and the next one are not strictly required by pleroma but adding them won't hurt
|
||||
match request header append "X-Forwarded-By" value "$SERVER_ADDR:$SERVER_PORT"
|
||||
|
||||
match response header append "X-XSS-Protection" value "1; mode=block"
|
||||
match response header append "X-Permitted-Cross-Domain-Policies" value "none"
|
||||
match response header append "X-Frame-Options" value "DENY"
|
||||
match response header append "X-Content-Type-Options" value "nosniff"
|
||||
match response header append "Referrer-Policy" value "same-origin"
|
||||
match response header append "X-Download-Options" value "noopen"
|
||||
match response header append "Content-Security-Policy" value "default-src 'none'; base-uri 'self'; form-action 'self'; img-src 'self' data: https:; media-src 'self' https:; style-src 'self' 'unsafe-inline'; font-src 'self'; script-src 'self'; connect-src 'self' wss://CHANGEME.tld; upgrade-insecure-requests;" # Modify "CHANGEME.tld" and set your instance's domain here
|
||||
match request header append "Connection" value "upgrade"
|
||||
#match response header append "Strict-Transport-Security" value "max-age=31536000; includeSubDomains" # Uncomment this only after you get HTTPS working.
|
||||
|
||||
# If you do not want remote frontends to be able to access your Pleroma backend server, comment these lines
|
||||
match response header append "Access-Control-Allow-Origin" value "*"
|
||||
match response header append "Access-Control-Allow-Methods" value "POST, PUT, DELETE, GET, PATCH, OPTIONS"
|
||||
match response header append "Access-Control-Allow-Headers" value "Authorization, Content-Type, Idempotency-Key"
|
||||
match response header append "Access-Control-Expose-Headers" value "Link, X-RateLimit-Reset, X-RateLimit-Limit, X-RateLimit-Remaining, X-Request-Id"
|
||||
# Stop commenting lines here
|
||||
}
|
||||
|
||||
relay wwwtls {
|
||||
listen on $ext_inet port https tls # Comment to disable listening on IPv4
|
||||
listen on $ext_inet6 port https tls # Comment to disable listening on IPv6
|
||||
|
||||
protocol plerup
|
||||
|
||||
forward to <pleroma_server> port 4000 check http "/" code 200
|
||||
forward to <httpd_server> port 80 check http "/robots.txt" code 200
|
||||
}
|
||||
```
|
||||
Again, change *\<IPv4/6 address\>* to your server's address(es) and comment one of the two *listen* options if needed. Also change *wss://CHANGEME.tld* to *wss://\<your instance's domain name\>*.
|
||||
Check the configuration with `relayd -n`, if it is OK enable and start relayd (as root):
|
||||
```
|
||||
rcctl enable relayd
|
||||
rcctl start relayd
|
||||
```
|
||||
|
||||
#### pf
|
||||
Enabling and configuring pf is highly recommended.
|
||||
In /etc/pf.conf, insert the following configuration:
|
||||
```
|
||||
# Macros
|
||||
if="<network interface>"
|
||||
authorized_ssh_clients="any"
|
||||
|
||||
# Skip traffic on loopback interface
|
||||
set skip on lo
|
||||
|
||||
# Default behavior
|
||||
set block-policy drop
|
||||
block in log all
|
||||
pass out quick
|
||||
|
||||
# Security features
|
||||
match in all scrub (no-df random-id)
|
||||
block in log from urpf-failed
|
||||
|
||||
# Rules
|
||||
pass in quick on $if inet proto icmp to ($if) icmp-type { echoreq unreach paramprob trace } # ICMP
|
||||
pass in quick on $if inet6 proto icmp6 to ($if) icmp6-type { echoreq unreach paramprob timex toobig } # ICMPv6
|
||||
pass in quick on $if proto tcp to ($if) port { http https } # relayd/httpd
|
||||
pass in quick on $if proto tcp from $authorized_ssh_clients to ($if) port ssh
|
||||
```
|
||||
Replace *\<network interface\>* by your server's network interface name (which you can get with ifconfig). Consider replacing the content of the authorized\_ssh\_clients macro by, for exemple, your home IP address, to avoid SSH connection attempts from bots.
|
||||
|
||||
Check pf's configuration by running `pfctl -nf /etc/pf.conf`, load it with `pfctl -f /etc/pf.conf` and enable pf at boot with `rcctl enable pf`.
|
||||
|
||||
#### Configure and start pleroma
|
||||
Enter a shell as \_pleroma (as root `su _pleroma -`) and enter pleroma's installation directory (`cd ~/pleroma/`).
|
||||
Then follow the main installation guide:
|
||||
* run `mix deps.get`
|
||||
* run `mix pleroma.instance gen` and enter your instance's information when asked
|
||||
* copy config/generated\_config.exs to config/prod.secret.exs. The default values should be sufficient but you should edit it and check that everything seems OK.
|
||||
* exit your current shell back to a root one and run `psql -U postgres -f /home/_pleroma/config/setup_db.psql` to setup the database.
|
||||
* return to a \_pleroma shell into pleroma's installation directory (`su _pleroma -;cd ~/pleroma`) and run `MIX_ENV=prod mix ecto.migrate`
|
||||
|
||||
As \_pleroma in /home/\_pleroma/pleroma, you can now run `LC_ALL=en_US.UTF-8 MIX_ENV=prod mix phx.server` to start your instance.
|
||||
In another SSH session/tmux window, check that it is working properly by running `ftp -MVo - http://127.0.0.1:4000/api/v1/instance`, you should get json output. Double-check that *uri*'s value is your instance's domain name.
|
||||
|
||||
##### Starting pleroma at boot
|
||||
An rc script to automatically start pleroma at boot hasn't been written yet, it can be run in a tmux session (tmux is in base).
|
@ -0,0 +1,110 @@
|
||||
# Pleroman asennus OpenBSD:llä
|
||||
|
||||
Tarvitset:
|
||||
* Oman domainin
|
||||
* OpenBSD 6.3 -serverin
|
||||
* Auttavan ymmärryksen unix-järjestelmistä
|
||||
|
||||
Komennot, joiden edessä on '#', tulee ajaa käyttäjänä `root`. Tämä on
|
||||
suositeltavaa tehdä komennon `doas` avulla, katso `doas (1)` ja `doas.conf (5)`.
|
||||
Tästä eteenpäin oletuksena on, että domain "esimerkki.com" osoittaa
|
||||
serverin IP-osoitteeseen.
|
||||
|
||||
Jos asennuksen kanssa on ongelmia, IRC-kanava #pleroma Freenodessa tai
|
||||
Matrix-kanava #freenode_#pleroma:matrix.org ovat hyviä paikkoja löytää apua
|
||||
(englanniksi), `/msg eal kukkuu` jos haluat välttämättä puhua härmää.
|
||||
|
||||
Asenna tarvittava ohjelmisto:
|
||||
|
||||
`# pkg_add git elixir gmake postgresql-server-10.3 postgresql-contrib-10.3`
|
||||
|
||||
Luo postgresql-tietokanta:
|
||||
|
||||
`# su - _postgresql`
|
||||
|
||||
`$ mkdir /var/postgresql/data`
|
||||
|
||||
`$ initdb -D /var/postgresql/data -E UTF8`
|
||||
|
||||
`$ createdb`
|
||||
|
||||
Käynnistä tietokanta ja aseta se käynnistymään automaattisesti.
|
||||
|
||||
`# rcctl start postgresql`
|
||||
|
||||
`# rcctl enable postgresql`
|
||||
|
||||
Luo käyttäjä pleromaa varten (kysyy muutaman kysymyksen):
|
||||
|
||||
`# adduser pleroma`
|
||||
|
||||
Vaihda pleroma-käyttäjään ja mene kotihakemistoosi:
|
||||
|
||||
`# su - pleroma`
|
||||
|
||||
Lataa pleroman lähdekoodi:
|
||||
|
||||
`$ git clone https://git.pleroma.social/pleroma/pleroma.git`
|
||||
|
||||
`$ cd pleroma`
|
||||
|
||||
Asenna tarvittavat elixir-kirjastot:
|
||||
|
||||
`$ mix deps.get`
|
||||
|
||||
`$ mix deps.compile`
|
||||
|
||||
Luo tarvittava konfiguraatio:
|
||||
|
||||
`$ mix generate_config`
|
||||
|
||||
`$ cp config/generated_config.exs config/prod.secret.exs`
|
||||
|
||||
Aja luodut tietokantakomennot:
|
||||
|
||||
`# su _postgres -c 'psql -f config/setup_db.psql'`
|
||||
|
||||
`$ MIX_ENV=prod mix ecto.migrate`
|
||||
|
||||
Käynnistä pleroma-prosessi:
|
||||
|
||||
`$ MIX_ENV=prod mix compile`
|
||||
|
||||
`$ MIX_ENV=prod mix phx.server`
|
||||
|
||||
Tässä vaiheessa on hyvä tarkistaa että asetukset ovat oikein. Avaa selaimella,
|
||||
curlilla tai vastaavalla työkalulla `esimerkki.com:4000/api/v1/instance` ja katso
|
||||
että kohta "uri" on "https://esimerkki.com".
|
||||
|
||||
Huom! Muista varmistaa että muuttuja MIX_ENV on "prod" mix-komentoja ajaessasi.
|
||||
Mix lukee oikean konfiguraatiotiedoston sen mukaisesti.
|
||||
|
||||
Ohessa enimmäkseen toimivaksi todettu rc.d-skripti pleroman käynnistämiseen.
|
||||
Kirjoita se tiedostoon /etc/rc.d/pleroma. Tämän jälkeen aja
|
||||
`# chmod +x /etc/rc.d/pleroma`, ja voit käynnistää pleroman komennolla
|
||||
`# /etc/rc.d/pleroma start`.
|
||||
|
||||
```
|
||||
#!/bin/ksh
|
||||
#/etc/rc.d/pleroma
|
||||
|
||||
daemon="cd /home/pleroma/pleroma;MIX_ENV=prod /usr/local/bin/elixir"
|
||||
daemon_flags="--detached /usr/local/bin/mix phx.server"
|
||||
daemon_user="pleroma"
|
||||
rc_reload="NO"
|
||||
rc_bg="YES"
|
||||
|
||||
pexp="beam"
|
||||
|
||||
. /etc/rc.d/rc.subr
|
||||
|
||||
rc_cmd $1
|
||||
```
|
||||
|
||||
Tämän jälkeen tarvitset enää HTTP-serverin välittämään kutsut pleroma-prosessille.
|
||||
Tiedostosta `install/pleroma.nginx` löytyy esimerkkikonfiguraatio, ja TLS-sertifikaatit
|
||||
saat ilmaiseksi esimerkiksi [letsencryptiltä](https://certbot.eff.org/lets-encrypt/opbsd-nginx.html).
|
||||
Nginx asentuu yksinkertaisesti komennolla `# pkg_add nginx`.
|
||||
|
||||
Kun olet valmis, avaa https://esimerkki.com selaimessasi. Luo käyttäjä ja seuraa kiinnostavia
|
||||
tyyppejä muilla palvelimilla!
|
@ -0,0 +1,55 @@
|
||||
# Introduction to Pleroma
|
||||
## What is Pleroma?
|
||||
Pleroma is a federated social networking platform, compatible with GNU social, Mastodon and other OStatus and ActivityPub implementations. It is free software licensed under the AGPLv3.
|
||||
It actually consists of two components: a backend, named simply Pleroma, and a user-facing frontend, named Pleroma-FE. It also includes the Mastodon frontend, if that's your thing.
|
||||
It's part of what we call the fediverse, a federated network of instances which speak common protocols and can communicate with each other.
|
||||
One account on a instance is enough to talk to the entire fediverse!
|
||||
|
||||
## How can I use it?
|
||||
|
||||
Pleroma instances are already widely deployed, a list can be found here:
|
||||
http://distsn.org/pleroma-instances.html
|
||||
|
||||
If you don't feel like joining an existing instance, but instead prefer to deploy your own instance, that's easy too!
|
||||
Installation instructions can be found here:
|
||||
[main Pleroma wiki](/)
|
||||
|
||||
## I got an account, now what?
|
||||
Great! Now you can explore the fediverse!
|
||||
- Open the login page for your Pleroma instance (for ex. https://pleroma.soykaf.com) and login with your username and password.
|
||||
(If you don't have one yet, click on Register) :slightly_smiling_face:
|
||||
|
||||
At this point you will have two columns in front of you.
|
||||
|
||||
### Left column
|
||||
- first block: here you can see your avatar, your nickname a bio, and statistics (Statuses, Following, Followers).
|
||||
Under that you have a text form which allows you to post new statuses. The icon on the left is for uploading media files and attach them to your post. The number under the text form is a character counter, every instance can have a different character limit (the default is 5000).
|
||||
If you want to mention someone, type @ + name of the person. A drop-down menu will help you in finding the right person. :slight_smile:
|
||||
To post your status, simply press Submit.
|
||||
|
||||
- second block: Here you can switch between the different timelines:
|
||||
- Timeline: all the people that you follow
|
||||
- Mentions: all the statutes where you are mentioned
|
||||
- Public Timeline: all the statutes from the local instance
|
||||
- The Whole Known Network: everything, local and remote!
|
||||
|
||||
- third block: this is the Chat block, where you communicate with people on the same instance in realtime. It is local-only, for now, but we're planning to make it extendable to the entire fediverse! :sweat_smile:
|
||||
|
||||
- fourth block: This is the Notifications block, here you will get notified whenever somebody mentions you, follows you, repeats or favorites one of your statuses.
|
||||
|
||||
### Right column
|
||||
This is where the interesting stuff happens! :slight_smile:
|
||||
Depending on the timeline you will see different statuses, but each status has a standard structure:
|
||||
- Icon + name + link to profile. An optional left-arrow if it's a reply to another status (hovering will reveal the replied-to status).
|
||||
- A + button on the right allows you to Expand/Collapse an entire discussion thread. It also updates in realtime!
|
||||
- A binocular icon allows you to open the status on the instance where it's originating from.
|
||||
- The text of the status, including mentions. If you click on a mention, it will automatically open the profile page of that person.
|
||||
- Four buttons (left to right): Reply, Repeat, Favorite, Delete.
|
||||
|
||||
## Mastodon interface
|
||||
If the Pleroma interface isn't your thing, or you're just trying something new but you want to keep using the familiar Mastodon interface, we got that too! :smile:
|
||||
Just add a "/web" after your instance url (for ex. https://pleroma.soycaf.com/web) and you'll end on the Mastodon web interface, but with a Pleroma backend! MAGIC! :fireworks:
|
||||
For more information on the Mastodon interface, please look here:
|
||||
https://github.com/tootsuite/documentation/blob/master/Using-Mastodon/User-guide.md
|
||||
|
||||
Remember, what you see is only the frontend part of Mastodon, the backend is still Pleroma.
|
@ -0,0 +1,21 @@
|
||||
; Assumes pleroma is installed in /home/pleroma/pleroma and running as the pleroma user
|
||||
; Also assumes mix is in /usr/bin, this might differ on BSDs or niche Linux distros
|
||||
; Logs into /home/pleroma/logs
|
||||
[program:pleroma]
|
||||
command=/usr/bin/mix phx.server
|
||||
directory=/home/pleroma/pleroma
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user=pleroma
|
||||
environment =
|
||||
MIX_ENV=prod,
|
||||
HOME=/home/pleroma,
|
||||
USER=pleroma,
|
||||
PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/pleroma/bin:%(ENV_PATH)s",
|
||||
PWD=/home/pleroma/pleroma
|
||||
stdout_logfile=/home/pleroma/logs/stdout.log
|
||||
stdout_logfile_maxbytes=50MB
|
||||
stdout_logfile_backups=10
|
||||
stderr_logfile=/home/pleroma/logs/stderr.log
|
||||
stderr_logfile_maxbytes=50MB
|
||||
stderr_logfile_backups=10
|
@ -0,0 +1,60 @@
|
||||
defmodule Pleroma.Healthcheck do
|
||||
@moduledoc """
|
||||
Module collects metrics about app and assign healthy status.
|
||||
"""
|
||||
alias Pleroma.Healthcheck
|
||||
alias Pleroma.Repo
|
||||
|
||||
defstruct pool_size: 0,
|
||||
active: 0,
|
||||
idle: 0,
|
||||
memory_used: 0,
|
||||
healthy: true
|
||||
|
||||
@type t :: %__MODULE__{
|
||||
pool_size: non_neg_integer(),
|
||||
active: non_neg_integer(),
|
||||
idle: non_neg_integer(),
|
||||
memory_used: number(),
|
||||
healthy: boolean()
|
||||
}
|
||||
|
||||
@spec system_info() :: t()
|
||||
def system_info do
|
||||
%Healthcheck{
|
||||
memory_used: Float.round(:erlang.memory(:total) / 1024 / 1024, 2)
|
||||
}
|
||||
|> assign_db_info()
|
||||
|> check_health()
|
||||
end
|
||||
|
||||
defp assign_db_info(healthcheck) do
|
||||
database = Application.get_env(:pleroma, Repo)[:database]
|
||||
|
||||
query =
|
||||
"select state, count(pid) from pg_stat_activity where datname = '#{database}' group by state;"
|
||||
|
||||
result = Repo.query!(query)
|
||||
pool_size = Application.get_env(:pleroma, Repo)[:pool_size]
|
||||
|
||||
db_info =
|
||||
Enum.reduce(result.rows, %{active: 0, idle: 0}, fn [state, cnt], states ->
|
||||
if state == "active" do
|
||||
Map.put(states, :active, states.active + cnt)
|
||||
else
|
||||
Map.put(states, :idle, states.idle + cnt)
|
||||
end
|
||||
end)
|
||||
|> Map.put(:pool_size, pool_size)
|
||||
|
||||
Map.merge(healthcheck, db_info)
|
||||
end
|
||||
|
||||
@spec check_health(Healthcheck.t()) :: Healthcheck.t()
|
||||
def check_health(%{pool_size: pool_size, active: active} = check)
|
||||
when active >= pool_size do
|
||||
%{check | healthy: false}
|
||||
end
|
||||
|
||||
def check_health(check), do: check
|
||||
end
|
@ -0,0 +1,51 @@
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.Database do
|
||||
alias Mix.Tasks.Pleroma.Common
|
||||
require Logger
|
||||
use Mix.Task
|
||||
|
||||
@shortdoc "A collection of database related tasks"
|
||||
@moduledoc """
|
||||
A collection of database related tasks
|
||||
|
||||
## Replace embedded objects with their references
|
||||
|
||||
Replaces embedded objects with references to them in the `objects` table. Only needs to be ran once. 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.
|
||||
|
||||
mix pleroma.database remove_embedded_objects
|
||||
|
||||
Options:
|
||||
- `--vacuum` - run `VACUUM FULL` after the embedded objects are replaced with their references
|
||||
"""
|
||||
def run(["remove_embedded_objects" | args]) do
|
||||
{options, [], []} =
|
||||
OptionParser.parse(
|
||||
args,
|
||||
strict: [
|
||||
vacuum: :boolean
|
||||
]
|
||||
)
|
||||
|
||||
Common.start_pleroma()
|
||||
Logger.info("Removing embedded objects")
|
||||
|
||||
Pleroma.Repo.query!(
|
||||
"update activities set data = jsonb_set(data, '{object}'::text[], data->'object'->'id') where data->'object'->>'id' is not null;",
|
||||
[],
|
||||
timeout: :infinity
|
||||
)
|
||||
|
||||
if Keyword.get(options, :vacuum) do
|
||||
Logger.info("Runnning VACUUM FULL")
|
||||
|
||||
Pleroma.Repo.query!(
|
||||
"vacuum full;",
|
||||
[],
|
||||
timeout: :infinity
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,293 @@
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.Emoji do
|
||||
use Mix.Task
|
||||
|
||||
@shortdoc "Manages emoji packs"
|
||||
@moduledoc """
|
||||
Manages emoji packs
|
||||
|
||||
## ls-packs
|
||||
|
||||
mix pleroma.emoji ls-packs [OPTION...]
|
||||
|
||||
Lists the emoji packs and metadata specified in the manifest.
|
||||
|
||||
### Options
|
||||
|
||||
- `-m, --manifest PATH/URL` - path to a custom manifest, it can
|
||||
either be an URL starting with `http`, in that case the
|
||||
manifest will be fetched from that address, or a local path
|
||||
|
||||
## get-packs
|
||||
|
||||
mix pleroma.emoji get-packs [OPTION...] PACKS
|
||||
|
||||
Fetches, verifies and installs the specified PACKS from the
|
||||
manifest into the `STATIC-DIR/emoji/PACK-NAME`
|
||||
|
||||
### Options
|
||||
|
||||
- `-m, --manifest PATH/URL` - same as ls-packs
|
||||
|
||||
## gen-pack
|
||||
|
||||
mix pleroma.emoji gen-pack PACK-URL
|
||||
|
||||
Creates a new manifest entry and a file list from the specified
|
||||
remote pack file. Currently, only .zip archives are recognized
|
||||
as remote pack files and packs are therefore assumed to be zip
|
||||
archives. This command is intended to run interactively and will
|
||||
first ask you some basic questions about the pack, then download
|
||||
the remote file and generate an SHA256 checksum for it, then
|
||||
generate an emoji file list for you.
|
||||
|
||||
The manifest entry will either be written to a newly created
|
||||
`index.json` file or appended to the existing one, *replacing*
|
||||
the old pack with the same name if it was in the file previously.
|
||||
|
||||
The file list will be written to the file specified previously,
|
||||
*replacing* that file. You _should_ check that the file list doesn't
|
||||
contain anything you don't need in the pack, that is, anything that is
|
||||
not an emoji (the whole pack is downloaded, but only emoji files
|
||||
are extracted).
|
||||
"""
|
||||
|
||||
@default_manifest Pleroma.Config.get!([:emoji, :default_manifest])
|
||||
|
||||
def run(["ls-packs" | args]) do
|
||||
Application.ensure_all_started(:hackney)
|
||||
|
||||
{options, [], []} = parse_global_opts(args)
|
||||
|
||||
manifest =
|
||||
fetch_manifest(if options[:manifest], do: options[:manifest], else: @default_manifest)
|
||||
|
||||
Enum.each(manifest, fn {name, info} ->
|
||||
to_print = [
|
||||
{"Name", name},
|
||||
{"Homepage", info["homepage"]},
|
||||
{"Description", info["description"]},
|
||||
{"License", info["license"]},
|
||||
{"Source", info["src"]}
|
||||
]
|
||||
|
||||
for {param, value} <- to_print do
|
||||
IO.puts(IO.ANSI.format([:bright, param, :normal, ": ", value]))
|
||||
end
|
||||
|
||||
# A newline
|
||||
IO.puts("")
|
||||
end)
|
||||
end
|
||||
|
||||
def run(["get-packs" | args]) do
|
||||
Application.ensure_all_started(:hackney)
|
||||
|
||||
{options, pack_names, []} = parse_global_opts(args)
|
||||
|
||||
manifest_url = if options[:manifest], do: options[:manifest], else: @default_manifest
|
||||
|
||||
manifest = fetch_manifest(manifest_url)
|
||||
|
||||
for pack_name <- pack_names do
|
||||
if Map.has_key?(manifest, pack_name) do
|
||||
pack = manifest[pack_name]
|
||||
src_url = pack["src"]
|
||||
|
||||
IO.puts(
|
||||
IO.ANSI.format([
|
||||
"Downloading ",
|
||||
:bright,
|
||||
pack_name,
|
||||
:normal,
|
||||
" from ",
|
||||
:underline,
|
||||
src_url
|
||||
])
|
||||
)
|
||||
|
||||
binary_archive = Tesla.get!(src_url).body
|
||||
archive_sha = :crypto.hash(:sha256, binary_archive) |> Base.encode16()
|
||||
|
||||
sha_status_text = ["SHA256 of ", :bright, pack_name, :normal, " source file is ", :bright]
|
||||
|
||||
if archive_sha == String.upcase(pack["src_sha256"]) do
|
||||
IO.puts(IO.ANSI.format(sha_status_text ++ [:green, "OK"]))
|
||||
else
|
||||
IO.puts(IO.ANSI.format(sha_status_text ++ [:red, "BAD"]))
|
||||
|
||||
raise "Bad SHA256 for #{pack_name}"
|
||||
end
|
||||
|
||||
# The url specified in files should be in the same directory
|
||||
files_url = Path.join(Path.dirname(manifest_url), pack["files"])
|
||||
|
||||
IO.puts(
|
||||
IO.ANSI.format([
|
||||
"Fetching the file list for ",
|
||||
:bright,
|
||||
pack_name,
|
||||
:normal,
|
||||
" from ",
|
||||
:underline,
|
||||
files_url
|
||||
])
|
||||
)
|
||||
|
||||
files = Tesla.get!(files_url).body |> Poison.decode!()
|
||||
|
||||
IO.puts(IO.ANSI.format(["Unpacking ", :bright, pack_name]))
|
||||
|
||||
pack_path =
|
||||
Path.join([
|
||||
Pleroma.Config.get!([:instance, :static_dir]),
|
||||
"emoji",
|
||||
pack_name
|
||||
])
|
||||
|
||||
files_to_unzip =
|
||||
Enum.map(
|
||||
files,
|
||||
fn {_, f} -> to_charlist(f) end
|
||||
)
|
||||
|
||||
{:ok, _} =
|
||||
:zip.unzip(binary_archive,
|
||||
cwd: pack_path,
|
||||
file_list: files_to_unzip
|
||||
)
|
||||
|
||||
IO.puts(IO.ANSI.format(["Writing emoji.txt for ", :bright, pack_name]))
|
||||
|
||||
emoji_txt_str =
|
||||
Enum.map(
|
||||
files,
|
||||
fn {shortcode, path} ->
|
||||
emojo_path = Path.join("/emoji/#{pack_name}", path)
|
||||
"#{shortcode}, #{emojo_path}"
|
||||
end
|
||||
)
|
||||
|> Enum.join("\n")
|
||||
|
||||
File.write!(Path.join(pack_path, "emoji.txt"), emoji_txt_str)
|
||||
else
|
||||
IO.puts(IO.ANSI.format([:bright, :red, "No pack named \"#{pack_name}\" found"]))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def run(["gen-pack", src]) do
|
||||
Application.ensure_all_started(:hackney)
|
||||
|
||||
proposed_name = Path.basename(src) |> Path.rootname()
|
||||
name = String.trim(IO.gets("Pack name [#{proposed_name}]: "))
|
||||
# If there's no name, use the default one
|
||||
name = if String.length(name) > 0, do: name, else: proposed_name
|
||||
|
||||
license = String.trim(IO.gets("License: "))
|
||||
homepage = String.trim(IO.gets("Homepage: "))
|
||||
description = String.trim(IO.gets("Description: "))
|
||||
|
||||
proposed_files_name = "#{name}.json"
|
||||
files_name = String.trim(IO.gets("Save file list to [#{proposed_files_name}]: "))
|
||||
files_name = if String.length(files_name) > 0, do: files_name, else: proposed_files_name
|
||||
|
||||
default_exts = [".png", ".gif"]
|
||||
default_exts_str = Enum.join(default_exts, " ")
|
||||
|
||||
exts =
|
||||
String.trim(
|
||||
IO.gets("Emoji file extensions (separated with spaces) [#{default_exts_str}]: ")
|
||||
)
|
||||
|
||||
exts =
|
||||
if String.length(exts) > 0 do
|
||||
String.split(exts, " ")
|
||||
|> Enum.filter(fn e -> e |> String.trim() |> String.length() > 0 end)
|
||||
else
|
||||
default_exts
|
||||
end
|
||||
|
||||
IO.puts("Downloading the pack and generating SHA256")
|
||||
|
||||
binary_archive = Tesla.get!(src).body
|
||||
archive_sha = :crypto.hash(:sha256, binary_archive) |> Base.encode16()
|
||||
|
||||
IO.puts("SHA256 is #{archive_sha}")
|
||||
|
||||
pack_json = %{
|
||||
name => %{
|
||||
license: license,
|
||||
homepage: homepage,
|
||||
description: description,
|
||||
src: src,
|
||||
src_sha256: archive_sha,
|
||||
files: files_name
|
||||
}
|
||||
}
|
||||
|
||||
tmp_pack_dir = Path.join(System.tmp_dir!(), "emoji-pack-#{name}")
|
||||
|
||||
{:ok, _} =
|
||||
:zip.unzip(
|
||||
binary_archive,
|
||||
cwd: tmp_pack_dir
|
||||
)
|
||||
|
||||
emoji_map = Pleroma.Emoji.make_shortcode_to_file_map(tmp_pack_dir, exts)
|
||||
|
||||
File.write!(files_name, Poison.encode!(emoji_map, pretty: true))
|
||||
|
||||
IO.puts("""
|
||||
|
||||
#{files_name} has been created and contains the list of all found emojis in the pack.
|
||||
Please review the files in the remove those not needed.
|
||||
""")
|
||||
|
||||
if File.exists?("index.json") do
|
||||
existing_data = File.read!("index.json") |> Poison.decode!()
|
||||
|
||||
File.write!(
|
||||
"index.json",
|
||||
Poison.encode!(
|
||||
Map.merge(
|
||||
existing_data,
|
||||
pack_json
|
||||
),
|
||||
pretty: true
|
||||
)
|
||||
)
|
||||
|
||||
IO.puts("index.json file has been update with the #{name} pack")
|
||||
else
|
||||
File.write!("index.json", Poison.encode!(pack_json, pretty: true))
|
||||
|
||||
IO.puts("index.json has been created with the #{name} pack")
|
||||
end
|
||||
end
|
||||
|
||||
defp fetch_manifest(from) do
|
||||
Poison.decode!(
|
||||
if String.starts_with?(from, "http") do
|
||||
Tesla.get!(from).body
|
||||
else
|
||||
File.read!(from)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
defp parse_global_opts(args) do
|
||||
OptionParser.parse(
|
||||
args,
|
||||
strict: [
|
||||
manifest: :string
|
||||
],
|
||||
aliases: [
|
||||
m: :manifest
|
||||
]
|
||||
)
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
User-Agent: *
|
||||
Disallow: <%= if indexable, do: "", else: "/" %>
|
@ -0,0 +1,32 @@
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.RobotsTxt do
|
||||
use Mix.Task
|
||||
|
||||
@shortdoc "Generate robots.txt"
|
||||
@moduledoc """
|
||||
Generates robots.txt
|
||||
|
||||
## Overwrite robots.txt to disallow all
|
||||
|
||||
mix pleroma.robots_txt disallow_all
|
||||
|
||||
This will write a robots.txt that will hide all paths on your instance
|
||||
from search engines and other robots that obey robots.txt
|
||||
|
||||
"""
|
||||
def run(["disallow_all"]) do
|
||||
static_dir = Pleroma.Config.get([:instance, :static_dir], "instance/static/")
|
||||
|
||||
if !File.exists?(static_dir) do
|
||||
File.mkdir_p!(static_dir)
|
||||
end
|
||||
|
||||
robots_txt_path = Path.join(static_dir, "robots.txt")
|
||||
robots_txt_content = "User-Agent: *\nDisallow: /\n"
|
||||
|
||||
File.write!(robots_txt_path, robots_txt_content, [:write])
|
||||
end
|
||||
end
|
@ -0,0 +1,60 @@
|
||||
defmodule Pleroma.Bookmark do
|
||||
use Ecto.Schema
|
||||
|
||||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Bookmark
|
||||
alias Pleroma.FlakeId
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
|
||||
@type t :: %__MODULE__{}
|
||||
|
||||
schema "bookmarks" do
|
||||
belongs_to(:user, User, type: FlakeId)
|
||||
belongs_to(:activity, Activity, type: FlakeId)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
@spec create(FlakeId.t(), FlakeId.t()) :: {:ok, Bookmark.t()} | {:error, Changeset.t()}
|
||||
def create(user_id, activity_id) do
|
||||
attrs = %{
|
||||
user_id: user_id,
|
||||
activity_id: activity_id
|
||||
}
|
||||
|
||||
%Bookmark{}
|
||||
|> cast(attrs, [:user_id, :activity_id])
|
||||
|> validate_required([:user_id, :activity_id])
|
||||
|> unique_constraint(:activity_id, name: :bookmarks_user_id_activity_id_index)
|
||||
|> Repo.insert()
|
||||
end
|
||||
|
||||
@spec for_user_query(FlakeId.t()) :: Ecto.Query.t()
|
||||
def for_user_query(user_id) do
|
||||
Bookmark
|
||||
|> where(user_id: ^user_id)
|
||||
|> join(:inner, [b], activity in assoc(b, :activity))
|
||||
|> preload([b, a], activity: a)
|
||||
end
|
||||
|
||||
def get(user_id, activity_id) do
|
||||
Bookmark
|
||||
|> where(user_id: ^user_id)
|
||||
|> where(activity_id: ^activity_id)
|
||||
|> Repo.one()
|
||||
end
|
||||
|
||||
@spec destroy(FlakeId.t(), FlakeId.t()) :: {:ok, Bookmark.t()} | {:error, Changeset.t()}
|
||||
def destroy(user_id, activity_id) do
|
||||
from(b in Bookmark,
|
||||
where: b.user_id == ^user_id,
|
||||
where: b.activity_id == ^activity_id
|
||||
)
|
||||
|> Repo.one()
|
||||
|> Repo.delete()
|
||||
end
|
||||
end
|
@ -1,152 +0,0 @@
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Jobs do
|
||||
@moduledoc """
|
||||
A basic job queue
|
||||
"""
|
||||
use GenServer
|
||||
|
||||
require Logger
|
||||
|
||||
def init(args) do
|
||||
{:ok, args}
|
||||
end
|
||||
|
||||
def start_link do
|
||||
queues =
|
||||
Pleroma.Config.get(Pleroma.Jobs)
|
||||
|> Enum.map(fn {name, _} -> create_queue(name) end)
|
||||
|> Enum.into(%{})
|
||||
|
||||
state = %{
|
||||
queues: queues,
|
||||
refs: %{}
|
||||
}
|
||||
|
||||
GenServer.start_link(__MODULE__, state, name: __MODULE__)
|
||||
end
|
||||
|
||||
def create_queue(name) do
|
||||
{name, {:sets.new(), []}}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Enqueues a job.
|
||||
|
||||
Returns `:ok`.
|
||||
|
||||
## Arguments
|
||||
|
||||
- `queue_name` - a queue name(must be specified in the config).
|
||||
- `mod` - a worker module (must have `perform` function).
|
||||
- `args` - a list of arguments for the `perform` function of the worker module.
|
||||
- `priority` - a job priority (`0` by default).
|
||||
|
||||
## Examples
|
||||
|
||||
Enqueue `Module.perform/0` with `priority=1`:
|
||||
|
||||
iex> Pleroma.Jobs.enqueue(:example_queue, Module, [])
|
||||
:ok
|
||||
|
||||
Enqueue `Module.perform(:job_name)` with `priority=5`:
|
||||
|
||||
iex> Pleroma.Jobs.enqueue(:example_queue, Module, [:job_name], 5)
|
||||
:ok
|
||||
|
||||
Enqueue `Module.perform(:another_job, data)` with `priority=1`:
|
||||
|
||||
iex> data = "foobar"
|
||||
iex> Pleroma.Jobs.enqueue(:example_queue, Module, [:another_job, data])
|
||||
:ok
|
||||
|
||||
Enqueue `Module.perform(:foobar_job, :foo, :bar, 42)` with `priority=1`:
|
||||
|
||||
iex> Pleroma.Jobs.enqueue(:example_queue, Module, [:foobar_job, :foo, :bar, 42])
|
||||
:ok
|
||||
|
||||
"""
|
||||
|
||||
def enqueue(queue_name, mod, args, priority \\ 1)
|
||||
|
||||
if Mix.env() == :test do
|
||||
def enqueue(_queue_name, mod, args, _priority) do
|
||||
apply(mod, :perform, args)
|
||||
end
|
||||
else
|
||||
@spec enqueue(atom(), atom(), [any()], integer()) :: :ok
|
||||
def enqueue(queue_name, mod, args, priority) do
|
||||
GenServer.cast(__MODULE__, {:enqueue, queue_name, mod, args, priority})
|
||||
end
|
||||
end
|
||||
|
||||
def handle_cast({:enqueue, queue_name, mod, args, priority}, state) do
|
||||
{running_jobs, queue} = state[:queues][queue_name]
|
||||
|
||||
queue = enqueue_sorted(queue, {mod, args}, priority)
|
||||
|
||||
state =
|
||||
state
|
||||
|> update_queue(queue_name, {running_jobs, queue})
|
||||
|> maybe_start_job(queue_name, running_jobs, queue)
|
||||
|
||||
{:noreply, state}
|
||||
end
|
||||
|
||||
def handle_info({:DOWN, ref, :process, _pid, _reason}, state) do
|
||||
queue_name = state.refs[ref]
|
||||
|
||||
{running_jobs, queue} = state[:queues][queue_name]
|
||||
|
||||
running_jobs = :sets.del_element(ref, running_jobs)
|
||||
|
||||
state =
|
||||
state
|
||||
|> remove_ref(ref)
|
||||
|> update_queue(queue_name, {running_jobs, queue})
|
||||
|> maybe_start_job(queue_name, running_jobs, queue)
|
||||
|
||||
{:noreply, state}
|
||||
end
|
||||
|
||||
def maybe_start_job(state, queue_name, running_jobs, queue) do
|
||||
if :sets.size(running_jobs) < Pleroma.Config.get([__MODULE__, queue_name, :max_jobs]) &&
|
||||
queue != [] do
|
||||
{{mod, args}, queue} = queue_pop(queue)
|
||||
{:ok, pid} = Task.start(fn -> apply(mod, :perform, args) end)
|
||||
mref = Process.monitor(pid)
|
||||
|
||||
state
|
||||
|> add_ref(queue_name, mref)
|
||||
|> update_queue(queue_name, {:sets.add_element(mref, running_jobs), queue})
|
||||
else
|
||||
state
|
||||
end
|
||||
end
|
||||
|
||||
def enqueue_sorted(queue, element, priority) do
|
||||
[%{item: element, priority: priority} | queue]
|
||||
|> Enum.sort_by(fn %{priority: priority} -> priority end)
|
||||
end
|
||||
|
||||
def queue_pop([%{item: element} | queue]) do
|
||||
{element, queue}
|
||||
end
|
||||
|
||||
defp add_ref(state, queue_name, ref) do
|
||||
refs = Map.put(state[:refs], ref, queue_name)
|
||||
Map.put(state, :refs, refs)
|
||||
end
|
||||
|
||||
defp remove_ref(state, ref) do
|
||||
refs = Map.delete(state[:refs], ref)
|
||||
Map.put(state, :refs, refs)
|
||||
end
|
||||
|
||||
defp update_queue(state, queue_name, data) do
|
||||
queues = Map.put(state[:queues], queue_name, data)
|
||||
Map.put(state, :queues, queues)
|
||||
end
|
||||
end
|
@ -0,0 +1,61 @@
|
||||
defmodule Pleroma.Object.Containment do
|
||||
@moduledoc """
|
||||
# Object Containment
|
||||
|
||||
This module contains some useful functions for containing objects to specific
|
||||
origins and determining those origins. They previously lived in the
|
||||
ActivityPub `Transmogrifier` module.
|
||||
|
||||
Object containment is an important step in validating remote objects to prevent
|
||||
spoofing, therefore removal of object containment functions is NOT recommended.
|
||||
"""
|
||||
def get_actor(%{"actor" => actor}) when is_binary(actor) do
|
||||
actor
|
||||
end
|
||||
|
||||
def get_actor(%{"actor" => actor}) when is_list(actor) do
|
||||
if is_binary(Enum.at(actor, 0)) do
|
||||
Enum.at(actor, 0)
|
||||
else
|
||||
Enum.find(actor, fn %{"type" => type} -> type in ["Person", "Service", "Application"] end)
|
||||
|> Map.get("id")
|
||||
end
|
||||
end
|
||||
|
||||
def get_actor(%{"actor" => %{"id" => id}}) when is_bitstring(id) do
|
||||
id
|
||||
end
|
||||
|
||||
def get_actor(%{"actor" => nil, "attributedTo" => actor}) when not is_nil(actor) do
|
||||
get_actor(%{"actor" => actor})
|
||||
end
|
||||
|
||||
@doc """
|
||||
Checks that an imported AP object's actor matches the domain it came from.
|
||||
"""
|
||||
def contain_origin(_id, %{"actor" => nil}), do: :error
|
||||
|
||||
def contain_origin(id, %{"actor" => _actor} = params) do
|
||||
id_uri = URI.parse(id)
|
||||
actor_uri = URI.parse(get_actor(params))
|
||||
|
||||
if id_uri.host == actor_uri.host do
|
||||
:ok
|
||||
else
|
||||
:error
|
||||
end
|
||||
end
|
||||
|
||||
def contain_origin_from_id(_id, %{"id" => nil}), do: :error
|
||||
|
||||
def contain_origin_from_id(id, %{"id" => other_id} = _params) do
|
||||
id_uri = URI.parse(id)
|
||||
other_uri = URI.parse(other_id)
|
||||
|
||||
if id_uri.host == other_uri.host do
|
||||
:ok
|
||||
else
|
||||
:error
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,75 @@
|
||||
defmodule Pleroma.Object.Fetcher do
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Object.Containment
|
||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||
alias Pleroma.Web.OStatus
|
||||
|
||||
require Logger
|
||||
|
||||
@httpoison Application.get_env(:pleroma, :httpoison)
|
||||
|
||||
# TODO:
|
||||
# This will create a Create activity, which we need internally at the moment.
|
||||
def fetch_object_from_id(id) do
|
||||
if object = Object.get_cached_by_ap_id(id) do
|
||||
{:ok, object}
|
||||
else
|
||||
Logger.info("Fetching #{id} via AP")
|
||||
|
||||
with {:ok, data} <- fetch_and_contain_remote_object_from_id(id),
|
||||
nil <- Object.normalize(data, false),
|
||||
params <- %{
|
||||
"type" => "Create",
|
||||
"to" => data["to"],
|
||||
"cc" => data["cc"],
|
||||
"actor" => data["actor"] || data["attributedTo"],
|
||||
"object" => data
|
||||
},
|
||||
:ok <- Containment.contain_origin(id, params),
|
||||
{:ok, activity} <- Transmogrifier.handle_incoming(params) do
|
||||
{:ok, Object.normalize(activity, false)}
|
||||
else
|
||||
{:error, {:reject, nil}} ->
|
||||
{:reject, nil}
|
||||
|
||||
object = %Object{} ->
|
||||
{:ok, object}
|
||||
|
||||
_e ->
|
||||
Logger.info("Couldn't get object via AP, trying out OStatus fetching...")
|
||||
|
||||
case OStatus.fetch_activity_from_url(id) do
|
||||
{:ok, [activity | _]} -> {:ok, Object.normalize(activity, false)}
|
||||
e -> e
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def fetch_object_from_id!(id) do
|
||||
with {:ok, object} <- fetch_object_from_id(id) do
|
||||
object
|
||||
else
|
||||
_e ->
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def fetch_and_contain_remote_object_from_id(id) do
|
||||
Logger.info("Fetching object #{id} via AP")
|
||||
|
||||
with true <- String.starts_with?(id, "http"),
|
||||
{:ok, %{body: body, status: code}} when code in 200..299 <-
|
||||
@httpoison.get(
|
||||
id,
|
||||
[{:Accept, "application/activity+json"}]
|
||||
),
|
||||
{:ok, data} <- Jason.decode(body),
|
||||
:ok <- Containment.contain_origin_from_id(id, data) do
|
||||
{:ok, data}
|
||||
else
|
||||
e ->
|
||||
{:error, e}
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,84 @@
|
||||
defmodule Pleroma.Pagination do
|
||||
@moduledoc """
|
||||
Implements Mastodon-compatible pagination.
|
||||
"""
|
||||
|
||||
import Ecto.Query
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Pleroma.Repo
|
||||
|
||||
@default_limit 20
|
||||
|
||||
def fetch_paginated(query, params) do
|
||||
options = cast_params(params)
|
||||
|
||||
query
|
||||
|> paginate(options)
|
||||
|> Repo.all()
|
||||
|> enforce_order(options)
|
||||
end
|
||||
|
||||
def paginate(query, options) do
|
||||
query
|
||||
|> restrict(:min_id, options)
|
||||
|> restrict(:since_id, options)
|
||||
|> restrict(:max_id, options)
|
||||
|> restrict(:order, options)
|
||||
|> restrict(:limit, options)
|
||||
end
|
||||
|
||||
defp cast_params(params) do
|
||||
param_types = %{
|
||||
min_id: :string,
|
||||
since_id: :string,
|
||||
max_id: :string,
|
||||
limit: :integer
|
||||
}
|
||||
|
||||
params =
|
||||
Enum.reduce(params, %{}, fn
|
||||
{key, _value}, acc when is_atom(key) -> Map.drop(acc, [key])
|
||||
{key, value}, acc -> Map.put(acc, key, value)
|
||||
end)
|
||||
|
||||
changeset = cast({%{}, param_types}, params, Map.keys(param_types))
|
||||
changeset.changes
|
||||
end
|
||||
|
||||
defp restrict(query, :min_id, %{min_id: min_id}) do
|
||||
where(query, [q], q.id > ^min_id)
|
||||
end
|
||||
|
||||
defp restrict(query, :since_id, %{since_id: since_id}) do
|
||||
where(query, [q], q.id > ^since_id)
|
||||
end
|
||||
|
||||
defp restrict(query, :max_id, %{max_id: max_id}) do
|
||||
where(query, [q], q.id < ^max_id)
|
||||
end
|
||||
|
||||
defp restrict(query, :order, %{min_id: _}) do
|
||||
order_by(query, [u], fragment("? asc nulls last", u.id))
|
||||
end
|
||||
|
||||
defp restrict(query, :order, _options) do
|
||||
order_by(query, [u], fragment("? desc nulls last", u.id))
|
||||
end
|
||||
|
||||
defp restrict(query, :limit, options) do
|
||||
limit = Map.get(options, :limit, @default_limit)
|
||||
|
||||
query
|
||||
|> limit(^limit)
|
||||
end
|
||||
|
||||
defp restrict(query, _, _), do: query
|
||||
|
||||
defp enforce_order(result, %{min_id: _}) do
|
||||
result
|
||||
|> Enum.reverse()
|
||||
end
|
||||
|
||||
defp enforce_order(result, _), do: result
|
||||
end
|
@ -0,0 +1,57 @@
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Registration do
|
||||
use Ecto.Schema
|
||||
|
||||
import Ecto.Changeset
|
||||
|
||||
alias Pleroma.Registration
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
|
||||
@primary_key {:id, Pleroma.FlakeId, autogenerate: true}
|
||||
|
||||
schema "registrations" do
|
||||
belongs_to(:user, User, type: Pleroma.FlakeId)
|
||||
field(:provider, :string)
|
||||
field(:uid, :string)
|
||||
field(:info, :map, default: %{})
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
def nickname(registration, default \\ nil),
|
||||
do: Map.get(registration.info, "nickname", default)
|
||||
|
||||
def email(registration, default \\ nil),
|
||||
do: Map.get(registration.info, "email", default)
|
||||
|
||||
def name(registration, default \\ nil),
|
||||
do: Map.get(registration.info, "name", default)
|
||||
|
||||
def description(registration, default \\ nil),
|
||||
do: Map.get(registration.info, "description", default)
|
||||
|
||||
def changeset(registration, params \\ %{}) do
|
||||
registration
|
||||
|> cast(params, [:user_id, :provider, :uid, :info])
|
||||
|> validate_required([:provider, :uid])
|
||||
|> foreign_key_constraint(:user_id)
|
||||
|> unique_constraint(:uid, name: :registrations_provider_uid_index)
|
||||
end
|
||||
|
||||
def bind_to_user(registration, user) do
|
||||
registration
|
||||
|> changeset(%{user_id: (user && user.id) || nil})
|
||||
|> Repo.update()
|
||||
end
|
||||
|
||||
def get_by_provider_uid(provider, uid) do
|
||||
Repo.get_by(Registration,
|
||||
provider: to_string(provider),
|
||||
uid: to_string(uid)
|
||||
)
|
||||
end
|
||||
end
|
@ -0,0 +1,161 @@
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.ScheduledActivity do
|
||||
use Ecto.Schema
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.ScheduledActivity
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI.Utils
|
||||
|
||||
import Ecto.Query
|
||||
import Ecto.Changeset
|
||||
|
||||
@min_offset :timer.minutes(5)
|
||||
|
||||
schema "scheduled_activities" do
|
||||
belongs_to(:user, User, type: Pleroma.FlakeId)
|
||||
field(:scheduled_at, :naive_datetime)
|
||||
field(:params, :map)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
def changeset(%ScheduledActivity{} = scheduled_activity, attrs) do
|
||||
scheduled_activity
|
||||
|> cast(attrs, [:scheduled_at, :params])
|
||||
|> validate_required([:scheduled_at, :params])
|
||||
|> validate_scheduled_at()
|
||||
|> with_media_attachments()
|
||||
end
|
||||
|
||||
defp with_media_attachments(
|
||||
%{changes: %{params: %{"media_ids" => media_ids} = params}} = changeset
|
||||
)
|
||||
when is_list(media_ids) do
|
||||
media_attachments = Utils.attachments_from_ids(%{"media_ids" => media_ids})
|
||||
|
||||
params =
|
||||
params
|
||||
|> Map.put("media_attachments", media_attachments)
|
||||
|> Map.put("media_ids", media_ids)
|
||||
|
||||
put_change(changeset, :params, params)
|
||||
end
|
||||
|
||||
defp with_media_attachments(changeset), do: changeset
|
||||
|
||||
def update_changeset(%ScheduledActivity{} = scheduled_activity, attrs) do
|
||||
scheduled_activity
|
||||
|> cast(attrs, [:scheduled_at])
|
||||
|> validate_required([:scheduled_at])
|
||||
|> validate_scheduled_at()
|
||||
end
|
||||
|
||||
def validate_scheduled_at(changeset) do
|
||||
validate_change(changeset, :scheduled_at, fn _, scheduled_at ->
|
||||
cond do
|
||||
not far_enough?(scheduled_at) ->
|
||||
[scheduled_at: "must be at least 5 minutes from now"]
|
||||
|
||||
exceeds_daily_user_limit?(changeset.data.user_id, scheduled_at) ->
|
||||
[scheduled_at: "daily limit exceeded"]
|
||||
|
||||
exceeds_total_user_limit?(changeset.data.user_id) ->
|
||||
[scheduled_at: "total limit exceeded"]
|
||||
|
||||
true ->
|
||||
[]
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
def exceeds_daily_user_limit?(user_id, scheduled_at) do
|
||||
ScheduledActivity
|
||||
|> where(user_id: ^user_id)
|
||||
|> where([sa], type(sa.scheduled_at, :date) == type(^scheduled_at, :date))
|
||||
|> select([sa], count(sa.id))
|
||||
|> Repo.one()
|
||||
|> Kernel.>=(Config.get([ScheduledActivity, :daily_user_limit]))
|
||||
end
|
||||
|
||||
def exceeds_total_user_limit?(user_id) do
|
||||
ScheduledActivity
|
||||
|> where(user_id: ^user_id)
|
||||
|> select([sa], count(sa.id))
|
||||
|> Repo.one()
|
||||
|> Kernel.>=(Config.get([ScheduledActivity, :total_user_limit]))
|
||||
end
|
||||
|
||||
def far_enough?(scheduled_at) when is_binary(scheduled_at) do
|
||||
with {:ok, scheduled_at} <- Ecto.Type.cast(:naive_datetime, scheduled_at) do
|
||||
far_enough?(scheduled_at)
|
||||
else
|
||||
_ -> false
|
||||
end
|
||||
end
|
||||
|
||||
def far_enough?(scheduled_at) do
|
||||
now = NaiveDateTime.utc_now()
|
||||
diff = NaiveDateTime.diff(scheduled_at, now, :millisecond)
|
||||
diff > @min_offset
|
||||
end
|
||||
|
||||
def new(%User{} = user, attrs) do
|
||||
%ScheduledActivity{user_id: user.id}
|
||||
|> changeset(attrs)
|
||||
end
|
||||
|
||||
def create(%User{} = user, attrs) do
|
||||
user
|
||||
|> new(attrs)
|
||||
|> Repo.insert()
|
||||
end
|
||||
|
||||
def get(%User{} = user, scheduled_activity_id) do
|
||||
ScheduledActivity
|
||||
|> where(user_id: ^user.id)
|
||||
|> where(id: ^scheduled_activity_id)
|
||||
|> Repo.one()
|
||||
end
|
||||
|
||||
def update(%ScheduledActivity{} = scheduled_activity, attrs) do
|
||||
scheduled_activity
|
||||
|> update_changeset(attrs)
|
||||
|> Repo.update()
|
||||
end
|
||||
|
||||
def delete(%ScheduledActivity{} = scheduled_activity) do
|
||||
scheduled_activity
|
||||
|> Repo.delete()
|
||||
end
|
||||
|
||||
def delete(id) when is_binary(id) or is_integer(id) do
|
||||
ScheduledActivity
|
||||
|> where(id: ^id)
|
||||
|> select([sa], sa)
|
||||
|> Repo.delete_all()
|
||||
|> case do
|
||||
{1, [scheduled_activity]} -> {:ok, scheduled_activity}
|
||||
_ -> :error
|
||||
end
|
||||
end
|
||||
|
||||
def for_user_query(%User{} = user) do
|
||||
ScheduledActivity
|
||||
|> where(user_id: ^user.id)
|
||||
end
|
||||
|
||||
def due_activities(offset \\ 0) do
|
||||
naive_datetime =
|
||||
NaiveDateTime.utc_now()
|
||||
|> NaiveDateTime.add(offset, :millisecond)
|
||||
|
||||
ScheduledActivity
|
||||
|> where([sa], sa.scheduled_at < ^naive_datetime)
|
||||
|> Repo.all()
|
||||
end
|
||||
end
|
@ -0,0 +1,58 @@
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.ScheduledActivityWorker do
|
||||
@moduledoc """
|
||||
Sends scheduled activities to the job queue.
|
||||
"""
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.ScheduledActivity
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.CommonAPI
|
||||
use GenServer
|
||||
require Logger
|
||||
|
||||
@schedule_interval :timer.minutes(1)
|
||||
|
||||
def start_link do
|
||||
GenServer.start_link(__MODULE__, nil)
|
||||
end
|
||||
|
||||
def init(_) do
|
||||
if Config.get([ScheduledActivity, :enabled]) do
|
||||
schedule_next()
|
||||
{:ok, nil}
|
||||
else
|
||||
:ignore
|
||||
end
|
||||
end
|
||||
|
||||
def perform(:execute, scheduled_activity_id) do
|
||||
try do
|
||||
{:ok, scheduled_activity} = ScheduledActivity.delete(scheduled_activity_id)
|
||||
%User{} = user = User.get_cached_by_id(scheduled_activity.user_id)
|
||||
{:ok, _result} = CommonAPI.post(user, scheduled_activity.params)
|
||||
rescue
|
||||
error ->
|
||||
Logger.error(
|
||||
"#{__MODULE__} Couldn't create a status from the scheduled activity: #{inspect(error)}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
def handle_info(:perform, state) do
|
||||
ScheduledActivity.due_activities(@schedule_interval)
|
||||
|> Enum.each(fn scheduled_activity ->
|
||||
PleromaJobQueue.enqueue(:scheduled_activities, __MODULE__, [:execute, scheduled_activity.id])
|
||||
end)
|
||||
|
||||
schedule_next()
|
||||
{:noreply, state}
|
||||
end
|
||||
|
||||
defp schedule_next do
|
||||
Process.send_after(self(), :perform, @schedule_interval)
|
||||
end
|
||||
end
|
@ -0,0 +1,54 @@
|
||||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.AdminAPI.Search do
|
||||
import Ecto.Query
|
||||
|
||||
alias Pleroma.Repo
|
||||
alias Pleroma.User
|
||||
|
||||
@page_size 50
|
||||
|
||||
def user(%{query: term} = params) when is_nil(term) or term == "" do
|
||||
query = maybe_filtered_query(params)
|
||||
|
||||
paginated_query =
|
||||
maybe_filtered_query(params)
|
||||
|> paginate(params[:page] || 1, params[:page_size] || @page_size)
|
||||
|
||||
count = query |> Repo.aggregate(:count, :id)
|
||||
|
||||
results = Repo.all(paginated_query)
|
||||
|
||||
{:ok, results, count}
|
||||
end
|
||||
|
||||
def user(%{query: term} = params) when is_binary(term) do
|
||||
search_query = from(u in maybe_filtered_query(params), where: ilike(u.nickname, ^"%#{term}%"))
|
||||
|
||||
count = search_query |> Repo.aggregate(:count, :id)
|
||||
|
||||
results =
|
||||
search_query
|
||||
|> paginate(params[:page] || 1, params[:page_size] || @page_size)
|
||||
|> Repo.all()
|
||||
|
||||
{:ok, results, count}
|
||||
end
|
||||
|
||||
defp maybe_filtered_query(params) do
|
||||
from(u in User, order_by: u.nickname)
|
||||
|> User.maybe_local_user_query(params[:local])
|
||||
|> User.maybe_external_user_query(params[:external])
|
||||
|> User.maybe_active_user_query(params[:active])
|
||||
|> User.maybe_deactivated_user_query(params[:deactivated])
|
||||
end
|
||||
|
||||
defp paginate(query, page, page_size) do
|
||||
from(u in query,
|
||||
limit: ^page_size,
|
||||
offset: ^((page - 1) * page_size)
|
||||
)
|
||||
end
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue