Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into alexgleason/pleroma-restrict-domain
This commit is contained in:
commit
329aa19c9f
177 changed files with 4028 additions and 2257 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -27,6 +27,8 @@ erl_crash.dump
|
||||||
# variables.
|
# variables.
|
||||||
/config/*.secret.exs
|
/config/*.secret.exs
|
||||||
/config/generated_config.exs
|
/config/generated_config.exs
|
||||||
|
/config/*.env
|
||||||
|
|
||||||
|
|
||||||
# Database setup file, some may forget to delete it
|
# Database setup file, some may forget to delete it
|
||||||
/config/setup_db.psql
|
/config/setup_db.psql
|
||||||
|
|
|
@ -25,6 +25,8 @@ before_script:
|
||||||
- apt-get update && apt-get install -y cmake
|
- apt-get update && apt-get install -y cmake
|
||||||
- mix local.hex --force
|
- mix local.hex --force
|
||||||
- mix local.rebar --force
|
- mix local.rebar --force
|
||||||
|
- apt-get -qq update
|
||||||
|
- apt-get install -y libmagic-dev
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
@ -196,7 +198,7 @@ amd64:
|
||||||
variables: &release-variables
|
variables: &release-variables
|
||||||
MIX_ENV: prod
|
MIX_ENV: prod
|
||||||
before_script: &before-release
|
before_script: &before-release
|
||||||
- apt-get update && apt-get install -y cmake
|
- apt-get update && apt-get install -y cmake libmagic-dev
|
||||||
- echo "import Mix.Config" > config/prod.secret.exs
|
- echo "import Mix.Config" > config/prod.secret.exs
|
||||||
- mix local.hex --force
|
- mix local.hex --force
|
||||||
- mix local.rebar --force
|
- mix local.rebar --force
|
||||||
|
@ -215,7 +217,7 @@ amd64-musl:
|
||||||
cache: *release-cache
|
cache: *release-cache
|
||||||
variables: *release-variables
|
variables: *release-variables
|
||||||
before_script: &before-release-musl
|
before_script: &before-release-musl
|
||||||
- apk add git gcc g++ musl-dev make cmake
|
- apk add git gcc g++ musl-dev make cmake file-dev
|
||||||
- echo "import Mix.Config" > config/prod.secret.exs
|
- echo "import Mix.Config" > config/prod.secret.exs
|
||||||
- mix local.hex --force
|
- mix local.hex --force
|
||||||
- mix local.rebar --force
|
- mix local.rebar --force
|
||||||
|
|
22
CHANGELOG.md
22
CHANGELOG.md
|
@ -9,12 +9,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Mix tasks for controlling user account confirmation status in bulk (`mix pleroma.user confirm_all` and `mix pleroma.user unconfirm_all`)
|
- Mix tasks for controlling user account confirmation status in bulk (`mix pleroma.user confirm_all` and `mix pleroma.user unconfirm_all`)
|
||||||
- Mix task for sending confirmation emails to all unconfirmed users (`mix pleroma.email send_confirmation_mails`)
|
- Mix task for sending confirmation emails to all unconfirmed users (`mix pleroma.email send_confirmation_mails`)
|
||||||
- Mix task option for force-unfollowing relays
|
- Mix task option for force-unfollowing relays
|
||||||
|
- Media preview proxy (requires `ffmpeg` and `ImageMagick` to be installed and media proxy to be enabled; see `:media_preview_proxy` config for more details).
|
||||||
|
- Pleroma API: Importing the mutes users from CSV files.
|
||||||
|
- Experimental websocket-based federation between Pleroma instances.
|
||||||
|
- Support pagination of blocks and mutes
|
||||||
|
- App metrics: ability to restrict access to specified IP whitelist.
|
||||||
|
- Account backup
|
||||||
|
- Configuration: Add `:instance, autofollowing_nicknames` setting to provide a way to make accounts automatically follow new users that register on the local Pleroma instance.
|
||||||
- Ability to view remote timelines, with ex. `/api/v1/timelines/public?instance=lain.com` and streams `public:remote` and `public:remote:media`
|
- Ability to view remote timelines, with ex. `/api/v1/timelines/public?instance=lain.com` and streams `public:remote` and `public:remote:media`
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- **Breaking** Requires `libmagic` (or `file`) to guess file types.
|
||||||
- **Breaking:** Pleroma Admin API: emoji packs and files routes changed.
|
- **Breaking:** Pleroma Admin API: emoji packs and files routes changed.
|
||||||
- **Breaking:** Sensitive/NSFW statuses no longer disable link previews.
|
- **Breaking:** Sensitive/NSFW statuses no longer disable link previews.
|
||||||
|
- **Breaking:** App metrics endpoint (`/api/pleroma/app_metrics`) is disabled by default, check `docs/API/prometheus.md` on enabling and configuring.
|
||||||
- Search: Users are now findable by their urls.
|
- Search: Users are now findable by their urls.
|
||||||
- Renamed `:await_up_timeout` in `:connections_pool` namespace to `:connect_timeout`, old name is deprecated.
|
- Renamed `:await_up_timeout` in `:connections_pool` namespace to `:connect_timeout`, old name is deprecated.
|
||||||
- Renamed `:timeout` in `pools` namespace to `:recv_timeout`, old name is deprecated.
|
- Renamed `:timeout` in `pools` namespace to `:recv_timeout`, old name is deprecated.
|
||||||
|
@ -23,17 +32,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Minimum lifetime for ephmeral activities changed to 10 minutes and made configurable (`:min_lifetime` option).
|
- Minimum lifetime for ephmeral activities changed to 10 minutes and made configurable (`:min_lifetime` option).
|
||||||
- Introduced optional dependencies on `ffmpeg`, `ImageMagick`, `exiftool` software packages. Please refer to `docs/installation/optional/media_graphics_packages.md`.
|
- Introduced optional dependencies on `ffmpeg`, `ImageMagick`, `exiftool` software packages. Please refer to `docs/installation/optional/media_graphics_packages.md`.
|
||||||
|
|
||||||
### Added
|
|
||||||
- Media preview proxy (requires `ffmpeg` and `ImageMagick` to be installed and media proxy to be enabled; see `:media_preview_proxy` config for more details).
|
|
||||||
- Pleroma API: Importing the mutes users from CSV files.
|
|
||||||
- Experimental websocket-based federation between Pleroma instances.
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>API Changes</summary>
|
<summary>API Changes</summary>
|
||||||
|
|
||||||
- Pleroma API: Importing the mutes users from CSV files.
|
- Pleroma API: Importing the mutes users from CSV files.
|
||||||
- Admin API: Importing emoji from a zip file
|
- Admin API: Importing emoji from a zip file
|
||||||
- Pleroma API: Pagination for remote/local packs and emoji.
|
- Pleroma API: Pagination for remote/local packs and emoji.
|
||||||
|
- Admin API: (`GET /api/pleroma/admin/users`) added filters user by `unconfirmed` status
|
||||||
|
- Admin API: (`GET /api/pleroma/admin/users`) added filters user by `actor_type`
|
||||||
|
- Pleroma API: Add `idempotency_key` to the chat message entity that can be used for optimistic message sending.
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
@ -49,6 +56,11 @@ switched to a new configuration mechanism, however it was not officially removed
|
||||||
|
|
||||||
- Add documented-but-missing chat pagination.
|
- Add documented-but-missing chat pagination.
|
||||||
- Allow sending out emails again.
|
- Allow sending out emails again.
|
||||||
|
- Allow sending chat messages to yourself.
|
||||||
|
- Fix remote users with a whitespace name.
|
||||||
|
- OStatus / static FE endpoints: fixed inaccessibility for anonymous users on non-federating instances, switched to handling per `:restrict_unauthenticated` setting.
|
||||||
|
- Mastodon API: Current user is now included in conversation if it's the only participant
|
||||||
|
- Mastodon API: Fixed last_status.account being not filled with account data
|
||||||
|
|
||||||
## Unreleased (Patch)
|
## Unreleased (Patch)
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,6 @@ websocket_config = [
|
||||||
|
|
||||||
# Configures the endpoint
|
# Configures the endpoint
|
||||||
config :pleroma, Pleroma.Web.Endpoint,
|
config :pleroma, Pleroma.Web.Endpoint,
|
||||||
instrumenters: [Pleroma.Web.Endpoint.Instrumenter],
|
|
||||||
url: [host: "localhost"],
|
url: [host: "localhost"],
|
||||||
http: [
|
http: [
|
||||||
ip: {127, 0, 0, 1},
|
ip: {127, 0, 0, 1},
|
||||||
|
@ -143,7 +142,7 @@ config :pleroma, Pleroma.Web.Endpoint,
|
||||||
secret_key_base: "aK4Abxf29xU9TTDKre9coZPUgevcVCFQJe/5xP/7Lt4BEif6idBIbjupVbOrbKxl",
|
secret_key_base: "aK4Abxf29xU9TTDKre9coZPUgevcVCFQJe/5xP/7Lt4BEif6idBIbjupVbOrbKxl",
|
||||||
signing_salt: "CqaoopA2",
|
signing_salt: "CqaoopA2",
|
||||||
render_errors: [view: Pleroma.Web.ErrorView, accepts: ~w(json)],
|
render_errors: [view: Pleroma.Web.ErrorView, accepts: ~w(json)],
|
||||||
pubsub: [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2],
|
pubsub_server: Pleroma.PubSub,
|
||||||
secure_cookie_flag: true,
|
secure_cookie_flag: true,
|
||||||
extra_cookie_attrs: [
|
extra_cookie_attrs: [
|
||||||
"SameSite=Lax"
|
"SameSite=Lax"
|
||||||
|
@ -235,6 +234,7 @@ config :pleroma, :instance,
|
||||||
"text/bbcode"
|
"text/bbcode"
|
||||||
],
|
],
|
||||||
autofollowed_nicknames: [],
|
autofollowed_nicknames: [],
|
||||||
|
autofollowing_nicknames: [],
|
||||||
max_pinned_statuses: 1,
|
max_pinned_statuses: 1,
|
||||||
attachment_links: false,
|
attachment_links: false,
|
||||||
max_report_comment_size: 1000,
|
max_report_comment_size: 1000,
|
||||||
|
@ -551,6 +551,7 @@ config :pleroma, Oban,
|
||||||
queues: [
|
queues: [
|
||||||
activity_expiration: 10,
|
activity_expiration: 10,
|
||||||
token_expiration: 5,
|
token_expiration: 5,
|
||||||
|
backup: 1,
|
||||||
federator_incoming: 50,
|
federator_incoming: 50,
|
||||||
federator_outgoing: 50,
|
federator_outgoing: 50,
|
||||||
ingestion_queue: 50,
|
ingestion_queue: 50,
|
||||||
|
@ -636,7 +637,12 @@ config :pleroma, Pleroma.Emails.UserEmail,
|
||||||
|
|
||||||
config :pleroma, Pleroma.Emails.NewUsersDigestEmail, enabled: false
|
config :pleroma, Pleroma.Emails.NewUsersDigestEmail, enabled: false
|
||||||
|
|
||||||
config :prometheus, Pleroma.Web.Endpoint.MetricsExporter, path: "/api/pleroma/app_metrics"
|
config :prometheus, Pleroma.Web.Endpoint.MetricsExporter,
|
||||||
|
enabled: false,
|
||||||
|
auth: false,
|
||||||
|
ip_whitelist: [],
|
||||||
|
path: "/api/pleroma/app_metrics",
|
||||||
|
format: :text
|
||||||
|
|
||||||
config :pleroma, Pleroma.ScheduledActivity,
|
config :pleroma, Pleroma.ScheduledActivity,
|
||||||
daily_user_limit: 25,
|
daily_user_limit: 25,
|
||||||
|
@ -802,6 +808,8 @@ config :pleroma, :hackney_pools,
|
||||||
timeout: 300_000
|
timeout: 300_000
|
||||||
]
|
]
|
||||||
|
|
||||||
|
config :pleroma, :majic_pool, size: 2
|
||||||
|
|
||||||
private_instance? = :if_instance_is_private
|
private_instance? = :if_instance_is_private
|
||||||
|
|
||||||
config :pleroma, :restrict_unauthenticated,
|
config :pleroma, :restrict_unauthenticated,
|
||||||
|
@ -828,6 +836,11 @@ config :floki, :html_parser, Floki.HTMLParser.FastHtml
|
||||||
|
|
||||||
config :pleroma, Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.PleromaAuthenticator
|
config :pleroma, Pleroma.Web.Auth.Authenticator, Pleroma.Web.Auth.PleromaAuthenticator
|
||||||
|
|
||||||
|
config :pleroma, Pleroma.User.Backup,
|
||||||
|
purge_after_days: 30,
|
||||||
|
limit_days: 7,
|
||||||
|
dir: nil
|
||||||
|
|
||||||
# Import environment specific config. This must remain at the bottom
|
# Import environment specific config. This must remain at the bottom
|
||||||
# of this file so it overrides the configuration defined above.
|
# of this file so it overrides the configuration defined above.
|
||||||
import_config "#{Mix.env()}.exs"
|
import_config "#{Mix.env()}.exs"
|
||||||
|
|
|
@ -829,13 +829,13 @@ config :pleroma, :config_description, [
|
||||||
key: :autofollowed_nicknames,
|
key: :autofollowed_nicknames,
|
||||||
type: {:list, :string},
|
type: {:list, :string},
|
||||||
description:
|
description:
|
||||||
"Set to nicknames of (local) users that every new user should automatically follow",
|
"Set to nicknames of (local) users that every new user should automatically follow"
|
||||||
suggestions: [
|
},
|
||||||
"lain",
|
%{
|
||||||
"kaniini",
|
key: :autofollowing_nicknames,
|
||||||
"lanodan",
|
type: {:list, :string},
|
||||||
"rinpatch"
|
description:
|
||||||
]
|
"Set to nicknames of (local) users that automatically follows every newly registered user"
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :attachment_links,
|
key: :attachment_links,
|
||||||
|
@ -1757,28 +1757,37 @@ config :pleroma, :config_description, [
|
||||||
related_policy: "Pleroma.Web.ActivityPub.MRF.KeywordPolicy",
|
related_policy: "Pleroma.Web.ActivityPub.MRF.KeywordPolicy",
|
||||||
label: "MRF Keyword",
|
label: "MRF Keyword",
|
||||||
type: :group,
|
type: :group,
|
||||||
description: "Reject or Word-Replace messages with a keyword or regex",
|
description:
|
||||||
|
"Reject or Word-Replace messages matching a keyword or [Regex](https://hexdocs.pm/elixir/Regex.html).",
|
||||||
children: [
|
children: [
|
||||||
%{
|
%{
|
||||||
key: :reject,
|
key: :reject,
|
||||||
type: {:list, :string},
|
type: {:list, :string},
|
||||||
description:
|
description: """
|
||||||
"A list of patterns which result in message being rejected. Each pattern can be a string or a regular expression.",
|
A list of patterns which result in message being rejected.
|
||||||
|
|
||||||
|
Each pattern can be a string or [Regex](https://hexdocs.pm/elixir/Regex.html) in the format of `~r/PATTERN/`.
|
||||||
|
""",
|
||||||
suggestions: ["foo", ~r/foo/iu]
|
suggestions: ["foo", ~r/foo/iu]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :federated_timeline_removal,
|
key: :federated_timeline_removal,
|
||||||
type: {:list, :string},
|
type: {:list, :string},
|
||||||
description:
|
description: """
|
||||||
"A list of patterns which result in message being removed from federated timelines (a.k.a unlisted). Each pattern can be a string or a regular expression.",
|
A list of patterns which result in message being removed from federated timelines (a.k.a unlisted).
|
||||||
|
|
||||||
|
Each pattern can be a string or [Regex](https://hexdocs.pm/elixir/Regex.html) in the format of `~r/PATTERN/`.
|
||||||
|
""",
|
||||||
suggestions: ["foo", ~r/foo/iu]
|
suggestions: ["foo", ~r/foo/iu]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :replace,
|
key: :replace,
|
||||||
type: {:list, :tuple},
|
type: {:list, :tuple},
|
||||||
description:
|
description: """
|
||||||
"A list of tuples containing {pattern, replacement}. Each pattern can be a string or a regular expression.",
|
**Pattern**: a string or [Regex](https://hexdocs.pm/elixir/Regex.html) in the format of `~r/PATTERN/`.
|
||||||
suggestions: [{"foo", "bar"}, {~r/foo/iu, "bar"}]
|
|
||||||
|
**Replacement**: a string. Leaving the field empty is permitted.
|
||||||
|
"""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -2288,6 +2297,12 @@ config :pleroma, :config_description, [
|
||||||
description: "Activity expiration queue",
|
description: "Activity expiration queue",
|
||||||
suggestions: [10]
|
suggestions: [10]
|
||||||
},
|
},
|
||||||
|
%{
|
||||||
|
key: :backup,
|
||||||
|
type: :integer,
|
||||||
|
description: "Backup queue",
|
||||||
|
suggestions: [1]
|
||||||
|
},
|
||||||
%{
|
%{
|
||||||
key: :attachments_cleanup,
|
key: :attachments_cleanup,
|
||||||
type: :integer,
|
type: :integer,
|
||||||
|
@ -3708,5 +3723,76 @@ config :pleroma, :config_description, [
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
group: :pleroma,
|
||||||
|
key: :majic_pool,
|
||||||
|
type: :group,
|
||||||
|
description: "Majic/libmagic configuration",
|
||||||
|
children: [
|
||||||
|
%{
|
||||||
|
key: :size,
|
||||||
|
type: :integer,
|
||||||
|
description: "Number of majic workers to start.",
|
||||||
|
suggestions: [2]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
group: :pleroma,
|
||||||
|
key: Pleroma.User.Backup,
|
||||||
|
type: :group,
|
||||||
|
description: "Account Backup",
|
||||||
|
children: [
|
||||||
|
%{
|
||||||
|
key: :purge_after_days,
|
||||||
|
type: :integer,
|
||||||
|
description: "Remove backup achives after N days",
|
||||||
|
suggestions: [30]
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
key: :limit_days,
|
||||||
|
type: :integer,
|
||||||
|
description: "Limit user to export not more often than once per N days",
|
||||||
|
suggestions: [7]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
group: :prometheus,
|
||||||
|
key: Pleroma.Web.Endpoint.MetricsExporter,
|
||||||
|
type: :group,
|
||||||
|
description: "Prometheus app metrics endpoint configuration",
|
||||||
|
children: [
|
||||||
|
%{
|
||||||
|
key: :enabled,
|
||||||
|
type: :boolean,
|
||||||
|
description: "[Pleroma extension] Enables app metrics endpoint."
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
key: :ip_whitelist,
|
||||||
|
type: [{:list, :string}, {:list, :charlist}, {:list, :tuple}],
|
||||||
|
description:
|
||||||
|
"[Pleroma extension] If non-empty, restricts access to app metrics endpoint to specified IP addresses."
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
key: :auth,
|
||||||
|
type: [:boolean, :tuple],
|
||||||
|
description: "Enables HTTP Basic Auth for app metrics endpoint.",
|
||||||
|
suggestion: [false, {:basic, "myusername", "mypassword"}]
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
key: :path,
|
||||||
|
type: :string,
|
||||||
|
description: "App metrics endpoint URI path.",
|
||||||
|
suggestions: ["/api/pleroma/app_metrics"]
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
key: :format,
|
||||||
|
type: :atom,
|
||||||
|
description: "App metrics endpoint output format.",
|
||||||
|
suggestions: [:text, :protobuf]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -20,12 +20,14 @@ Configuration options:
|
||||||
- `external`: only external users
|
- `external`: only external users
|
||||||
- `active`: only active users
|
- `active`: only active users
|
||||||
- `need_approval`: only unapproved users
|
- `need_approval`: only unapproved users
|
||||||
|
- `unconfirmed`: only unconfirmed users
|
||||||
- `deactivated`: only deactivated users
|
- `deactivated`: only deactivated users
|
||||||
- `is_admin`: users with admin role
|
- `is_admin`: users with admin role
|
||||||
- `is_moderator`: users with moderator role
|
- `is_moderator`: users with moderator role
|
||||||
- *optional* `page`: **integer** page number
|
- *optional* `page`: **integer** page number
|
||||||
- *optional* `page_size`: **integer** number of users per page (default is `50`)
|
- *optional* `page_size`: **integer** number of users per page (default is `50`)
|
||||||
- *optional* `tags`: **[string]** tags list
|
- *optional* `tags`: **[string]** tags list
|
||||||
|
- *optional* `actor_types`: **[string]** actor type list (`Person`, `Service`, `Application`)
|
||||||
- *optional* `name`: **string** user display name
|
- *optional* `name`: **string** user display name
|
||||||
- *optional* `email`: **string** user email
|
- *optional* `email`: **string** user email
|
||||||
- Example: `https://mypleroma.org/api/pleroma/admin/users?query=john&filters=local,active&page=1&page_size=10&tags[]=some_tag&tags[]=another_tag&name=display_name&email=email@example.com`
|
- Example: `https://mypleroma.org/api/pleroma/admin/users?query=john&filters=local,active&page=1&page_size=10&tags[]=some_tag&tags[]=another_tag&name=display_name&email=email@example.com`
|
||||||
|
|
|
@ -116,6 +116,10 @@ The modified chat message
|
||||||
This will return a list of chats that you have been involved in, sorted by their
|
This will return a list of chats that you have been involved in, sorted by their
|
||||||
last update (so new chats will be at the top).
|
last update (so new chats will be at the top).
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
- with_muted: Include chats from muted users (boolean).
|
||||||
|
|
||||||
Returned data:
|
Returned data:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
@ -173,11 +177,14 @@ Returned data:
|
||||||
"created_at": "2020-04-21T15:06:45.000Z",
|
"created_at": "2020-04-21T15:06:45.000Z",
|
||||||
"emojis": [],
|
"emojis": [],
|
||||||
"id": "12",
|
"id": "12",
|
||||||
"unread": false
|
"unread": false,
|
||||||
|
"idempotency_key": "75442486-0874-440c-9db1-a7006c25a31f"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- idempotency_key: The copy of the `idempotency-key` HTTP request header that can be used for optimistic message sending. Included only during the first few minutes after the message creation.
|
||||||
|
|
||||||
### Posting a chat message
|
### Posting a chat message
|
||||||
|
|
||||||
Posting a chat message for given Chat id works like this:
|
Posting a chat message for given Chat id works like this:
|
||||||
|
|
|
@ -615,3 +615,41 @@ Emoji reactions work a lot like favourites do. They make it possible to react to
|
||||||
{"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]}
|
{"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `POST /api/v1/pleroma/backups`
|
||||||
|
### Create a user backup archive
|
||||||
|
|
||||||
|
* Method: `POST`
|
||||||
|
* Authentication: required
|
||||||
|
* Params: none
|
||||||
|
* Response: JSON
|
||||||
|
* Example response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
[{
|
||||||
|
"content_type": "application/zip",
|
||||||
|
"file_size": 0,
|
||||||
|
"inserted_at": "2020-09-10T16:18:03.000Z",
|
||||||
|
"processed": false,
|
||||||
|
"url": "https://example.com/media/backups/archive-foobar-20200910T161803-QUhx6VYDRQ2wfV0SdA2Pfj_2CLM_ATUlw-D5l5TJf4Q.zip"
|
||||||
|
}]
|
||||||
|
```
|
||||||
|
|
||||||
|
## `GET /api/v1/pleroma/backups`
|
||||||
|
### Lists user backups
|
||||||
|
|
||||||
|
* Method: `GET`
|
||||||
|
* Authentication: not required
|
||||||
|
* Params: none
|
||||||
|
* Response: JSON
|
||||||
|
* Example response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
[{
|
||||||
|
"content_type": "application/zip",
|
||||||
|
"file_size": 55457,
|
||||||
|
"inserted_at": "2020-09-10T16:18:03.000Z",
|
||||||
|
"processed": true,
|
||||||
|
"url": "https://example.com/media/backups/archive-foobar-20200910T161803-QUhx6VYDRQ2wfV0SdA2Pfj_2CLM_ATUlw-D5l5TJf4Q.zip"
|
||||||
|
}]
|
||||||
|
```
|
||||||
|
|
|
@ -2,15 +2,37 @@
|
||||||
|
|
||||||
Pleroma includes support for exporting metrics via the [prometheus_ex](https://github.com/deadtrickster/prometheus.ex) library.
|
Pleroma includes support for exporting metrics via the [prometheus_ex](https://github.com/deadtrickster/prometheus.ex) library.
|
||||||
|
|
||||||
|
Config example:
|
||||||
|
|
||||||
|
```
|
||||||
|
config :prometheus, Pleroma.Web.Endpoint.MetricsExporter,
|
||||||
|
enabled: true,
|
||||||
|
auth: {:basic, "myusername", "mypassword"},
|
||||||
|
ip_whitelist: ["127.0.0.1"],
|
||||||
|
path: "/api/pleroma/app_metrics",
|
||||||
|
format: :text
|
||||||
|
```
|
||||||
|
|
||||||
|
* `enabled` (Pleroma extension) enables the endpoint
|
||||||
|
* `ip_whitelist` (Pleroma extension) could be used to restrict access only to specified IPs
|
||||||
|
* `auth` sets the authentication (`false` for no auth; configurable to HTTP Basic Auth, see [prometheus-plugs](https://github.com/deadtrickster/prometheus-plugs#exporting) documentation)
|
||||||
|
* `format` sets the output format (`:text` or `:protobuf`)
|
||||||
|
* `path` sets the path to app metrics page
|
||||||
|
|
||||||
|
|
||||||
## `/api/pleroma/app_metrics`
|
## `/api/pleroma/app_metrics`
|
||||||
|
|
||||||
### Exports Prometheus application metrics
|
### Exports Prometheus application metrics
|
||||||
|
|
||||||
* Method: `GET`
|
* Method: `GET`
|
||||||
* Authentication: not required
|
* Authentication: not required by default (see configuration options above)
|
||||||
* Params: none
|
* Params: none
|
||||||
* Response: JSON
|
* Response: text
|
||||||
|
|
||||||
## Grafana
|
## Grafana
|
||||||
|
|
||||||
### Config example
|
### Config example
|
||||||
|
|
||||||
The following is a config example to use with [Grafana](https://grafana.com)
|
The following is a config example to use with [Grafana](https://grafana.com)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,12 +1,23 @@
|
||||||
# Managing frontends
|
# Managing frontends
|
||||||
|
|
||||||
`mix pleroma.frontend install <frontend> [--ref <ref>] [--file <file>] [--build-url <build-url>] [--path <path>] [--build-dir <build-dir>]`
|
=== "OTP"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./bin/pleroma_ctl frontend install <frontend> [--ref <ref>] [--file <file>] [--build-url <build-url>] [--path <path>] [--build-dir <build-dir>]
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.frontend install <frontend> [--ref <ref>] [--file <file>] [--build-url <build-url>] [--path <path>] [--build-dir <build-dir>]
|
||||||
|
```
|
||||||
|
|
||||||
Frontend can be installed either from local zip file, or automatically downloaded from the web.
|
Frontend can be installed either from local zip file, or automatically downloaded from the web.
|
||||||
|
|
||||||
You can give all the options directly on the command like, but missing information will be filled out by looking at the data configured under `frontends.available` in the config files.
|
You can give all the options directly on the command line, but missing information will be filled out by looking at the data configured under `frontends.available` in the config files.
|
||||||
|
|
||||||
|
Currently, known `<frontend>` values are:
|
||||||
|
|
||||||
Currently known `<frontend>` values are:
|
|
||||||
- [admin-fe](https://git.pleroma.social/pleroma/admin-fe)
|
- [admin-fe](https://git.pleroma.social/pleroma/admin-fe)
|
||||||
- [kenoma](http://git.pleroma.social/lambadalambda/kenoma)
|
- [kenoma](http://git.pleroma.social/lambadalambda/kenoma)
|
||||||
- [pleroma-fe](http://git.pleroma.social/pleroma/pleroma-fe)
|
- [pleroma-fe](http://git.pleroma.social/pleroma/pleroma-fe)
|
||||||
|
@ -19,51 +30,67 @@ You can still install frontends that are not configured, see below.
|
||||||
|
|
||||||
For a frontend configured under the `available` key, it's enough to install it by name.
|
For a frontend configured under the `available` key, it's enough to install it by name.
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl frontend install pleroma
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.frontend install pleroma
|
./bin/pleroma_ctl frontend install pleroma
|
||||||
```
|
```
|
||||||
|
|
||||||
This will download the latest build for the the pre-configured `ref` and install it. It can then be configured as the one of the served frontends in the config file (see `primary` or `admin`).
|
=== "From Source"
|
||||||
|
|
||||||
You can override any of the details. To install a pleroma build from a different url, you could do this:
|
```sh
|
||||||
|
mix pleroma.frontend install pleroma
|
||||||
|
```
|
||||||
|
|
||||||
```sh tab="OPT"
|
This will download the latest build for the pre-configured `ref` and install it. It can then be configured as the one of the served frontends in the config file (see `primary` or `admin`).
|
||||||
./bin/pleroma_ctl frontend install pleroma --ref 2hu_edition --build-url https://example.org/raymoo.zip
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
You can override any of the details. To install a pleroma build from a different URL, you could do this:
|
||||||
mix pleroma.frontend install pleroma --ref 2hu_edition --build-url https://example.org/raymoo.zip
|
|
||||||
```
|
=== "OTP"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
./bin/pleroma_ctl frontend install pleroma --ref 2hu_edition --build-url https://example.org/raymoo.zip
|
||||||
|
```
|
||||||
|
|
||||||
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.frontend install pleroma --ref 2hu_edition --build-url https://example.org/raymoo.zip
|
||||||
|
```
|
||||||
|
|
||||||
Similarly, you can also install from a local zip file.
|
Similarly, you can also install from a local zip file.
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl frontend install pleroma --ref mybuild --file ~/Downloads/doomfe.zip
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.frontend install pleroma --ref mybuild --file ~/Downloads/doomfe.zip
|
./bin/pleroma_ctl frontend install pleroma --ref mybuild --file ~/Downloads/doomfe.zip
|
||||||
```
|
```
|
||||||
|
|
||||||
The resulting frontend will always be installed into a folder of this template: `${instance_static}/frontends/${name}/${ref}`
|
=== "From Source"
|
||||||
|
|
||||||
Careful: This folder will be completely replaced on installation
|
```sh
|
||||||
|
mix pleroma.frontend install pleroma --ref mybuild --file ~/Downloads/doomfe.zip
|
||||||
|
```
|
||||||
|
|
||||||
|
The resulting frontend will always be installed into a folder of this template: `${instance_static}/frontends/${name}/${ref}`.
|
||||||
|
|
||||||
|
Careful: This folder will be completely replaced on installation.
|
||||||
|
|
||||||
## Example installation for an unknown frontend
|
## Example installation for an unknown frontend
|
||||||
|
|
||||||
The installation process is the same, but you will have to give all the needed options on the commond line. For example:
|
The installation process is the same, but you will have to give all the needed options on the command line. For example:
|
||||||
|
|
||||||
```sh tab="OTP"
|
=== "OTP"
|
||||||
./bin/pleroma_ctl frontend install gensokyo --ref master --build-url https://gensokyo.2hu/builds/marisa.zip
|
|
||||||
```
|
|
||||||
|
|
||||||
```sh tab="From Source"
|
```sh
|
||||||
mix pleroma.frontend install gensokyo --ref master --build-url https://gensokyo.2hu/builds/marisa.zip
|
./bin/pleroma_ctl frontend install gensokyo --ref master --build-url https://gensokyo.2hu/builds/marisa.zip
|
||||||
```
|
```
|
||||||
|
|
||||||
If you don't have a zip file but just want to install a frontend from a local path, you can simply copy the files over a folder of this template: `${instance_static}/frontends/${name}/${ref}`
|
=== "From Source"
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mix pleroma.frontend install gensokyo --ref master --build-url https://gensokyo.2hu/builds/marisa.zip
|
||||||
|
```
|
||||||
|
|
||||||
|
If you don't have a zip file but just want to install a frontend from a local path, you can simply copy the files over a folder of this template: `${instance_static}/frontends/${name}/${ref}`.
|
||||||
|
|
||||||
|
|
|
@ -40,3 +40,5 @@ If any of the options are left unspecified, you will be prompted interactively.
|
||||||
- `--strip-uploads <Y|N>` - use ExifTool to strip uploads of sensitive location data
|
- `--strip-uploads <Y|N>` - use ExifTool to strip uploads of sensitive location data
|
||||||
- `--anonymize-uploads <Y|N>` - randomize uploaded filenames
|
- `--anonymize-uploads <Y|N>` - randomize uploaded filenames
|
||||||
- `--dedupe-uploads <Y|N>` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames
|
- `--dedupe-uploads <Y|N>` - store files based on their hash to reduce data storage requirements if duplicates are uploaded with different filenames
|
||||||
|
- `--skip-release-env` - skip generation the release environment file
|
||||||
|
- `--release-env-file` - release environment file path
|
||||||
|
|
9
docs/administration/CLI_tasks/release_environments.md
Normal file
9
docs/administration/CLI_tasks/release_environments.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Generate release environment file
|
||||||
|
|
||||||
|
```sh tab="OTP"
|
||||||
|
./bin/pleroma_ctl release_env gen
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh tab="From Source"
|
||||||
|
mix pleroma.release_env gen
|
||||||
|
```
|
|
@ -1,11 +1,41 @@
|
||||||
# ChatMessages
|
# AP Extensions
|
||||||
|
## Actor endpoints
|
||||||
|
|
||||||
ChatMessages are the messages sent in 1-on-1 chats. They are similar to
|
The following endpoints are additionally present into our actors.
|
||||||
|
|
||||||
|
- `oauthRegistrationEndpoint` (`http://litepub.social/ns#oauthRegistrationEndpoint`)
|
||||||
|
- `uploadMedia` (`https://www.w3.org/ns/activitystreams#uploadMedia`)
|
||||||
|
|
||||||
|
### oauthRegistrationEndpoint
|
||||||
|
|
||||||
|
Points to MastodonAPI `/api/v1/apps` for now.
|
||||||
|
|
||||||
|
See <https://docs.joinmastodon.org/methods/apps/>
|
||||||
|
|
||||||
|
### uploadMedia
|
||||||
|
|
||||||
|
Inspired by <https://www.w3.org/wiki/SocialCG/ActivityPub/MediaUpload>, it is part of the ActivityStreams namespace because it used to be part of the ActivityPub specification and got removed from it.
|
||||||
|
|
||||||
|
Content-Type: multipart/form-data
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
- (required) `file`: The file being uploaded
|
||||||
|
- (optionnal) `description`: A plain-text description of the media, for accessibility purposes.
|
||||||
|
|
||||||
|
Response: HTTP 201 Created with the object into the body, no `Location` header provided as it doesn't have an `id`
|
||||||
|
|
||||||
|
The object given in the reponse should then be inserted into an Object's `attachment` field.
|
||||||
|
|
||||||
|
## ChatMessages
|
||||||
|
|
||||||
|
`ChatMessage`s are the messages sent in 1-on-1 chats. They are similar to
|
||||||
`Note`s, but the addresing is done by having a single AP actor in the `to`
|
`Note`s, but the addresing is done by having a single AP actor in the `to`
|
||||||
field. Addressing multiple actors is not allowed. These messages are always
|
field. Addressing multiple actors is not allowed. These messages are always
|
||||||
private, there is no public version of them. They are created with a `Create`
|
private, there is no public version of them. They are created with a `Create`
|
||||||
activity.
|
activity.
|
||||||
|
|
||||||
|
They are part of the `litepub` namespace as `http://litepub.social/ns#ChatMessage`.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
|
|
@ -7,97 +7,105 @@ Feel free to contact us to be added to this list!
|
||||||
- Homepage: <https://www.pleroma.com/#desktopApp>
|
- Homepage: <https://www.pleroma.com/#desktopApp>
|
||||||
- Source Code: <https://github.com/roma-apps/roma-desktop>
|
- Source Code: <https://github.com/roma-apps/roma-desktop>
|
||||||
- Platforms: Windows, Mac, Linux
|
- Platforms: Windows, Mac, Linux
|
||||||
- Features: Streaming Ready
|
- Features: MastoAPI, Streaming Ready
|
||||||
|
|
||||||
### Social
|
### Social
|
||||||
- Source Code: <https://gitlab.gnome.org/World/Social>
|
- Source Code: <https://gitlab.gnome.org/World/Social>
|
||||||
- Contact: [@brainblasted@social.libre.fi](https://social.libre.fi/users/brainblasted)
|
- Contact: [@brainblasted@social.libre.fi](https://social.libre.fi/users/brainblasted)
|
||||||
- Platforms: Linux (GNOME)
|
- Platforms: Linux (GNOME)
|
||||||
- Note(2019-01-28): Not at a pre-alpha stage yet
|
- Note(2019-01-28): Not at a pre-alpha stage yet
|
||||||
|
- Features: MastoAPI
|
||||||
|
|
||||||
### Whalebird
|
### Whalebird
|
||||||
- Homepage: <https://whalebird.org/>
|
- Homepage: <https://whalebird.org/>
|
||||||
- Source Code: <https://github.com/h3poteto/whalebird-desktop>
|
- Source Code: <https://github.com/h3poteto/whalebird-desktop>
|
||||||
- Contact: [@h3poteto@pleroma.io](https://pleroma.io/users/h3poteto)
|
- Contact: [@h3poteto@pleroma.io](https://pleroma.io/users/h3poteto)
|
||||||
- Platforms: Windows, Mac, Linux
|
- Platforms: Windows, Mac, Linux
|
||||||
- Features: Streaming Ready
|
- Features: MastoAPI, Streaming Ready
|
||||||
|
|
||||||
## Handheld
|
## Handheld
|
||||||
|
### AndStatus
|
||||||
|
- Homepage: <http://andstatus.org/>
|
||||||
|
- Source Code: <https://github.com/andstatus/andstatus/>
|
||||||
|
- Platforms: Android
|
||||||
|
- Features: MastoAPI, ActivityPub (Client-to-Server)
|
||||||
|
|
||||||
### Amaroq
|
### Amaroq
|
||||||
- Homepage: <https://itunes.apple.com/us/app/amaroq-for-mastodon/id1214116200>
|
- Homepage: <https://itunes.apple.com/us/app/amaroq-for-mastodon/id1214116200>
|
||||||
- Source Code: <https://github.com/ReticentJohn/Amaroq>
|
- Source Code: <https://github.com/ReticentJohn/Amaroq>
|
||||||
- Contact: [@eurasierboy@mastodon.social](https://mastodon.social/users/eurasierboy)
|
- Contact: [@eurasierboy@mastodon.social](https://mastodon.social/users/eurasierboy)
|
||||||
- Platforms: iOS
|
- Platforms: iOS
|
||||||
- Features: No Streaming
|
- Features: MastoAPI, No Streaming
|
||||||
|
|
||||||
### Fedilab
|
### Fedilab
|
||||||
- Homepage: <https://fedilab.app/>
|
- Homepage: <https://fedilab.app/>
|
||||||
- Source Code: <https://framagit.org/tom79/fedilab/>
|
- Source Code: <https://framagit.org/tom79/fedilab/>
|
||||||
- Contact: [@fedilab@framapiaf.org](https://framapiaf.org/users/fedilab)
|
- Contact: [@fedilab@framapiaf.org](https://framapiaf.org/users/fedilab)
|
||||||
- Platforms: Android
|
- Platforms: Android
|
||||||
- Features: Streaming Ready, Moderation, Text Formatting
|
- Features: MastoAPI, Streaming Ready, Moderation, Text Formatting
|
||||||
|
|
||||||
### Kyclos
|
### Kyclos
|
||||||
- Source Code: <https://git.pleroma.social/pleroma/harbour-kyclos>
|
- Source Code: <https://git.pleroma.social/pleroma/harbour-kyclos>
|
||||||
- Platforms: SailfishOS
|
- Platforms: SailfishOS
|
||||||
- Features: No Streaming
|
- Features: MastoAPI, No Streaming
|
||||||
|
|
||||||
### Husky
|
### Husky
|
||||||
- Source code: <https://git.mentality.rip/FWGS/Husky>
|
- Source code: <https://git.mentality.rip/FWGS/Husky>
|
||||||
- Contact: [@Husky@enigmatic.observer](https://enigmatic.observer/users/Husky)
|
- Contact: [@Husky@enigmatic.observer](https://enigmatic.observer/users/Husky)
|
||||||
- Platforms: Android
|
- Platforms: Android
|
||||||
- Features: No Streaming, Emoji Reactions, Text Formatting, FE Stickers
|
- Features: MastoAPI, No Streaming, Emoji Reactions, Text Formatting, FE Stickers
|
||||||
|
|
||||||
### Fedi
|
### Fedi
|
||||||
- Homepage: <https://www.fediapp.com/>
|
- Homepage: <https://www.fediapp.com/>
|
||||||
- Source Code: Proprietary, but gratis
|
- Source Code: Proprietary, but gratis
|
||||||
- Platforms: iOS, Android
|
- Platforms: iOS, Android
|
||||||
- Features: Pleroma-specific features like Reactions
|
- Features: MastoAPI, Pleroma-specific features like Reactions
|
||||||
|
|
||||||
### Tusky
|
### Tusky
|
||||||
- Homepage: <https://tuskyapp.github.io/>
|
- Homepage: <https://tuskyapp.github.io/>
|
||||||
- Source Code: <https://github.com/tuskyapp/Tusky>
|
- Source Code: <https://github.com/tuskyapp/Tusky>
|
||||||
- Contact: [@ConnyDuck@mastodon.social](https://mastodon.social/users/ConnyDuck)
|
- Contact: [@ConnyDuck@mastodon.social](https://mastodon.social/users/ConnyDuck)
|
||||||
- Platforms: Android
|
- Platforms: Android
|
||||||
- Features: No Streaming
|
- Features: MastoAPI, No Streaming
|
||||||
|
|
||||||
### Twidere
|
### Twidere
|
||||||
- Homepage: <https://twidere.mariotaku.org/>
|
- Homepage: <https://twidere.mariotaku.org/>
|
||||||
- Source Code: <https://github.com/TwidereProject/Twidere-Android/>
|
- Source Code: <https://github.com/TwidereProject/Twidere-Android/>
|
||||||
- Contact: <me@mariotaku.org>
|
- Contact: <me@mariotaku.org>
|
||||||
- Platform: Android
|
- Platform: Android
|
||||||
- Features: No Streaming
|
- Features: MastoAPI, No Streaming
|
||||||
|
|
||||||
### Indigenous
|
### Indigenous
|
||||||
- Homepage: <https://indigenous.realize.be/>
|
- Homepage: <https://indigenous.realize.be/>
|
||||||
- Source Code: <https://github.com/swentel/indigenous-android/>
|
- Source Code: <https://github.com/swentel/indigenous-android/>
|
||||||
- Contact: [@realize.be@realize.be](@realize.be@realize.be)
|
- Contact: [@swentel@realize.be](https://realize.be)
|
||||||
- Platforms: Android
|
- Platforms: Android
|
||||||
- Features: No Streaming
|
- Features: MastoAPI, No Streaming
|
||||||
|
|
||||||
## Alternative Web Interfaces
|
## Alternative Web Interfaces
|
||||||
### Brutaldon
|
### Brutaldon
|
||||||
- Homepage: <https://jfm.carcosa.net/projects/software/brutaldon/>
|
- Homepage: <https://jfm.carcosa.net/projects/software/brutaldon/>
|
||||||
- Source Code: <https://git.carcosa.net/jmcbray/brutaldon>
|
- Source Code: <https://git.carcosa.net/jmcbray/brutaldon>
|
||||||
- Contact: [@gcupc@glitch.social](https://glitch.social/users/gcupc)
|
- Contact: [@gcupc@glitch.social](https://glitch.social/users/gcupc)
|
||||||
- Features: No Streaming
|
- Features: MastoAPI, No Streaming
|
||||||
|
|
||||||
### Halcyon
|
### Halcyon
|
||||||
- Source Code: <https://notabug.org/halcyon-suite/halcyon>
|
- Source Code: <https://notabug.org/halcyon-suite/halcyon>
|
||||||
- Contact: [@halcyon@social.csswg.org](https://social.csswg.org/users/halcyon)
|
- Contact: [@halcyon@social.csswg.org](https://social.csswg.org/users/halcyon)
|
||||||
- Features: Streaming Ready
|
- Features: MastoAPI, Streaming Ready
|
||||||
|
|
||||||
### Pinafore
|
### Pinafore
|
||||||
- Homepage: <https://pinafore.social/>
|
- Homepage: <https://pinafore.social/>
|
||||||
- Source Code: <https://github.com/nolanlawson/pinafore>
|
- Source Code: <https://github.com/nolanlawson/pinafore>
|
||||||
- Contact: [@pinafore@mastodon.technology](https://mastodon.technology/users/pinafore)
|
- Contact: [@pinafore@mastodon.technology](https://mastodon.technology/users/pinafore)
|
||||||
- Note: Pleroma support is a secondary goal
|
- Note: Pleroma support is a secondary goal
|
||||||
- Features: No Streaming
|
- Features: MastoAPI, No Streaming
|
||||||
|
|
||||||
### Sengi
|
### Sengi
|
||||||
- Homepage: <https://nicolasconstant.github.io/sengi/>
|
- Homepage: <https://nicolasconstant.github.io/sengi/>
|
||||||
- Source Code: <https://github.com/NicolasConstant/sengi>
|
- Source Code: <https://github.com/NicolasConstant/sengi>
|
||||||
- Contact: [@sengi_app@mastodon.social](https://mastodon.social/users/sengi_app)
|
- Contact: [@sengi_app@mastodon.social](https://mastodon.social/users/sengi_app)
|
||||||
|
- Features: MastoAPI
|
||||||
|
|
||||||
### DashFE
|
### DashFE
|
||||||
- Source Code: <https://notabug.org/daisuke/DashboardFE>
|
- Source Code: <https://notabug.org/daisuke/DashboardFE>
|
||||||
|
@ -107,3 +115,4 @@ Feel free to contact us to be added to this list!
|
||||||
- Source Code: <https://git.freesoftwareextremist.com/bloat/>
|
- Source Code: <https://git.freesoftwareextremist.com/bloat/>
|
||||||
- Contact: [@r@freesoftwareextremist.com](https://freesoftwareextremist.com/users/r)
|
- Contact: [@r@freesoftwareextremist.com](https://freesoftwareextremist.com/users/r)
|
||||||
- Features: Does not requires JavaScript
|
- Features: Does not requires JavaScript
|
||||||
|
- Features: MastoAPI
|
||||||
|
|
|
@ -45,6 +45,7 @@ To add configuration to your config file, you can copy it from the base config.
|
||||||
older software for theses nicknames.
|
older software for theses nicknames.
|
||||||
* `max_pinned_statuses`: The maximum number of pinned statuses. `0` will disable the feature.
|
* `max_pinned_statuses`: The maximum number of pinned statuses. `0` will disable the feature.
|
||||||
* `autofollowed_nicknames`: Set to nicknames of (local) users that every new user should automatically follow.
|
* `autofollowed_nicknames`: Set to nicknames of (local) users that every new user should automatically follow.
|
||||||
|
* `autofollowing_nicknames`: Set to nicknames of (local) users that automatically follows every newly registered user.
|
||||||
* `attachment_links`: Set to true to enable automatically adding attachment link text to statuses.
|
* `attachment_links`: Set to true to enable automatically adding attachment link text to statuses.
|
||||||
* `max_report_comment_size`: The maximum size of the report comment (Default: `1000`).
|
* `max_report_comment_size`: The maximum size of the report comment (Default: `1000`).
|
||||||
* `safe_dm_mentions`: If set to true, only mentions at the beginning of a post will be used to address people in direct messages. This is to prevent accidental mentioning of people when talking about them (e.g. "@friend hey i really don't like @enemy"). Default: `false`.
|
* `safe_dm_mentions`: If set to true, only mentions at the beginning of a post will be used to address people in direct messages. This is to prevent accidental mentioning of people when talking about them (e.g. "@friend hey i really don't like @enemy"). Default: `false`.
|
||||||
|
@ -1077,6 +1078,20 @@ Control favicons for instances.
|
||||||
|
|
||||||
* `enabled`: Allow/disallow displaying and getting instances favicons
|
* `enabled`: Allow/disallow displaying and getting instances favicons
|
||||||
|
|
||||||
|
## Pleroma.User.Backup
|
||||||
|
|
||||||
|
!!! note
|
||||||
|
Requires enabled email
|
||||||
|
|
||||||
|
* `:purge_after_days` an integer, remove backup achives after N days.
|
||||||
|
* `:limit_days` an integer, limit user to export not more often than once per N days.
|
||||||
|
* `:dir` a string with a path to backup temporary directory or `nil` to let Pleroma choose temporary directory in the following order:
|
||||||
|
1. the directory named by the TMPDIR environment variable
|
||||||
|
2. the directory named by the TEMP environment variable
|
||||||
|
3. the directory named by the TMP environment variable
|
||||||
|
4. C:\TMP on Windows or /tmp on Unix-like operating systems
|
||||||
|
5. as a last resort, the current working directory
|
||||||
|
|
||||||
## Frontend management
|
## Frontend management
|
||||||
|
|
||||||
Frontends in Pleroma are swappable - you can specify which one to use here.
|
Frontends in Pleroma are swappable - you can specify which one to use here.
|
||||||
|
|
|
@ -13,6 +13,7 @@ It assumes that you have administrative rights, either as root or a user with [s
|
||||||
* `erlang-parsetools`
|
* `erlang-parsetools`
|
||||||
* `erlang-xmerl`
|
* `erlang-xmerl`
|
||||||
* `git`
|
* `git`
|
||||||
|
* `file-dev`
|
||||||
* Development Tools
|
* Development Tools
|
||||||
* `cmake`
|
* `cmake`
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@ sudo apk upgrade
|
||||||
* Install some tools, which are needed later:
|
* Install some tools, which are needed later:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo apk add git build-base cmake
|
sudo apk add git build-base cmake file-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install Elixir and Erlang
|
### Install Elixir and Erlang
|
||||||
|
|
|
@ -10,6 +10,7 @@ This guide will assume that you have administrative rights, either as root or a
|
||||||
* `git`
|
* `git`
|
||||||
* `base-devel`
|
* `base-devel`
|
||||||
* `cmake`
|
* `cmake`
|
||||||
|
* `file`
|
||||||
|
|
||||||
#### Optional packages used in this guide
|
#### Optional packages used in this guide
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ sudo pacman -Syu
|
||||||
* Install some of the above mentioned programs:
|
* Install some of the above mentioned programs:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo pacman -S git base-devel elixir cmake
|
sudo pacman -S git base-devel elixir cmake file
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install PostgreSQL
|
### Install PostgreSQL
|
||||||
|
|
|
@ -10,6 +10,7 @@ This guide will assume you are on Debian Stretch. This guide should also work wi
|
||||||
* `elixir` (1.8+, Follow the guide to install from the Erlang Solutions repo or use [asdf](https://github.com/asdf-vm/asdf) as the pleroma user)
|
* `elixir` (1.8+, Follow the guide to install from the Erlang Solutions repo or use [asdf](https://github.com/asdf-vm/asdf) as the pleroma user)
|
||||||
* `erlang-dev`
|
* `erlang-dev`
|
||||||
* `erlang-nox`
|
* `erlang-nox`
|
||||||
|
* `libmagic-dev`
|
||||||
* `git`
|
* `git`
|
||||||
* `build-essential`
|
* `build-essential`
|
||||||
* `cmake`
|
* `cmake`
|
||||||
|
@ -34,7 +35,7 @@ sudo apt full-upgrade
|
||||||
* Install some of the above mentioned programs:
|
* Install some of the above mentioned programs:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo apt install git build-essential postgresql postgresql-contrib cmake
|
sudo apt install git build-essential postgresql postgresql-contrib cmake libmagic-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install Elixir and Erlang
|
### Install Elixir and Erlang
|
||||||
|
@ -100,6 +101,7 @@ sudo -Hu pleroma mix deps.get
|
||||||
mv config/{generated_config.exs,prod.secret.exs}
|
mv config/{generated_config.exs,prod.secret.exs}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
* The previous command creates also the file `config/setup_db.psql`, with which you can create the database:
|
* The previous command creates also the file `config/setup_db.psql`, with which you can create the database:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
@ -180,6 +182,7 @@ sudo cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.se
|
||||||
```
|
```
|
||||||
|
|
||||||
* Edit the service file and make sure that all paths fit your installation
|
* Edit the service file and make sure that all paths fit your installation
|
||||||
|
* Check that `EnvironmentFile` contains the correct path to the env file. Or generate the env file: `sudo -Hu pleroma mix pleroma.release_env gen`
|
||||||
* Enable and start `pleroma.service`:
|
* Enable and start `pleroma.service`:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
- `git`
|
- `git`
|
||||||
- `build-essential`
|
- `build-essential`
|
||||||
- `cmake`
|
- `cmake`
|
||||||
|
- `libmagic-dev`
|
||||||
|
|
||||||
#### このガイドで利用している追加パッケージ
|
#### このガイドで利用している追加パッケージ
|
||||||
|
|
||||||
|
@ -36,7 +37,7 @@ sudo apt full-upgrade
|
||||||
|
|
||||||
* 上記に挙げたパッケージをインストールしておきます。
|
* 上記に挙げたパッケージをインストールしておきます。
|
||||||
```
|
```
|
||||||
sudo apt install git build-essential postgresql postgresql-contrib cmake ffmpeg imagemagick
|
sudo apt install git build-essential postgresql postgresql-contrib cmake ffmpeg imagemagick libmagic-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### ElixirとErlangをインストールします
|
### ElixirとErlangをインストールします
|
||||||
|
|
|
@ -29,6 +29,7 @@ Gentoo quite pointedly does not come with a cron daemon installed, and as such i
|
||||||
* `dev-lang/elixir`
|
* `dev-lang/elixir`
|
||||||
* `dev-vcs/git`
|
* `dev-vcs/git`
|
||||||
* `dev-util/cmake`
|
* `dev-util/cmake`
|
||||||
|
* `sys-apps/file`
|
||||||
|
|
||||||
#### Optional ebuilds used in this guide
|
#### Optional ebuilds used in this guide
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ Gentoo quite pointedly does not come with a cron daemon installed, and as such i
|
||||||
* Emerge all required the required and suggested software in one go:
|
* Emerge all required the required and suggested software in one go:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# emerge --ask dev-db/postgresql dev-lang/elixir dev-vcs/git www-servers/nginx app-crypt/certbot app-crypt/certbot-nginx dev-util/cmake
|
# emerge --ask dev-db/postgresql dev-lang/elixir dev-vcs/git www-servers/nginx app-crypt/certbot app-crypt/certbot-nginx dev-util/cmake sys-apps/file
|
||||||
```
|
```
|
||||||
|
|
||||||
If you would not like to install the optional packages, remove them from this line.
|
If you would not like to install the optional packages, remove them from this line.
|
||||||
|
|
|
@ -27,22 +27,23 @@ Other than things bundled in the OTP release Pleroma depends on:
|
||||||
* PostgreSQL (also utilizes extensions in postgresql-contrib)
|
* PostgreSQL (also utilizes extensions in postgresql-contrib)
|
||||||
* nginx (could be swapped with another reverse proxy but this guide covers only it)
|
* nginx (could be swapped with another reverse proxy but this guide covers only it)
|
||||||
* certbot (for Let's Encrypt certificates, could be swapped with another ACME client, but this guide covers only it)
|
* certbot (for Let's Encrypt certificates, could be swapped with another ACME client, but this guide covers only it)
|
||||||
|
* libmagic/file
|
||||||
|
|
||||||
=== "Alpine"
|
=== "Alpine"
|
||||||
```
|
```
|
||||||
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
|
echo "http://nl.alpinelinux.org/alpine/latest-stable/community" >> /etc/apk/repositories
|
||||||
apk update
|
apk update
|
||||||
apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot
|
apk add curl unzip ncurses postgresql postgresql-contrib nginx certbot file-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
=== "Debian/Ubuntu"
|
=== "Debian/Ubuntu"
|
||||||
```
|
```
|
||||||
apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot
|
apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot libmagic-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### Installing optional packages
|
### Installing optional packages
|
||||||
|
|
||||||
Per [`docs/installation/optional/media_graphics_packages.md`](docs/installation/optional/media_graphics_packages.md):
|
Per [`docs/installation/optional/media_graphics_packages.md`](optional/media_graphics_packages.md):
|
||||||
* ImageMagick
|
* ImageMagick
|
||||||
* ffmpeg
|
* ffmpeg
|
||||||
* exiftool
|
* exiftool
|
||||||
|
@ -148,6 +149,9 @@ chown -R pleroma /etc/pleroma
|
||||||
# Run the config generator
|
# Run the config generator
|
||||||
su pleroma -s $SHELL -lc "./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql"
|
su pleroma -s $SHELL -lc "./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql"
|
||||||
|
|
||||||
|
# Run the environment file generator.
|
||||||
|
su pleroma -s $SHELL -lc "./bin/pleroma_ctl release_env gen"
|
||||||
|
|
||||||
# Create the postgres database
|
# Create the postgres database
|
||||||
su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"
|
su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"
|
||||||
|
|
||||||
|
@ -158,7 +162,7 @@ su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
|
||||||
# su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
|
# su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
|
||||||
|
|
||||||
# Start the instance to verify that everything is working as expected
|
# Start the instance to verify that everything is working as expected
|
||||||
su pleroma -s $SHELL -lc "./bin/pleroma daemon"
|
su pleroma -s $SHELL -lc "export $(cat /opt/pleroma/config/pleroma.env); ./bin/pleroma daemon"
|
||||||
|
|
||||||
# Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly
|
# Wait for about 20 seconds and query the instance endpoint, if it shows your uri, name and email correctly, you are configured correctly
|
||||||
sleep 20 && curl http://localhost:4000/api/v1/instance
|
sleep 20 && curl http://localhost:4000/api/v1/instance
|
||||||
|
@ -310,4 +314,3 @@ This will create an account withe the username of 'joeuser' with the email addre
|
||||||
## Questions
|
## Questions
|
||||||
|
|
||||||
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
Questions about the installation or didn’t it work as it should be, ask in [#pleroma:matrix.org](https://matrix.heldscal.la/#/room/#freenode_#pleroma:matrix.org) or IRC Channel **#pleroma** on **Freenode**.
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ pidfile="/var/run/pleroma.pid"
|
||||||
directory=/opt/pleroma
|
directory=/opt/pleroma
|
||||||
healthcheck_delay=60
|
healthcheck_delay=60
|
||||||
healthcheck_timer=30
|
healthcheck_timer=30
|
||||||
|
export $(cat /opt/pleroma/config/pleroma.env)
|
||||||
|
|
||||||
: ${pleroma_port:-4000}
|
: ${pleroma_port:-4000}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,8 @@ Environment="MIX_ENV=prod"
|
||||||
Environment="HOME=/var/lib/pleroma"
|
Environment="HOME=/var/lib/pleroma"
|
||||||
; Path to the folder containing the Pleroma installation.
|
; Path to the folder containing the Pleroma installation.
|
||||||
WorkingDirectory=/opt/pleroma
|
WorkingDirectory=/opt/pleroma
|
||||||
|
; Path to the environment file. the file contains RELEASE_COOKIE and etc
|
||||||
|
EnvironmentFile=/opt/pleroma/config/pleroma.env
|
||||||
; Path to the Mix binary.
|
; Path to the Mix binary.
|
||||||
ExecStart=/usr/bin/mix phx.server
|
ExecStart=/usr/bin/mix phx.server
|
||||||
|
|
||||||
|
@ -29,8 +31,6 @@ ProtectHome=true
|
||||||
ProtectSystem=full
|
ProtectSystem=full
|
||||||
; Sets up a new /dev mount for the process and only adds API pseudo devices like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled by default because it may not work on devices like the Raspberry Pi.
|
; Sets up a new /dev mount for the process and only adds API pseudo devices like /dev/null, /dev/zero or /dev/random but not physical devices. Disabled by default because it may not work on devices like the Raspberry Pi.
|
||||||
PrivateDevices=false
|
PrivateDevices=false
|
||||||
; Ensures that the service process and all its children can never gain new privileges through execve().
|
|
||||||
NoNewPrivileges=true
|
|
||||||
; Drops the sysadmin capability from the daemon.
|
; Drops the sysadmin capability from the daemon.
|
||||||
CapabilityBoundingSet=~CAP_SYS_ADMIN
|
CapabilityBoundingSet=~CAP_SYS_ADMIN
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,9 @@ defmodule Mix.Tasks.Pleroma.Instance do
|
||||||
listen_port: :string,
|
listen_port: :string,
|
||||||
strip_uploads: :string,
|
strip_uploads: :string,
|
||||||
anonymize_uploads: :string,
|
anonymize_uploads: :string,
|
||||||
dedupe_uploads: :string
|
dedupe_uploads: :string,
|
||||||
|
skip_release_env: :boolean,
|
||||||
|
release_env_file: :string
|
||||||
],
|
],
|
||||||
aliases: [
|
aliases: [
|
||||||
o: :output,
|
o: :output,
|
||||||
|
@ -241,6 +243,24 @@ defmodule Mix.Tasks.Pleroma.Instance do
|
||||||
|
|
||||||
write_robots_txt(static_dir, indexable, template_dir)
|
write_robots_txt(static_dir, indexable, template_dir)
|
||||||
|
|
||||||
|
if Keyword.get(options, :skip_release_env, false) do
|
||||||
|
shell_info("""
|
||||||
|
Release environment file is skip. Please generate the release env file before start.
|
||||||
|
`MIX_ENV=#{Mix.env()} mix pleroma.release_env gen`
|
||||||
|
""")
|
||||||
|
else
|
||||||
|
shell_info("Generation the environment file:")
|
||||||
|
|
||||||
|
release_env_args =
|
||||||
|
with path when not is_nil(path) <- Keyword.get(options, :release_env_file) do
|
||||||
|
["gen", "--path", path]
|
||||||
|
else
|
||||||
|
_ -> ["gen"]
|
||||||
|
end
|
||||||
|
|
||||||
|
Mix.Tasks.Pleroma.ReleaseEnv.run(release_env_args)
|
||||||
|
end
|
||||||
|
|
||||||
shell_info(
|
shell_info(
|
||||||
"\n All files successfully written! Refer to the installation instructions for your platform for next steps."
|
"\n All files successfully written! Refer to the installation instructions for your platform for next steps."
|
||||||
)
|
)
|
||||||
|
|
76
lib/mix/tasks/pleroma/release_env.ex
Normal file
76
lib/mix/tasks/pleroma/release_env.ex
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Mix.Tasks.Pleroma.ReleaseEnv do
|
||||||
|
use Mix.Task
|
||||||
|
import Mix.Pleroma
|
||||||
|
|
||||||
|
@shortdoc "Generate Pleroma environment file."
|
||||||
|
@moduledoc File.read!("docs/administration/CLI_tasks/release_environments.md")
|
||||||
|
|
||||||
|
def run(["gen" | rest]) do
|
||||||
|
{options, [], []} =
|
||||||
|
OptionParser.parse(
|
||||||
|
rest,
|
||||||
|
strict: [
|
||||||
|
force: :boolean,
|
||||||
|
path: :string
|
||||||
|
],
|
||||||
|
aliases: [
|
||||||
|
p: :path,
|
||||||
|
f: :force
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
file_path =
|
||||||
|
get_option(
|
||||||
|
options,
|
||||||
|
:path,
|
||||||
|
"Environment file path",
|
||||||
|
"./config/pleroma.env"
|
||||||
|
)
|
||||||
|
|
||||||
|
env_path = Path.expand(file_path)
|
||||||
|
|
||||||
|
proceed? =
|
||||||
|
if File.exists?(env_path) do
|
||||||
|
get_option(
|
||||||
|
options,
|
||||||
|
:force,
|
||||||
|
"Environment file already exists. Do you want to overwrite the #{env_path} file? (y/n)",
|
||||||
|
"n"
|
||||||
|
) === "y"
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
if proceed? do
|
||||||
|
case do_generate(env_path) do
|
||||||
|
{:error, reason} ->
|
||||||
|
shell_error(
|
||||||
|
File.Error.message(%{action: "write to file", reason: reason, path: env_path})
|
||||||
|
)
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
shell_info("\nThe file generated: #{env_path}.\n")
|
||||||
|
|
||||||
|
shell_info("""
|
||||||
|
WARNING: before start pleroma app please make sure to make the file read-only and non-modifiable.
|
||||||
|
Example:
|
||||||
|
chmod 0444 #{file_path}
|
||||||
|
chattr +i #{file_path}
|
||||||
|
""")
|
||||||
|
end
|
||||||
|
else
|
||||||
|
shell_info("\nThe file is exist. #{env_path}.\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def do_generate(path) do
|
||||||
|
content = "RELEASE_COOKIE=#{Base.encode32(:crypto.strong_rand_bytes(32))}"
|
||||||
|
|
||||||
|
File.mkdir_p!(Path.dirname(path))
|
||||||
|
File.write(path, content)
|
||||||
|
end
|
||||||
|
end
|
|
@ -419,7 +419,7 @@ defmodule Mix.Tasks.Pleroma.User do
|
||||||
|> Enum.each(fn user ->
|
|> Enum.each(fn user ->
|
||||||
shell_info(
|
shell_info(
|
||||||
"#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
|
"#{user.nickname} moderator: #{user.is_moderator}, admin: #{user.is_admin}, locked: #{
|
||||||
user.locked
|
user.is_locked
|
||||||
}, deactivated: #{user.deactivated}"
|
}, deactivated: #{user.deactivated}"
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
@ -447,10 +447,10 @@ defmodule Mix.Tasks.Pleroma.User do
|
||||||
defp set_locked(user, value) do
|
defp set_locked(user, value) do
|
||||||
{:ok, user} =
|
{:ok, user} =
|
||||||
user
|
user
|
||||||
|> Changeset.change(%{locked: value})
|
|> Changeset.change(%{is_locked: value})
|
||||||
|> User.update_and_set_cache()
|
|> User.update_and_set_cache()
|
||||||
|
|
||||||
shell_info("Locked status of #{user.nickname}: #{user.locked}")
|
shell_info("Locked status of #{user.nickname}: #{user.is_locked}")
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,12 @@ defmodule Phoenix.Transports.WebSocket.Raw do
|
||||||
|
|
||||||
case conn do
|
case conn do
|
||||||
%{halted: false} = conn ->
|
%{halted: false} = conn ->
|
||||||
case Transport.connect(endpoint, handler, transport, __MODULE__, nil, conn.params) do
|
case handler.connect(%{
|
||||||
|
endpoint: endpoint,
|
||||||
|
transport: transport,
|
||||||
|
options: [serializer: nil],
|
||||||
|
params: conn.params
|
||||||
|
}) do
|
||||||
{:ok, socket} ->
|
{:ok, socket} ->
|
||||||
{:ok, conn, {__MODULE__, {socket, opts}}}
|
{:ok, conn, {__MODULE__, {socket, opts}}}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ defmodule Pleroma.Activity do
|
||||||
alias Pleroma.ReportNote
|
alias Pleroma.ReportNote
|
||||||
alias Pleroma.ThreadMute
|
alias Pleroma.ThreadMute
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
|
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
@ -153,6 +154,18 @@ defmodule Pleroma.Activity do
|
||||||
|
|
||||||
def get_bookmark(_, _), do: nil
|
def get_bookmark(_, _), do: nil
|
||||||
|
|
||||||
|
def get_report(activity_id) do
|
||||||
|
opts = %{
|
||||||
|
type: "Flag",
|
||||||
|
skip_preload: true,
|
||||||
|
preload_report_notes: true
|
||||||
|
}
|
||||||
|
|
||||||
|
ActivityPub.fetch_activities_query([], opts)
|
||||||
|
|> where(id: ^activity_id)
|
||||||
|
|> Repo.one()
|
||||||
|
end
|
||||||
|
|
||||||
def change(struct, params \\ %{}) do
|
def change(struct, params \\ %{}) do
|
||||||
struct
|
struct
|
||||||
|> cast(params, [:data, :recipients])
|
|> cast(params, [:data, :recipients])
|
||||||
|
|
|
@ -95,11 +95,12 @@ defmodule Pleroma.Application do
|
||||||
[
|
[
|
||||||
Pleroma.Stats,
|
Pleroma.Stats,
|
||||||
Pleroma.JobQueueMonitor,
|
Pleroma.JobQueueMonitor,
|
||||||
|
{Majic.Pool, [name: Pleroma.MajicPool, pool_size: Config.get([:majic_pool, :size], 2)]},
|
||||||
{Oban, Config.get(Oban)}
|
{Oban, Config.get(Oban)}
|
||||||
] ++
|
] ++
|
||||||
task_children(@env) ++
|
task_children(@env) ++
|
||||||
dont_run_in_test(@env) ++
|
dont_run_in_test(@env) ++
|
||||||
chat_child(@env, chat_enabled?()) ++
|
chat_child(chat_enabled?()) ++
|
||||||
[
|
[
|
||||||
Pleroma.Web.Endpoint,
|
Pleroma.Web.Endpoint,
|
||||||
Pleroma.Gopher.Server
|
Pleroma.Gopher.Server
|
||||||
|
@ -150,7 +151,10 @@ defmodule Pleroma.Application do
|
||||||
|
|
||||||
Pleroma.Web.Endpoint.MetricsExporter.setup()
|
Pleroma.Web.Endpoint.MetricsExporter.setup()
|
||||||
Pleroma.Web.Endpoint.PipelineInstrumenter.setup()
|
Pleroma.Web.Endpoint.PipelineInstrumenter.setup()
|
||||||
Pleroma.Web.Endpoint.Instrumenter.setup()
|
|
||||||
|
# Note: disabled until prometheus-phx is integrated into prometheus-phoenix:
|
||||||
|
# Pleroma.Web.Endpoint.Instrumenter.setup()
|
||||||
|
PrometheusPhx.setup()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp cachex_children do
|
defp cachex_children do
|
||||||
|
@ -164,7 +168,11 @@ defmodule Pleroma.Application do
|
||||||
build_cachex("web_resp", limit: 2500),
|
build_cachex("web_resp", limit: 2500),
|
||||||
build_cachex("emoji_packs", expiration: emoji_packs_expiration(), limit: 10),
|
build_cachex("emoji_packs", expiration: emoji_packs_expiration(), limit: 10),
|
||||||
build_cachex("failed_proxy_url", limit: 2500),
|
build_cachex("failed_proxy_url", limit: 2500),
|
||||||
build_cachex("banned_urls", default_ttl: :timer.hours(24 * 30), limit: 5_000)
|
build_cachex("banned_urls", default_ttl: :timer.hours(24 * 30), limit: 5_000),
|
||||||
|
build_cachex("chat_message_id_idempotency_key",
|
||||||
|
expiration: chat_message_id_idempotency_key_expiration(),
|
||||||
|
limit: 500_000
|
||||||
|
)
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -174,6 +182,9 @@ defmodule Pleroma.Application do
|
||||||
defp idempotency_expiration,
|
defp idempotency_expiration,
|
||||||
do: expiration(default: :timer.seconds(6 * 60 * 60), interval: :timer.seconds(60))
|
do: expiration(default: :timer.seconds(6 * 60 * 60), interval: :timer.seconds(60))
|
||||||
|
|
||||||
|
defp chat_message_id_idempotency_key_expiration,
|
||||||
|
do: expiration(default: :timer.minutes(2), interval: :timer.seconds(60))
|
||||||
|
|
||||||
defp seconds_valid_interval,
|
defp seconds_valid_interval,
|
||||||
do: :timer.seconds(Config.get!([Pleroma.Captcha, :seconds_valid]))
|
do: :timer.seconds(Config.get!([Pleroma.Captcha, :seconds_valid]))
|
||||||
|
|
||||||
|
@ -201,11 +212,14 @@ defmodule Pleroma.Application do
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp chat_child(_env, true) do
|
defp chat_child(true) do
|
||||||
[Pleroma.Web.ChatChannel.ChatChannelState]
|
[
|
||||||
|
Pleroma.Web.ChatChannel.ChatChannelState,
|
||||||
|
{Phoenix.PubSub, [name: Pleroma.PubSub, adapter: Phoenix.PubSub.PG2]}
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp chat_child(_, _), do: []
|
defp chat_child(_), do: []
|
||||||
|
|
||||||
defp task_children(:test) do
|
defp task_children(:test) do
|
||||||
[
|
[
|
||||||
|
|
|
@ -10,7 +10,7 @@ defmodule Pleroma.Captcha.Kocaptcha do
|
||||||
def new do
|
def new do
|
||||||
endpoint = Pleroma.Config.get!([__MODULE__, :endpoint])
|
endpoint = Pleroma.Config.get!([__MODULE__, :endpoint])
|
||||||
|
|
||||||
case Tesla.get(endpoint <> "/new") do
|
case Pleroma.HTTP.get(endpoint <> "/new") do
|
||||||
{:error, _} ->
|
{:error, _} ->
|
||||||
%{error: :kocaptcha_service_unavailable}
|
%{error: :kocaptcha_service_unavailable}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ defmodule Pleroma.Conversation do
|
||||||
def maybe_create_recipientships(participation, activity) do
|
def maybe_create_recipientships(participation, activity) do
|
||||||
participation = Repo.preload(participation, :recipients)
|
participation = Repo.preload(participation, :recipients)
|
||||||
|
|
||||||
if participation.recipients |> Enum.empty?() do
|
if Enum.empty?(participation.recipients) do
|
||||||
recipients = User.get_all_by_ap_id(activity.recipients)
|
recipients = User.get_all_by_ap_id(activity.recipients)
|
||||||
RecipientShip.create(recipients, participation)
|
RecipientShip.create(recipients, participation)
|
||||||
end
|
end
|
||||||
|
@ -69,10 +69,6 @@ defmodule Pleroma.Conversation do
|
||||||
Enum.map(users, fn user ->
|
Enum.map(users, fn user ->
|
||||||
invisible_conversation = Enum.any?(users, &User.blocks?(user, &1))
|
invisible_conversation = Enum.any?(users, &User.blocks?(user, &1))
|
||||||
|
|
||||||
unless invisible_conversation do
|
|
||||||
User.increment_unread_conversation_count(conversation, user)
|
|
||||||
end
|
|
||||||
|
|
||||||
opts = Keyword.put(opts, :invisible_conversation, invisible_conversation)
|
opts = Keyword.put(opts, :invisible_conversation, invisible_conversation)
|
||||||
|
|
||||||
{:ok, participation} =
|
{:ok, participation} =
|
||||||
|
|
|
@ -63,21 +63,10 @@ defmodule Pleroma.Conversation.Participation do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_as_read(participation) do
|
def mark_as_read(%__MODULE__{} = participation) do
|
||||||
__MODULE__
|
participation
|
||||||
|> where(id: ^participation.id)
|
|> change(read: true)
|
||||||
|> update(set: [read: true])
|
|> Repo.update()
|
||||||
|> select([p], p)
|
|
||||||
|> Repo.update_all([])
|
|
||||||
|> case do
|
|
||||||
{1, [participation]} ->
|
|
||||||
participation = Repo.preload(participation, :user)
|
|
||||||
User.set_unread_conversation_count(participation.user)
|
|
||||||
{:ok, participation}
|
|
||||||
|
|
||||||
error ->
|
|
||||||
error
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_all_as_read(%User{local: true} = user, %User{} = target_user) do
|
def mark_all_as_read(%User{local: true} = user, %User{} = target_user) do
|
||||||
|
@ -93,7 +82,6 @@ defmodule Pleroma.Conversation.Participation do
|
||||||
|> update([p], set: [read: true])
|
|> update([p], set: [read: true])
|
||||||
|> Repo.update_all([])
|
|> Repo.update_all([])
|
||||||
|
|
||||||
{:ok, user} = User.set_unread_conversation_count(user)
|
|
||||||
{:ok, user, []}
|
{:ok, user, []}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -108,7 +96,6 @@ defmodule Pleroma.Conversation.Participation do
|
||||||
|> select([p], p)
|
|> select([p], p)
|
||||||
|> Repo.update_all([])
|
|> Repo.update_all([])
|
||||||
|
|
||||||
{:ok, user} = User.set_unread_conversation_count(user)
|
|
||||||
{:ok, user, participations}
|
{:ok, user, participations}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -220,6 +207,12 @@ defmodule Pleroma.Conversation.Participation do
|
||||||
{:ok, Repo.preload(participation, :recipients, force: true)}
|
{:ok, Repo.preload(participation, :recipients, force: true)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec unread_count(User.t()) :: integer()
|
||||||
|
def unread_count(%User{id: user_id}) do
|
||||||
|
from(q in __MODULE__, where: q.user_id == ^user_id and q.read == false)
|
||||||
|
|> Repo.aggregate(:count, :id)
|
||||||
|
end
|
||||||
|
|
||||||
def unread_conversation_count_for_user(user) do
|
def unread_conversation_count_for_user(user) do
|
||||||
from(p in __MODULE__,
|
from(p in __MODULE__,
|
||||||
where: p.user_id == ^user.id,
|
where: p.user_id == ^user.id,
|
||||||
|
|
|
@ -189,4 +189,30 @@ defmodule Pleroma.Emails.UserEmail do
|
||||||
|
|
||||||
Router.Helpers.subscription_url(Endpoint, :unsubscribe, token)
|
Router.Helpers.subscription_url(Endpoint, :unsubscribe, token)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def backup_is_ready_email(backup, admin_user_id \\ nil) do
|
||||||
|
%{user: user} = Pleroma.Repo.preload(backup, :user)
|
||||||
|
download_url = Pleroma.Web.PleromaAPI.BackupView.download_url(backup)
|
||||||
|
|
||||||
|
html_body =
|
||||||
|
if is_nil(admin_user_id) do
|
||||||
|
"""
|
||||||
|
<p>You requested a full backup of your Pleroma account. It's ready for download:</p>
|
||||||
|
<p><a href="#{download_url}">#{download_url}</a></p>
|
||||||
|
"""
|
||||||
|
else
|
||||||
|
admin = Pleroma.Repo.get(User, admin_user_id)
|
||||||
|
|
||||||
|
"""
|
||||||
|
<p>Admin @#{admin.nickname} requested a full backup of your Pleroma account. It's ready for download:</p>
|
||||||
|
<p><a href="#{download_url}">#{download_url}</a></p>
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
new()
|
||||||
|
|> to(recipient(user))
|
||||||
|
|> from(sender())
|
||||||
|
|> subject("Your account archive is ready")
|
||||||
|
|> html_body(html_body)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -594,7 +594,7 @@ defmodule Pleroma.Emoji.Pack do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp download_archive(url, sha) do
|
defp download_archive(url, sha) do
|
||||||
with {:ok, %{body: archive}} <- Tesla.get(url) do
|
with {:ok, %{body: archive}} <- Pleroma.HTTP.get(url) do
|
||||||
if Base.decode16!(sha) == :crypto.hash(:sha256, archive) do
|
if Base.decode16!(sha) == :crypto.hash(:sha256, archive) do
|
||||||
{:ok, archive}
|
{:ok, archive}
|
||||||
else
|
else
|
||||||
|
@ -617,7 +617,7 @@ defmodule Pleroma.Emoji.Pack do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp update_sha_and_save_metadata(pack, data) do
|
defp update_sha_and_save_metadata(pack, data) do
|
||||||
with {:ok, %{body: zip}} <- Tesla.get(data[:"fallback-src"]),
|
with {:ok, %{body: zip}} <- Pleroma.HTTP.get(data[:"fallback-src"]),
|
||||||
:ok <- validate_has_all_files(pack, zip) do
|
:ok <- validate_has_all_files(pack, zip) do
|
||||||
fallback_sha = :sha256 |> :crypto.hash(zip) |> Base.encode16()
|
fallback_sha = :sha256 |> :crypto.hash(zip) |> Base.encode16()
|
||||||
|
|
||||||
|
|
19
lib/pleroma/helpers/inet_helper.ex
Normal file
19
lib/pleroma/helpers/inet_helper.ex
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Helpers.InetHelper do
|
||||||
|
def parse_address(ip) when is_tuple(ip) do
|
||||||
|
{:ok, ip}
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_address(ip) when is_binary(ip) do
|
||||||
|
ip
|
||||||
|
|> String.to_charlist()
|
||||||
|
|> parse_address()
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_address(ip) do
|
||||||
|
:inet.parse_address(ip)
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,120 +0,0 @@
|
||||||
# Pleroma: A lightweight social networking server
|
|
||||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
|
|
||||||
defmodule Pleroma.MIME do
|
|
||||||
@moduledoc """
|
|
||||||
Returns the mime-type of a binary and optionally a normalized file-name.
|
|
||||||
"""
|
|
||||||
@default "application/octet-stream"
|
|
||||||
@read_bytes 35
|
|
||||||
|
|
||||||
@spec file_mime_type(String.t(), String.t()) ::
|
|
||||||
{:ok, content_type :: String.t(), filename :: String.t()} | {:error, any()} | :error
|
|
||||||
def file_mime_type(path, filename) do
|
|
||||||
with {:ok, content_type} <- file_mime_type(path),
|
|
||||||
filename <- fix_extension(filename, content_type) do
|
|
||||||
{:ok, content_type, filename}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec file_mime_type(String.t()) :: {:ok, String.t()} | {:error, any()} | :error
|
|
||||||
def file_mime_type(filename) do
|
|
||||||
File.open(filename, [:read], fn f ->
|
|
||||||
check_mime_type(IO.binread(f, @read_bytes))
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
def bin_mime_type(binary, filename) do
|
|
||||||
with {:ok, content_type} <- bin_mime_type(binary),
|
|
||||||
filename <- fix_extension(filename, content_type) do
|
|
||||||
{:ok, content_type, filename}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec bin_mime_type(binary()) :: {:ok, String.t()} | :error
|
|
||||||
def bin_mime_type(<<head::binary-size(@read_bytes), _::binary>>) do
|
|
||||||
{:ok, check_mime_type(head)}
|
|
||||||
end
|
|
||||||
|
|
||||||
def bin_mime_type(_), do: :error
|
|
||||||
|
|
||||||
def mime_type(<<_::binary>>), do: {:ok, @default}
|
|
||||||
|
|
||||||
defp fix_extension(filename, content_type) do
|
|
||||||
parts = String.split(filename, ".")
|
|
||||||
|
|
||||||
new_filename =
|
|
||||||
if length(parts) > 1 do
|
|
||||||
Enum.drop(parts, -1) |> Enum.join(".")
|
|
||||||
else
|
|
||||||
Enum.join(parts)
|
|
||||||
end
|
|
||||||
|
|
||||||
cond do
|
|
||||||
content_type == "application/octet-stream" ->
|
|
||||||
filename
|
|
||||||
|
|
||||||
ext = List.first(MIME.extensions(content_type)) ->
|
|
||||||
new_filename <> "." <> ext
|
|
||||||
|
|
||||||
true ->
|
|
||||||
Enum.join([new_filename, String.split(content_type, "/") |> List.last()], ".")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, _::binary>>) do
|
|
||||||
"image/png"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x47, 0x49, 0x46, 0x38, _, 0x61, _::binary>>) do
|
|
||||||
"image/gif"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0xFF, 0xD8, 0xFF, _::binary>>) do
|
|
||||||
"image/jpeg"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x1A, 0x45, 0xDF, 0xA3, _::binary>>) do
|
|
||||||
"video/webm"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x00, 0x00, 0x00, _, 0x66, 0x74, 0x79, 0x70, _::binary>>) do
|
|
||||||
"video/mp4"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x49, 0x44, 0x33, _::binary>>) do
|
|
||||||
"audio/mpeg"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<255, 251, _, 68, 0, 0, 0, 0, _::binary>>) do
|
|
||||||
"audio/mpeg"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(
|
|
||||||
<<0x4F, 0x67, 0x67, 0x53, 0x00, 0x02, 0x00, 0x00, _::size(160), 0x80, 0x74, 0x68, 0x65,
|
|
||||||
0x6F, 0x72, 0x61, _::binary>>
|
|
||||||
) do
|
|
||||||
"video/ogg"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<0x4F, 0x67, 0x67, 0x53, 0x00, 0x02, 0x00, 0x00, _::binary>>) do
|
|
||||||
"audio/ogg"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<"RIFF", _::binary-size(4), "WAVE", _::binary>>) do
|
|
||||||
"audio/wav"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<"RIFF", _::binary-size(4), "WEBP", _::binary>>) do
|
|
||||||
"image/webp"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(<<"RIFF", _::binary-size(4), "AVI.", _::binary>>) do
|
|
||||||
"video/avi"
|
|
||||||
end
|
|
||||||
|
|
||||||
defp check_mime_type(_) do
|
|
||||||
@default
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -655,6 +655,16 @@ defmodule Pleroma.ModerationLog do
|
||||||
"@#{actor_nickname} deleted chat message ##{subject_id}"
|
"@#{actor_nickname} deleted chat message ##{subject_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_log_entry_message(%ModerationLog{
|
||||||
|
data: %{
|
||||||
|
"actor" => %{"nickname" => actor_nickname},
|
||||||
|
"action" => "create_backup",
|
||||||
|
"subject" => %{"nickname" => user_nickname}
|
||||||
|
}
|
||||||
|
}) do
|
||||||
|
"@#{actor_nickname} requested account backup for @#{user_nickname}"
|
||||||
|
end
|
||||||
|
|
||||||
defp nicknames_to_string(nicknames) do
|
defp nicknames_to_string(nicknames) do
|
||||||
nicknames
|
nicknames
|
||||||
|> Enum.map(&"@#{&1}")
|
|> Enum.map(&"@#{&1}")
|
||||||
|
|
|
@ -66,6 +66,7 @@ defmodule Pleroma.Upload do
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()}
|
@spec store(source, options :: [option()]) :: {:ok, Map.t()} | {:error, any()}
|
||||||
|
@doc "Store a file. If using a `Plug.Upload{}` as the source, be sure to use `Majic.Plug` to ensure its content_type and filename is correct."
|
||||||
def store(upload, opts \\ []) do
|
def store(upload, opts \\ []) do
|
||||||
opts = get_opts(opts)
|
opts = get_opts(opts)
|
||||||
|
|
||||||
|
@ -139,14 +140,13 @@ defmodule Pleroma.Upload do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp prepare_upload(%Plug.Upload{} = file, opts) do
|
defp prepare_upload(%Plug.Upload{} = file, opts) do
|
||||||
with :ok <- check_file_size(file.path, opts.size_limit),
|
with :ok <- check_file_size(file.path, opts.size_limit) do
|
||||||
{:ok, content_type, name} <- Pleroma.MIME.file_mime_type(file.path, file.filename) do
|
|
||||||
{:ok,
|
{:ok,
|
||||||
%__MODULE__{
|
%__MODULE__{
|
||||||
id: UUID.generate(),
|
id: UUID.generate(),
|
||||||
name: name,
|
name: file.filename,
|
||||||
tempfile: file.path,
|
tempfile: file.path,
|
||||||
content_type: content_type
|
content_type: file.content_type
|
||||||
}}
|
}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -154,16 +154,17 @@ defmodule Pleroma.Upload do
|
||||||
defp prepare_upload(%{img: "data:image/" <> image_data}, opts) do
|
defp prepare_upload(%{img: "data:image/" <> image_data}, opts) do
|
||||||
parsed = Regex.named_captures(~r/(?<filetype>jpeg|png|gif);base64,(?<data>.*)/, image_data)
|
parsed = Regex.named_captures(~r/(?<filetype>jpeg|png|gif);base64,(?<data>.*)/, image_data)
|
||||||
data = Base.decode64!(parsed["data"], ignore: :whitespace)
|
data = Base.decode64!(parsed["data"], ignore: :whitespace)
|
||||||
hash = String.downcase(Base.encode16(:crypto.hash(:sha256, data)))
|
hash = Base.encode16(:crypto.hash(:sha256, data), lower: true)
|
||||||
|
|
||||||
with :ok <- check_binary_size(data, opts.size_limit),
|
with :ok <- check_binary_size(data, opts.size_limit),
|
||||||
tmp_path <- tempfile_for_image(data),
|
tmp_path <- tempfile_for_image(data),
|
||||||
{:ok, content_type, name} <-
|
{:ok, %{mime_type: content_type}} <-
|
||||||
Pleroma.MIME.bin_mime_type(data, hash <> "." <> parsed["filetype"]) do
|
Majic.perform({:bytes, data}, pool: Pleroma.MajicPool),
|
||||||
|
[ext | _] <- MIME.extensions(content_type) do
|
||||||
{:ok,
|
{:ok,
|
||||||
%__MODULE__{
|
%__MODULE__{
|
||||||
id: UUID.generate(),
|
id: UUID.generate(),
|
||||||
name: name,
|
name: hash <> "." <> ext,
|
||||||
tempfile: tmp_path,
|
tempfile: tmp_path,
|
||||||
content_type: content_type
|
content_type: content_type
|
||||||
}}
|
}}
|
||||||
|
@ -172,7 +173,7 @@ defmodule Pleroma.Upload do
|
||||||
|
|
||||||
# For Mix.Tasks.MigrateLocalUploads
|
# For Mix.Tasks.MigrateLocalUploads
|
||||||
defp prepare_upload(%__MODULE__{tempfile: path} = upload, _opts) do
|
defp prepare_upload(%__MODULE__{tempfile: path} = upload, _opts) do
|
||||||
with {:ok, content_type} <- Pleroma.MIME.file_mime_type(path) do
|
with {:ok, %{mime_type: content_type}} <- Majic.perform(path, pool: Pleroma.MajicPool) do
|
||||||
{:ok, %__MODULE__{upload | content_type: content_type}}
|
{:ok, %__MODULE__{upload | content_type: content_type}}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -107,7 +107,7 @@ defmodule Pleroma.User do
|
||||||
field(:note_count, :integer, default: 0)
|
field(:note_count, :integer, default: 0)
|
||||||
field(:follower_count, :integer, default: 0)
|
field(:follower_count, :integer, default: 0)
|
||||||
field(:following_count, :integer, default: 0)
|
field(:following_count, :integer, default: 0)
|
||||||
field(:locked, :boolean, default: false)
|
field(:is_locked, :boolean, default: false)
|
||||||
field(:confirmation_pending, :boolean, default: false)
|
field(:confirmation_pending, :boolean, default: false)
|
||||||
field(:password_reset_pending, :boolean, default: false)
|
field(:password_reset_pending, :boolean, default: false)
|
||||||
field(:approval_pending, :boolean, default: false)
|
field(:approval_pending, :boolean, default: false)
|
||||||
|
@ -128,7 +128,6 @@ defmodule Pleroma.User do
|
||||||
field(:hide_followers, :boolean, default: false)
|
field(:hide_followers, :boolean, default: false)
|
||||||
field(:hide_follows, :boolean, default: false)
|
field(:hide_follows, :boolean, default: false)
|
||||||
field(:hide_favorites, :boolean, default: true)
|
field(:hide_favorites, :boolean, default: true)
|
||||||
field(:unread_conversation_count, :integer, default: 0)
|
|
||||||
field(:pinned_activities, {:array, :string}, default: [])
|
field(:pinned_activities, {:array, :string}, default: [])
|
||||||
field(:email_notifications, :map, default: %{"digest" => false})
|
field(:email_notifications, :map, default: %{"digest" => false})
|
||||||
field(:mascot, :map, default: nil)
|
field(:mascot, :map, default: nil)
|
||||||
|
@ -136,7 +135,7 @@ defmodule Pleroma.User do
|
||||||
field(:pleroma_settings_store, :map, default: %{})
|
field(:pleroma_settings_store, :map, default: %{})
|
||||||
field(:fields, {:array, :map}, default: [])
|
field(:fields, {:array, :map}, default: [])
|
||||||
field(:raw_fields, {:array, :map}, default: [])
|
field(:raw_fields, {:array, :map}, default: [])
|
||||||
field(:discoverable, :boolean, default: false)
|
field(:is_discoverable, :boolean, default: false)
|
||||||
field(:invisible, :boolean, default: false)
|
field(:invisible, :boolean, default: false)
|
||||||
field(:allow_following_move, :boolean, default: true)
|
field(:allow_following_move, :boolean, default: true)
|
||||||
field(:skip_thread_containment, :boolean, default: false)
|
field(:skip_thread_containment, :boolean, default: false)
|
||||||
|
@ -426,7 +425,6 @@ defmodule Pleroma.User do
|
||||||
params,
|
params,
|
||||||
[
|
[
|
||||||
:bio,
|
:bio,
|
||||||
:name,
|
|
||||||
:emoji,
|
:emoji,
|
||||||
:ap_id,
|
:ap_id,
|
||||||
:inbox,
|
:inbox,
|
||||||
|
@ -436,7 +434,7 @@ defmodule Pleroma.User do
|
||||||
:avatar,
|
:avatar,
|
||||||
:ap_enabled,
|
:ap_enabled,
|
||||||
:banner,
|
:banner,
|
||||||
:locked,
|
:is_locked,
|
||||||
:last_refreshed_at,
|
:last_refreshed_at,
|
||||||
:uri,
|
:uri,
|
||||||
:follower_address,
|
:follower_address,
|
||||||
|
@ -448,14 +446,16 @@ defmodule Pleroma.User do
|
||||||
:follower_count,
|
:follower_count,
|
||||||
:fields,
|
:fields,
|
||||||
:following_count,
|
:following_count,
|
||||||
:discoverable,
|
:is_discoverable,
|
||||||
:invisible,
|
:invisible,
|
||||||
:actor_type,
|
:actor_type,
|
||||||
:also_known_as,
|
:also_known_as,
|
||||||
:accepts_chat_messages
|
:accepts_chat_messages
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|> validate_required([:name, :ap_id])
|
|> cast(params, [:name], empty_values: [])
|
||||||
|
|> validate_required([:ap_id])
|
||||||
|
|> validate_required([:name], trim: false)
|
||||||
|> unique_constraint(:nickname)
|
|> unique_constraint(:nickname)
|
||||||
|> validate_format(:nickname, @email_regex)
|
|> validate_format(:nickname, @email_regex)
|
||||||
|> validate_length(:bio, max: bio_limit)
|
|> validate_length(:bio, max: bio_limit)
|
||||||
|
@ -479,7 +479,7 @@ defmodule Pleroma.User do
|
||||||
:public_key,
|
:public_key,
|
||||||
:inbox,
|
:inbox,
|
||||||
:shared_inbox,
|
:shared_inbox,
|
||||||
:locked,
|
:is_locked,
|
||||||
:no_rich_text,
|
:no_rich_text,
|
||||||
:default_scope,
|
:default_scope,
|
||||||
:banner,
|
:banner,
|
||||||
|
@ -495,7 +495,7 @@ defmodule Pleroma.User do
|
||||||
:fields,
|
:fields,
|
||||||
:raw_fields,
|
:raw_fields,
|
||||||
:pleroma_settings_store,
|
:pleroma_settings_store,
|
||||||
:discoverable,
|
:is_discoverable,
|
||||||
:actor_type,
|
:actor_type,
|
||||||
:also_known_as,
|
:also_known_as,
|
||||||
:accepts_chat_messages
|
:accepts_chat_messages
|
||||||
|
@ -765,6 +765,16 @@ defmodule Pleroma.User do
|
||||||
follow_all(user, autofollowed_users)
|
follow_all(user, autofollowed_users)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp autofollowing_users(user) do
|
||||||
|
candidates = Config.get([:instance, :autofollowing_nicknames])
|
||||||
|
|
||||||
|
User.Query.build(%{nickname: candidates, local: true, deactivated: false})
|
||||||
|
|> Repo.all()
|
||||||
|
|> Enum.each(&follow(&1, user, :follow_accept))
|
||||||
|
|
||||||
|
{:ok, :success}
|
||||||
|
end
|
||||||
|
|
||||||
@doc "Inserts provided changeset, performs post-registration actions (confirmation email sending etc.)"
|
@doc "Inserts provided changeset, performs post-registration actions (confirmation email sending etc.)"
|
||||||
def register(%Ecto.Changeset{} = changeset) do
|
def register(%Ecto.Changeset{} = changeset) do
|
||||||
with {:ok, user} <- Repo.insert(changeset) do
|
with {:ok, user} <- Repo.insert(changeset) do
|
||||||
|
@ -774,6 +784,7 @@ defmodule Pleroma.User do
|
||||||
|
|
||||||
def post_register_action(%User{} = user) do
|
def post_register_action(%User{} = user) do
|
||||||
with {:ok, user} <- autofollow_users(user),
|
with {:ok, user} <- autofollow_users(user),
|
||||||
|
{:ok, _} <- autofollowing_users(user),
|
||||||
{:ok, user} <- set_cache(user),
|
{:ok, user} <- set_cache(user),
|
||||||
{:ok, _} <- send_welcome_email(user),
|
{:ok, _} <- send_welcome_email(user),
|
||||||
{:ok, _} <- send_welcome_message(user),
|
{:ok, _} <- send_welcome_message(user),
|
||||||
|
@ -847,7 +858,7 @@ defmodule Pleroma.User do
|
||||||
@spec maybe_direct_follow(User.t(), User.t()) :: {:ok, User.t()} | {:error, String.t()}
|
@spec maybe_direct_follow(User.t(), User.t()) :: {:ok, User.t()} | {:error, String.t()}
|
||||||
|
|
||||||
# "Locked" (self-locked) users demand explicit authorization of follow requests
|
# "Locked" (self-locked) users demand explicit authorization of follow requests
|
||||||
def maybe_direct_follow(%User{} = follower, %User{local: true, locked: true} = followed) do
|
def maybe_direct_follow(%User{} = follower, %User{local: true, is_locked: true} = followed) do
|
||||||
follow(follower, followed, :follow_pending)
|
follow(follower, followed, :follow_pending)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -954,7 +965,7 @@ defmodule Pleroma.User do
|
||||||
end
|
end
|
||||||
|
|
||||||
def locked?(%User{} = user) do
|
def locked?(%User{} = user) do
|
||||||
user.locked || false
|
user.is_locked || false
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_by_id(id) do
|
def get_by_id(id) do
|
||||||
|
@ -1293,47 +1304,6 @@ defmodule Pleroma.User do
|
||||||
|> update_and_set_cache()
|
|> update_and_set_cache()
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_unread_conversation_count(%User{local: true} = user) do
|
|
||||||
unread_query = Participation.unread_conversation_count_for_user(user)
|
|
||||||
|
|
||||||
User
|
|
||||||
|> join(:inner, [u], p in subquery(unread_query))
|
|
||||||
|> update([u, p],
|
|
||||||
set: [unread_conversation_count: p.count]
|
|
||||||
)
|
|
||||||
|> where([u], u.id == ^user.id)
|
|
||||||
|> select([u], u)
|
|
||||||
|> Repo.update_all([])
|
|
||||||
|> case do
|
|
||||||
{1, [user]} -> set_cache(user)
|
|
||||||
_ -> {:error, user}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_unread_conversation_count(user), do: {:ok, user}
|
|
||||||
|
|
||||||
def increment_unread_conversation_count(conversation, %User{local: true} = user) do
|
|
||||||
unread_query =
|
|
||||||
Participation.unread_conversation_count_for_user(user)
|
|
||||||
|> where([p], p.conversation_id == ^conversation.id)
|
|
||||||
|
|
||||||
User
|
|
||||||
|> join(:inner, [u], p in subquery(unread_query))
|
|
||||||
|> update([u, p],
|
|
||||||
inc: [unread_conversation_count: 1]
|
|
||||||
)
|
|
||||||
|> where([u], u.id == ^user.id)
|
|
||||||
|> where([u, p], p.count == 0)
|
|
||||||
|> select([u], u)
|
|
||||||
|> Repo.update_all([])
|
|
||||||
|> case do
|
|
||||||
{1, [user]} -> set_cache(user)
|
|
||||||
_ -> {:error, user}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def increment_unread_conversation_count(_, user), do: {:ok, user}
|
|
||||||
|
|
||||||
@spec get_users_from_set([String.t()], keyword()) :: [User.t()]
|
@spec get_users_from_set([String.t()], keyword()) :: [User.t()]
|
||||||
def get_users_from_set(ap_ids, opts \\ []) do
|
def get_users_from_set(ap_ids, opts \\ []) do
|
||||||
local_only = Keyword.get(opts, :local_only, true)
|
local_only = Keyword.get(opts, :local_only, true)
|
||||||
|
@ -1601,7 +1571,7 @@ defmodule Pleroma.User do
|
||||||
note_count: 0,
|
note_count: 0,
|
||||||
follower_count: 0,
|
follower_count: 0,
|
||||||
following_count: 0,
|
following_count: 0,
|
||||||
locked: false,
|
is_locked: false,
|
||||||
confirmation_pending: false,
|
confirmation_pending: false,
|
||||||
password_reset_pending: false,
|
password_reset_pending: false,
|
||||||
approval_pending: false,
|
approval_pending: false,
|
||||||
|
@ -1618,7 +1588,7 @@ defmodule Pleroma.User do
|
||||||
pleroma_settings_store: %{},
|
pleroma_settings_store: %{},
|
||||||
fields: [],
|
fields: [],
|
||||||
raw_fields: [],
|
raw_fields: [],
|
||||||
discoverable: false,
|
is_discoverable: false,
|
||||||
also_known_as: []
|
also_known_as: []
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
258
lib/pleroma/user/backup.ex
Normal file
258
lib/pleroma/user/backup.ex
Normal file
|
@ -0,0 +1,258 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.User.Backup do
|
||||||
|
use Ecto.Schema
|
||||||
|
|
||||||
|
import Ecto.Changeset
|
||||||
|
import Ecto.Query
|
||||||
|
import Pleroma.Web.Gettext
|
||||||
|
|
||||||
|
require Pleroma.Constants
|
||||||
|
|
||||||
|
alias Pleroma.Activity
|
||||||
|
alias Pleroma.Bookmark
|
||||||
|
alias Pleroma.Repo
|
||||||
|
alias Pleroma.User
|
||||||
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
|
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||||
|
alias Pleroma.Web.ActivityPub.UserView
|
||||||
|
alias Pleroma.Workers.BackupWorker
|
||||||
|
|
||||||
|
schema "backups" do
|
||||||
|
field(:content_type, :string)
|
||||||
|
field(:file_name, :string)
|
||||||
|
field(:file_size, :integer, default: 0)
|
||||||
|
field(:processed, :boolean, default: false)
|
||||||
|
|
||||||
|
belongs_to(:user, User, type: FlakeId.Ecto.CompatType)
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
def create(user, admin_id \\ nil) do
|
||||||
|
with :ok <- validate_email_enabled(),
|
||||||
|
:ok <- validate_user_email(user),
|
||||||
|
:ok <- validate_limit(user, admin_id),
|
||||||
|
{:ok, backup} <- user |> new() |> Repo.insert() do
|
||||||
|
BackupWorker.process(backup, admin_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def new(user) do
|
||||||
|
rand_str = :crypto.strong_rand_bytes(32) |> Base.url_encode64(padding: false)
|
||||||
|
datetime = Calendar.NaiveDateTime.Format.iso8601_basic(NaiveDateTime.utc_now())
|
||||||
|
name = "archive-#{user.nickname}-#{datetime}-#{rand_str}.zip"
|
||||||
|
|
||||||
|
%__MODULE__{
|
||||||
|
user_id: user.id,
|
||||||
|
content_type: "application/zip",
|
||||||
|
file_name: name
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete(backup) do
|
||||||
|
uploader = Pleroma.Config.get([Pleroma.Upload, :uploader])
|
||||||
|
|
||||||
|
with :ok <- uploader.delete_file(Path.join("backups", backup.file_name)) do
|
||||||
|
Repo.delete(backup)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp validate_limit(_user, admin_id) when is_binary(admin_id), do: :ok
|
||||||
|
|
||||||
|
defp validate_limit(user, nil) do
|
||||||
|
case get_last(user.id) do
|
||||||
|
%__MODULE__{inserted_at: inserted_at} ->
|
||||||
|
days = Pleroma.Config.get([__MODULE__, :limit_days])
|
||||||
|
diff = Timex.diff(NaiveDateTime.utc_now(), inserted_at, :days)
|
||||||
|
|
||||||
|
if diff > days do
|
||||||
|
:ok
|
||||||
|
else
|
||||||
|
{:error,
|
||||||
|
dngettext(
|
||||||
|
"errors",
|
||||||
|
"Last export was less than a day ago",
|
||||||
|
"Last export was less than %{days} days ago",
|
||||||
|
days,
|
||||||
|
days: days
|
||||||
|
)}
|
||||||
|
end
|
||||||
|
|
||||||
|
nil ->
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp validate_email_enabled do
|
||||||
|
if Pleroma.Config.get([Pleroma.Emails.Mailer, :enabled]) do
|
||||||
|
:ok
|
||||||
|
else
|
||||||
|
{:error, dgettext("errors", "Backups require enabled email")}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp validate_user_email(%User{email: nil}) do
|
||||||
|
{:error, dgettext("errors", "Email is required")}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp validate_user_email(%User{email: email}) when is_binary(email), do: :ok
|
||||||
|
|
||||||
|
def get_last(user_id) do
|
||||||
|
__MODULE__
|
||||||
|
|> where(user_id: ^user_id)
|
||||||
|
|> order_by(desc: :id)
|
||||||
|
|> limit(1)
|
||||||
|
|> Repo.one()
|
||||||
|
end
|
||||||
|
|
||||||
|
def list(%User{id: user_id}) do
|
||||||
|
__MODULE__
|
||||||
|
|> where(user_id: ^user_id)
|
||||||
|
|> order_by(desc: :id)
|
||||||
|
|> Repo.all()
|
||||||
|
end
|
||||||
|
|
||||||
|
def remove_outdated(%__MODULE__{id: latest_id, user_id: user_id}) do
|
||||||
|
__MODULE__
|
||||||
|
|> where(user_id: ^user_id)
|
||||||
|
|> where([b], b.id != ^latest_id)
|
||||||
|
|> Repo.all()
|
||||||
|
|> Enum.each(&BackupWorker.delete/1)
|
||||||
|
end
|
||||||
|
|
||||||
|
def get(id), do: Repo.get(__MODULE__, id)
|
||||||
|
|
||||||
|
def process(%__MODULE__{} = backup) do
|
||||||
|
with {:ok, zip_file} <- export(backup),
|
||||||
|
{:ok, %{size: size}} <- File.stat(zip_file),
|
||||||
|
{:ok, _upload} <- upload(backup, zip_file) do
|
||||||
|
backup
|
||||||
|
|> cast(%{file_size: size, processed: true}, [:file_size, :processed])
|
||||||
|
|> Repo.update()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@files ['actor.json', 'outbox.json', 'likes.json', 'bookmarks.json']
|
||||||
|
def export(%__MODULE__{} = backup) do
|
||||||
|
backup = Repo.preload(backup, :user)
|
||||||
|
name = String.trim_trailing(backup.file_name, ".zip")
|
||||||
|
dir = dir(name)
|
||||||
|
|
||||||
|
with :ok <- File.mkdir(dir),
|
||||||
|
:ok <- actor(dir, backup.user),
|
||||||
|
:ok <- statuses(dir, backup.user),
|
||||||
|
:ok <- likes(dir, backup.user),
|
||||||
|
:ok <- bookmarks(dir, backup.user),
|
||||||
|
{:ok, zip_path} <- :zip.create(String.to_charlist(dir <> ".zip"), @files, cwd: dir),
|
||||||
|
{:ok, _} <- File.rm_rf(dir) do
|
||||||
|
{:ok, to_string(zip_path)}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def dir(name) do
|
||||||
|
dir = Pleroma.Config.get([__MODULE__, :dir]) || System.tmp_dir!()
|
||||||
|
Path.join(dir, name)
|
||||||
|
end
|
||||||
|
|
||||||
|
def upload(%__MODULE__{} = backup, zip_path) do
|
||||||
|
uploader = Pleroma.Config.get([Pleroma.Upload, :uploader])
|
||||||
|
|
||||||
|
upload = %Pleroma.Upload{
|
||||||
|
name: backup.file_name,
|
||||||
|
tempfile: zip_path,
|
||||||
|
content_type: backup.content_type,
|
||||||
|
path: Path.join("backups", backup.file_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
with {:ok, _} <- Pleroma.Uploaders.Uploader.put_file(uploader, upload),
|
||||||
|
:ok <- File.rm(zip_path) do
|
||||||
|
{:ok, upload}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp actor(dir, user) do
|
||||||
|
with {:ok, json} <-
|
||||||
|
UserView.render("user.json", %{user: user})
|
||||||
|
|> Map.merge(%{"likes" => "likes.json", "bookmarks" => "bookmarks.json"})
|
||||||
|
|> Jason.encode() do
|
||||||
|
File.write(Path.join(dir, "actor.json"), json)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp write_header(file, name) do
|
||||||
|
IO.write(
|
||||||
|
file,
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
|
"id": "#{name}.json",
|
||||||
|
"type": "OrderedCollection",
|
||||||
|
"orderedItems": [
|
||||||
|
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp write(query, dir, name, fun) do
|
||||||
|
path = Path.join(dir, "#{name}.json")
|
||||||
|
|
||||||
|
with {:ok, file} <- File.open(path, [:write, :utf8]),
|
||||||
|
:ok <- write_header(file, name) do
|
||||||
|
total =
|
||||||
|
query
|
||||||
|
|> Pleroma.Repo.chunk_stream(100)
|
||||||
|
|> Enum.reduce(0, fn i, acc ->
|
||||||
|
with {:ok, data} <- fun.(i),
|
||||||
|
{:ok, str} <- Jason.encode(data),
|
||||||
|
:ok <- IO.write(file, str <> ",\n") do
|
||||||
|
acc + 1
|
||||||
|
else
|
||||||
|
_ -> acc
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
with :ok <- :file.pwrite(file, {:eof, -2}, "\n],\n \"totalItems\": #{total}}") do
|
||||||
|
File.close(file)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
defp bookmarks(dir, %{id: user_id} = _user) do
|
||||||
|
Bookmark
|
||||||
|
|> where(user_id: ^user_id)
|
||||||
|
|> join(:inner, [b], activity in assoc(b, :activity))
|
||||||
|
|> select([b, a], %{id: b.id, object: fragment("(?)->>'object'", a.data)})
|
||||||
|
|> write(dir, "bookmarks", fn a -> {:ok, a.object} end)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp likes(dir, user) do
|
||||||
|
user.ap_id
|
||||||
|
|> Activity.Queries.by_actor()
|
||||||
|
|> Activity.Queries.by_type("Like")
|
||||||
|
|> select([like], %{id: like.id, object: fragment("(?)->>'object'", like.data)})
|
||||||
|
|> write(dir, "likes", fn a -> {:ok, a.object} end)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp statuses(dir, user) do
|
||||||
|
opts =
|
||||||
|
%{}
|
||||||
|
|> Map.put(:type, ["Create", "Announce"])
|
||||||
|
|> Map.put(:actor_id, user.ap_id)
|
||||||
|
|
||||||
|
[
|
||||||
|
[Pleroma.Constants.as_public(), user.ap_id],
|
||||||
|
User.following(user),
|
||||||
|
Pleroma.List.memberships(user)
|
||||||
|
]
|
||||||
|
|> Enum.concat()
|
||||||
|
|> ActivityPub.fetch_activities_query(opts)
|
||||||
|
|> write(dir, "outbox", fn a ->
|
||||||
|
with {:ok, activity} <- Transmogrifier.prepare_outgoing(a.data) do
|
||||||
|
{:ok, Map.delete(activity, "@context")}
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
|
@ -43,6 +43,7 @@ defmodule Pleroma.User.Query do
|
||||||
active: boolean(),
|
active: boolean(),
|
||||||
deactivated: boolean(),
|
deactivated: boolean(),
|
||||||
need_approval: boolean(),
|
need_approval: boolean(),
|
||||||
|
unconfirmed: boolean(),
|
||||||
is_admin: boolean(),
|
is_admin: boolean(),
|
||||||
is_moderator: boolean(),
|
is_moderator: boolean(),
|
||||||
super_users: boolean(),
|
super_users: boolean(),
|
||||||
|
@ -55,7 +56,8 @@ defmodule Pleroma.User.Query do
|
||||||
ap_id: [String.t()],
|
ap_id: [String.t()],
|
||||||
order_by: term(),
|
order_by: term(),
|
||||||
select: term(),
|
select: term(),
|
||||||
limit: pos_integer()
|
limit: pos_integer(),
|
||||||
|
actor_types: [String.t()]
|
||||||
}
|
}
|
||||||
| map()
|
| map()
|
||||||
|
|
||||||
|
@ -114,6 +116,10 @@ defmodule Pleroma.User.Query do
|
||||||
where(query, [u], u.is_admin == ^bool)
|
where(query, [u], u.is_admin == ^bool)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp compose_query({:actor_types, actor_types}, query) when is_list(actor_types) do
|
||||||
|
where(query, [u], u.actor_type in ^actor_types)
|
||||||
|
end
|
||||||
|
|
||||||
defp compose_query({:is_moderator, bool}, query) do
|
defp compose_query({:is_moderator, bool}, query) do
|
||||||
where(query, [u], u.is_moderator == ^bool)
|
where(query, [u], u.is_moderator == ^bool)
|
||||||
end
|
end
|
||||||
|
@ -156,6 +162,10 @@ defmodule Pleroma.User.Query do
|
||||||
where(query, [u], u.approval_pending)
|
where(query, [u], u.approval_pending)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp compose_query({:unconfirmed, _}, query) do
|
||||||
|
where(query, [u], u.confirmation_pending)
|
||||||
|
end
|
||||||
|
|
||||||
defp compose_query({:followers, %User{id: id}}, query) do
|
defp compose_query({:followers, %User{id: id}}, query) do
|
||||||
query
|
query
|
||||||
|> where([u], u.id != ^id)
|
|> where([u], u.id != ^id)
|
||||||
|
|
|
@ -164,7 +164,7 @@ defmodule Pleroma.User.Search do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp filter_discoverable_users(query) do
|
defp filter_discoverable_users(query) do
|
||||||
from(q in query, where: q.discoverable == true)
|
from(q in query, where: q.is_discoverable == true)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp filter_internal_users(query) do
|
defp filter_internal_users(query) do
|
||||||
|
|
|
@ -172,7 +172,7 @@ defmodule Pleroma.Web do
|
||||||
def channel do
|
def channel do
|
||||||
quote do
|
quote do
|
||||||
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
# credo:disable-for-next-line Credo.Check.Consistency.MultiAliasImportRequireUse
|
||||||
use Phoenix.Channel
|
import Phoenix.Channel
|
||||||
import Pleroma.Web.Gettext
|
import Pleroma.Web.Gettext
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -827,7 +827,14 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
query =
|
query =
|
||||||
from([activity] in query,
|
from([activity] in query,
|
||||||
where: fragment("not (? = ANY(?))", activity.actor, ^mutes),
|
where: fragment("not (? = ANY(?))", activity.actor, ^mutes),
|
||||||
where: fragment("not (?->'to' \\?| ?)", activity.data, ^mutes)
|
where:
|
||||||
|
fragment(
|
||||||
|
"not (?->'to' \\?| ?) or ? = ?",
|
||||||
|
activity.data,
|
||||||
|
^mutes,
|
||||||
|
activity.actor,
|
||||||
|
^user.ap_id
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
unless opts[:skip_preload] do
|
unless opts[:skip_preload] do
|
||||||
|
@ -1223,11 +1230,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
{String.trim(name, ":"), url}
|
{String.trim(name, ":"), url}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
locked = data["manuallyApprovesFollowers"] || false
|
is_locked = data["manuallyApprovesFollowers"] || false
|
||||||
capabilities = data["capabilities"] || %{}
|
capabilities = data["capabilities"] || %{}
|
||||||
accepts_chat_messages = capabilities["acceptsChatMessages"]
|
accepts_chat_messages = capabilities["acceptsChatMessages"]
|
||||||
data = Transmogrifier.maybe_fix_user_object(data)
|
data = Transmogrifier.maybe_fix_user_object(data)
|
||||||
discoverable = data["discoverable"] || false
|
is_discoverable = data["discoverable"] || false
|
||||||
invisible = data["invisible"] || false
|
invisible = data["invisible"] || false
|
||||||
actor_type = data["type"] || "Person"
|
actor_type = data["type"] || "Person"
|
||||||
|
|
||||||
|
@ -1252,8 +1259,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
banner: banner,
|
banner: banner,
|
||||||
fields: fields,
|
fields: fields,
|
||||||
emoji: emojis,
|
emoji: emojis,
|
||||||
locked: locked,
|
is_locked: is_locked,
|
||||||
discoverable: discoverable,
|
is_discoverable: is_discoverable,
|
||||||
invisible: invisible,
|
invisible: invisible,
|
||||||
avatar: avatar,
|
avatar: avatar,
|
||||||
name: data["name"],
|
name: data["name"],
|
||||||
|
@ -1366,6 +1373,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
{:ok, data} <- user_data_from_user_object(data) do
|
{:ok, data} <- user_data_from_user_object(data) do
|
||||||
{:ok, maybe_update_follow_information(data)}
|
{:ok, maybe_update_follow_information(data)}
|
||||||
else
|
else
|
||||||
|
# If this has been deleted, only log a debug and not an error
|
||||||
{:error, "Object has been deleted" = e} ->
|
{:error, "Object has been deleted" = e} ->
|
||||||
Logger.debug("Could not decode user at fetch #{ap_id}, #{inspect(e)}")
|
Logger.debug("Could not decode user at fetch #{ap_id}, #{inspect(e)}")
|
||||||
{:error, e}
|
{:error, e}
|
||||||
|
|
|
@ -45,6 +45,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
||||||
when action in [:read_inbox, :update_outbox, :whoami, :upload_media]
|
when action in [:read_inbox, :update_outbox, :whoami, :upload_media]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
plug(Majic.Plug, [pool: Pleroma.MajicPool] when action in [:upload_media])
|
||||||
|
|
||||||
plug(
|
plug(
|
||||||
Pleroma.Web.Plugs.Cache,
|
Pleroma.Web.Plugs.Cache,
|
||||||
[query_params: false, tracking_fun: &__MODULE__.track_object_fetch/2]
|
[query_params: false, tracking_fun: &__MODULE__.track_object_fetch/2]
|
||||||
|
@ -412,7 +414,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
||||||
object =
|
object =
|
||||||
object
|
object
|
||||||
|> Map.merge(Map.take(params, ["to", "cc"]))
|
|> Map.merge(Map.take(params, ["to", "cc"]))
|
||||||
|> Map.put("attributedTo", user.ap_id())
|
|> Map.put("attributedTo", user.ap_id)
|
||||||
|> Transmogrifier.fix_object()
|
|> Transmogrifier.fix_object()
|
||||||
|
|
||||||
ActivityPub.create(%{
|
ActivityPub.create(%{
|
||||||
|
@ -456,7 +458,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
||||||
%{assigns: %{user: %User{nickname: nickname} = user}} = conn,
|
%{assigns: %{user: %User{nickname: nickname} = user}} = conn,
|
||||||
%{"nickname" => nickname} = params
|
%{"nickname" => nickname} = params
|
||||||
) do
|
) do
|
||||||
actor = user.ap_id()
|
actor = user.ap_id
|
||||||
|
|
||||||
params =
|
params =
|
||||||
params
|
params
|
||||||
|
@ -523,19 +525,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|
||||||
{new_user, for_user}
|
{new_user, for_user}
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
|
||||||
Endpoint based on <https://www.w3.org/wiki/SocialCG/ActivityPub/MediaUpload>
|
|
||||||
|
|
||||||
Parameters:
|
|
||||||
- (required) `file`: data of the media
|
|
||||||
- (optionnal) `description`: description of the media, intended for accessibility
|
|
||||||
|
|
||||||
Response:
|
|
||||||
- HTTP Code: 201 Created
|
|
||||||
- HTTP Body: ActivityPub object to be inserted into another's `attachment` field
|
|
||||||
|
|
||||||
Note: Will not point to a URL with a `Location` header because no standalone Activity has been created.
|
|
||||||
"""
|
|
||||||
def upload_media(%{assigns: %{user: %User{} = user}} = conn, %{"file" => file} = data) do
|
def upload_media(%{assigns: %{user: %User{} = user}} = conn, %{"file" => file} = data) do
|
||||||
with {:ok, object} <-
|
with {:ok, object} <-
|
||||||
ActivityPub.upload(
|
ActivityPub.upload(
|
||||||
|
|
|
@ -242,9 +242,7 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
# Publishes an activity to all relevant peers.
|
||||||
Publishes an activity to all relevant peers.
|
|
||||||
"""
|
|
||||||
def publish(%User{} = actor, %Activity{} = activity) do
|
def publish(%User{} = actor, %Activity{} = activity) do
|
||||||
public = is_public?(activity)
|
public = is_public?(activity)
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
||||||
%User{} = followed <- User.get_cached_by_ap_id(followed_user),
|
%User{} = followed <- User.get_cached_by_ap_id(followed_user),
|
||||||
{_, {:ok, _}, _, _} <-
|
{_, {:ok, _}, _, _} <-
|
||||||
{:following, User.follow(follower, followed, :follow_pending), follower, followed} do
|
{:following, User.follow(follower, followed, :follow_pending), follower, followed} do
|
||||||
if followed.local && !followed.locked do
|
if followed.local && !followed.is_locked do
|
||||||
{:ok, accept_data, _} = Builder.accept(followed, object)
|
{:ok, accept_data, _} = Builder.accept(followed, object)
|
||||||
{:ok, _activity, _} = Pipeline.common_pipeline(accept_data, local: true)
|
{:ok, _activity, _} = Pipeline.common_pipeline(accept_data, local: true)
|
||||||
end
|
end
|
||||||
|
@ -187,7 +187,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
||||||
{:ok, notifications} = Notification.create_notifications(activity, do_send: false)
|
{:ok, notifications} = Notification.create_notifications(activity, do_send: false)
|
||||||
{:ok, _user} = ActivityPub.increase_note_count_if_public(user, object)
|
{:ok, _user} = ActivityPub.increase_note_count_if_public(user, object)
|
||||||
|
|
||||||
if in_reply_to = object.data["inReplyTo"] do
|
if in_reply_to = object.data["inReplyTo"] && object.data["type"] != "Answer" do
|
||||||
Object.increase_replies_count(in_reply_to)
|
Object.increase_replies_count(in_reply_to)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -306,11 +306,18 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
||||||
|
|
||||||
streamables =
|
streamables =
|
||||||
[[actor, recipient], [recipient, actor]]
|
[[actor, recipient], [recipient, actor]]
|
||||||
|
|> Enum.uniq()
|
||||||
|> Enum.map(fn [user, other_user] ->
|
|> Enum.map(fn [user, other_user] ->
|
||||||
if user.local do
|
if user.local do
|
||||||
{:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id)
|
{:ok, chat} = Chat.bump_or_create(user.id, other_user.ap_id)
|
||||||
{:ok, cm_ref} = MessageReference.create(chat, object, user.ap_id != actor.ap_id)
|
{:ok, cm_ref} = MessageReference.create(chat, object, user.ap_id != actor.ap_id)
|
||||||
|
|
||||||
|
Cachex.put(
|
||||||
|
:chat_message_id_idempotency_key_cache,
|
||||||
|
cm_ref.id,
|
||||||
|
meta[:idempotency_key]
|
||||||
|
)
|
||||||
|
|
||||||
{
|
{
|
||||||
["user", "user:pleroma_chat"],
|
["user", "user:pleroma_chat"],
|
||||||
{user, %{cm_ref | chat: chat, object: object}}
|
{user, %{cm_ref | chat: chat, object: object}}
|
||||||
|
|
|
@ -40,6 +40,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
|> fix_in_reply_to(options)
|
|> fix_in_reply_to(options)
|
||||||
|> fix_emoji
|
|> fix_emoji
|
||||||
|> fix_tag
|
|> fix_tag
|
||||||
|
|> set_sensitive
|
||||||
|> fix_content_map
|
|> fix_content_map
|
||||||
|> fix_addressing
|
|> fix_addressing
|
||||||
|> fix_summary
|
|> fix_summary
|
||||||
|
@ -313,19 +314,21 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
tags =
|
tags =
|
||||||
tag
|
tag
|
||||||
|> Enum.filter(fn data -> data["type"] == "Hashtag" and data["name"] end)
|
|> Enum.filter(fn data -> data["type"] == "Hashtag" and data["name"] end)
|
||||||
|> Enum.map(fn data -> String.slice(data["name"], 1..-1) end)
|
|> Enum.map(fn %{"name" => name} ->
|
||||||
|
name
|
||||||
|
|> String.slice(1..-1)
|
||||||
|
|> String.downcase()
|
||||||
|
end)
|
||||||
|
|
||||||
Map.put(object, "tag", tag ++ tags)
|
Map.put(object, "tag", tag ++ tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_tag(%{"tag" => %{"type" => "Hashtag", "name" => hashtag} = tag} = object) do
|
def fix_tag(%{"tag" => %{} = tag} = object) do
|
||||||
combined = [tag, String.slice(hashtag, 1..-1)]
|
object
|
||||||
|
|> Map.put("tag", [tag])
|
||||||
Map.put(object, "tag", combined)
|
|> fix_tag
|
||||||
end
|
end
|
||||||
|
|
||||||
def fix_tag(%{"tag" => %{} = tag} = object), do: Map.put(object, "tag", [tag])
|
|
||||||
|
|
||||||
def fix_tag(object), do: object
|
def fix_tag(object), do: object
|
||||||
|
|
||||||
# content map usually only has one language so this will do for now.
|
# content map usually only has one language so this will do for now.
|
||||||
|
@ -927,7 +930,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
Map.put(object, "conversation", object["context"])
|
Map.put(object, "conversation", object["context"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_sensitive(%{"sensitive" => true} = object) do
|
def set_sensitive(%{"sensitive" => _} = object) do
|
||||||
object
|
object
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
||||||
"name" => user.name,
|
"name" => user.name,
|
||||||
"summary" => user.bio,
|
"summary" => user.bio,
|
||||||
"url" => user.ap_id,
|
"url" => user.ap_id,
|
||||||
"manuallyApprovesFollowers" => user.locked,
|
"manuallyApprovesFollowers" => user.is_locked,
|
||||||
"publicKey" => %{
|
"publicKey" => %{
|
||||||
"id" => "#{user.ap_id}#main-key",
|
"id" => "#{user.ap_id}#main-key",
|
||||||
"owner" => user.ap_id,
|
"owner" => user.ap_id,
|
||||||
|
@ -110,7 +110,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
||||||
"endpoints" => endpoints,
|
"endpoints" => endpoints,
|
||||||
"attachment" => fields,
|
"attachment" => fields,
|
||||||
"tag" => emoji_tags,
|
"tag" => emoji_tags,
|
||||||
"discoverable" => user.discoverable,
|
"discoverable" => user.is_discoverable,
|
||||||
"capabilities" => capabilities
|
"capabilities" => capabilities
|
||||||
}
|
}
|
||||||
|> Map.merge(maybe_make_image(&User.avatar_url/2, "icon", user))
|
|> Map.merge(maybe_make_image(&User.avatar_url/2, "icon", user))
|
||||||
|
|
|
@ -44,29 +44,30 @@ defmodule Pleroma.Web.ActivityPub.Visibility do
|
||||||
def is_list?(%{data: %{"listMessage" => _}}), do: true
|
def is_list?(%{data: %{"listMessage" => _}}), do: true
|
||||||
def is_list?(_), do: false
|
def is_list?(_), do: false
|
||||||
|
|
||||||
@spec visible_for_user?(Activity.t(), User.t() | nil) :: boolean()
|
@spec visible_for_user?(Activity.t() | nil, User.t() | nil) :: boolean()
|
||||||
def visible_for_user?(%{actor: ap_id}, %User{ap_id: ap_id}), do: true
|
def visible_for_user?(%Activity{actor: ap_id}, %User{ap_id: ap_id}), do: true
|
||||||
|
|
||||||
def visible_for_user?(nil, _), do: false
|
def visible_for_user?(nil, _), do: false
|
||||||
|
|
||||||
def visible_for_user?(%{data: %{"listMessage" => _}}, nil), do: false
|
def visible_for_user?(%Activity{data: %{"listMessage" => _}}, nil), do: false
|
||||||
|
|
||||||
def visible_for_user?(%{data: %{"listMessage" => list_ap_id}} = activity, %User{} = user) do
|
def visible_for_user?(
|
||||||
|
%Activity{data: %{"listMessage" => list_ap_id}} = activity,
|
||||||
|
%User{} = user
|
||||||
|
) do
|
||||||
user.ap_id in activity.data["to"] ||
|
user.ap_id in activity.data["to"] ||
|
||||||
list_ap_id
|
list_ap_id
|
||||||
|> Pleroma.List.get_by_ap_id()
|
|> Pleroma.List.get_by_ap_id()
|
||||||
|> Pleroma.List.member?(user)
|
|> Pleroma.List.member?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_for_user?(%{local: local} = activity, nil) do
|
def visible_for_user?(%Activity{} = activity, nil) do
|
||||||
cfg_key = if local, do: :local, else: :remote
|
if restrict_unauthenticated_access?(activity),
|
||||||
|
|
||||||
if Pleroma.Config.restrict_unauthenticated_access?(:activities, cfg_key),
|
|
||||||
do: false,
|
do: false,
|
||||||
else: is_public?(activity)
|
else: is_public?(activity)
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_for_user?(activity, user) do
|
def visible_for_user?(%Activity{} = activity, user) do
|
||||||
x = [user.ap_id | User.following(user)]
|
x = [user.ap_id | User.following(user)]
|
||||||
y = [activity.actor] ++ activity.data["to"] ++ (activity.data["cc"] || [])
|
y = [activity.actor] ++ activity.data["to"] ++ (activity.data["cc"] || [])
|
||||||
is_public?(activity) || Enum.any?(x, &(&1 in y))
|
is_public?(activity) || Enum.any?(x, &(&1 in y))
|
||||||
|
@ -82,6 +83,26 @@ defmodule Pleroma.Web.ActivityPub.Visibility do
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def restrict_unauthenticated_access?(%Activity{local: local}) do
|
||||||
|
restrict_unauthenticated_access_to_activity?(local)
|
||||||
|
end
|
||||||
|
|
||||||
|
def restrict_unauthenticated_access?(%Object{} = object) do
|
||||||
|
object
|
||||||
|
|> Object.local?()
|
||||||
|
|> restrict_unauthenticated_access_to_activity?()
|
||||||
|
end
|
||||||
|
|
||||||
|
def restrict_unauthenticated_access?(%User{} = user) do
|
||||||
|
User.visible_for(user, _reading_user = nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp restrict_unauthenticated_access_to_activity?(local?) when is_boolean(local?) do
|
||||||
|
cfg_key = if local?, do: :local, else: :remote
|
||||||
|
|
||||||
|
Pleroma.Config.restrict_unauthenticated_access?(:activities, cfg_key)
|
||||||
|
end
|
||||||
|
|
||||||
def get_visibility(object) do
|
def get_visibility(object) do
|
||||||
to = object.data["to"] || []
|
to = object.data["to"] || []
|
||||||
cc = object.data["cc"] || []
|
cc = object.data["cc"] || []
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
||||||
use Pleroma.Web, :controller
|
use Pleroma.Web, :controller
|
||||||
|
|
||||||
import Pleroma.Web.ControllerHelper, only: [json_response: 3]
|
import Pleroma.Web.ControllerHelper,
|
||||||
|
only: [json_response: 3, fetch_integer_param: 3]
|
||||||
|
|
||||||
alias Pleroma.Config
|
alias Pleroma.Config
|
||||||
alias Pleroma.MFA
|
alias Pleroma.MFA
|
||||||
|
@ -13,12 +14,9 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
||||||
alias Pleroma.Stats
|
alias Pleroma.Stats
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.ActivityPub.Builder
|
|
||||||
alias Pleroma.Web.ActivityPub.Pipeline
|
|
||||||
alias Pleroma.Web.AdminAPI
|
alias Pleroma.Web.AdminAPI
|
||||||
alias Pleroma.Web.AdminAPI.AccountView
|
alias Pleroma.Web.AdminAPI.AccountView
|
||||||
alias Pleroma.Web.AdminAPI.ModerationLogView
|
alias Pleroma.Web.AdminAPI.ModerationLogView
|
||||||
alias Pleroma.Web.AdminAPI.Search
|
|
||||||
alias Pleroma.Web.Endpoint
|
alias Pleroma.Web.Endpoint
|
||||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||||
alias Pleroma.Web.Router
|
alias Pleroma.Web.Router
|
||||||
|
@ -28,7 +26,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
||||||
plug(
|
plug(
|
||||||
OAuthScopesPlug,
|
OAuthScopesPlug,
|
||||||
%{scopes: ["read:accounts"], admin: true}
|
%{scopes: ["read:accounts"], admin: true}
|
||||||
when action in [:list_users, :user_show, :right_get, :show_user_credentials]
|
when action in [:right_get, :show_user_credentials, :create_backup]
|
||||||
)
|
)
|
||||||
|
|
||||||
plug(
|
plug(
|
||||||
|
@ -37,12 +35,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
||||||
when action in [
|
when action in [
|
||||||
:get_password_reset,
|
:get_password_reset,
|
||||||
:force_password_reset,
|
:force_password_reset,
|
||||||
:user_delete,
|
|
||||||
:users_create,
|
|
||||||
:user_toggle_activation,
|
|
||||||
:user_activate,
|
|
||||||
:user_deactivate,
|
|
||||||
:user_approve,
|
|
||||||
:tag_users,
|
:tag_users,
|
||||||
:untag_users,
|
:untag_users,
|
||||||
:right_add,
|
:right_add,
|
||||||
|
@ -54,12 +46,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
plug(
|
|
||||||
OAuthScopesPlug,
|
|
||||||
%{scopes: ["write:follows"], admin: true}
|
|
||||||
when action in [:user_follow, :user_unfollow]
|
|
||||||
)
|
|
||||||
|
|
||||||
plug(
|
plug(
|
||||||
OAuthScopesPlug,
|
OAuthScopesPlug,
|
||||||
%{scopes: ["read:statuses"], admin: true}
|
%{scopes: ["read:statuses"], admin: true}
|
||||||
|
@ -95,132 +81,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
||||||
|
|
||||||
action_fallback(AdminAPI.FallbackController)
|
action_fallback(AdminAPI.FallbackController)
|
||||||
|
|
||||||
def user_delete(conn, %{"nickname" => nickname}) do
|
|
||||||
user_delete(conn, %{"nicknames" => [nickname]})
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_delete(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do
|
|
||||||
users =
|
|
||||||
nicknames
|
|
||||||
|> Enum.map(&User.get_cached_by_nickname/1)
|
|
||||||
|
|
||||||
users
|
|
||||||
|> Enum.each(fn user ->
|
|
||||||
{:ok, delete_data, _} = Builder.delete(admin, user.ap_id)
|
|
||||||
Pipeline.common_pipeline(delete_data, local: true)
|
|
||||||
end)
|
|
||||||
|
|
||||||
ModerationLog.insert_log(%{
|
|
||||||
actor: admin,
|
|
||||||
subject: users,
|
|
||||||
action: "delete"
|
|
||||||
})
|
|
||||||
|
|
||||||
json(conn, nicknames)
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_follow(%{assigns: %{user: admin}} = conn, %{
|
|
||||||
"follower" => follower_nick,
|
|
||||||
"followed" => followed_nick
|
|
||||||
}) do
|
|
||||||
with %User{} = follower <- User.get_cached_by_nickname(follower_nick),
|
|
||||||
%User{} = followed <- User.get_cached_by_nickname(followed_nick) do
|
|
||||||
User.follow(follower, followed)
|
|
||||||
|
|
||||||
ModerationLog.insert_log(%{
|
|
||||||
actor: admin,
|
|
||||||
followed: followed,
|
|
||||||
follower: follower,
|
|
||||||
action: "follow"
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
json(conn, "ok")
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_unfollow(%{assigns: %{user: admin}} = conn, %{
|
|
||||||
"follower" => follower_nick,
|
|
||||||
"followed" => followed_nick
|
|
||||||
}) do
|
|
||||||
with %User{} = follower <- User.get_cached_by_nickname(follower_nick),
|
|
||||||
%User{} = followed <- User.get_cached_by_nickname(followed_nick) do
|
|
||||||
User.unfollow(follower, followed)
|
|
||||||
|
|
||||||
ModerationLog.insert_log(%{
|
|
||||||
actor: admin,
|
|
||||||
followed: followed,
|
|
||||||
follower: follower,
|
|
||||||
action: "unfollow"
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
json(conn, "ok")
|
|
||||||
end
|
|
||||||
|
|
||||||
def users_create(%{assigns: %{user: admin}} = conn, %{"users" => users}) do
|
|
||||||
changesets =
|
|
||||||
Enum.map(users, fn %{"nickname" => nickname, "email" => email, "password" => password} ->
|
|
||||||
user_data = %{
|
|
||||||
nickname: nickname,
|
|
||||||
name: nickname,
|
|
||||||
email: email,
|
|
||||||
password: password,
|
|
||||||
password_confirmation: password,
|
|
||||||
bio: "."
|
|
||||||
}
|
|
||||||
|
|
||||||
User.register_changeset(%User{}, user_data, need_confirmation: false)
|
|
||||||
end)
|
|
||||||
|> Enum.reduce(Ecto.Multi.new(), fn changeset, multi ->
|
|
||||||
Ecto.Multi.insert(multi, Ecto.UUID.generate(), changeset)
|
|
||||||
end)
|
|
||||||
|
|
||||||
case Pleroma.Repo.transaction(changesets) do
|
|
||||||
{:ok, users} ->
|
|
||||||
res =
|
|
||||||
users
|
|
||||||
|> Map.values()
|
|
||||||
|> Enum.map(fn user ->
|
|
||||||
{:ok, user} = User.post_register_action(user)
|
|
||||||
|
|
||||||
user
|
|
||||||
end)
|
|
||||||
|> Enum.map(&AccountView.render("created.json", %{user: &1}))
|
|
||||||
|
|
||||||
ModerationLog.insert_log(%{
|
|
||||||
actor: admin,
|
|
||||||
subjects: Map.values(users),
|
|
||||||
action: "create"
|
|
||||||
})
|
|
||||||
|
|
||||||
json(conn, res)
|
|
||||||
|
|
||||||
{:error, id, changeset, _} ->
|
|
||||||
res =
|
|
||||||
Enum.map(changesets.operations, fn
|
|
||||||
{current_id, {:changeset, _current_changeset, _}} when current_id == id ->
|
|
||||||
AccountView.render("create-error.json", %{changeset: changeset})
|
|
||||||
|
|
||||||
{_, {:changeset, current_changeset, _}} ->
|
|
||||||
AccountView.render("create-error.json", %{changeset: current_changeset})
|
|
||||||
end)
|
|
||||||
|
|
||||||
conn
|
|
||||||
|> put_status(:conflict)
|
|
||||||
|> json(res)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_show(%{assigns: %{user: admin}} = conn, %{"nickname" => nickname}) do
|
|
||||||
with %User{} = user <- User.get_cached_by_nickname_or_id(nickname, for: admin) do
|
|
||||||
conn
|
|
||||||
|> put_view(AccountView)
|
|
||||||
|> render("show.json", %{user: user})
|
|
||||||
else
|
|
||||||
_ -> {:error, :not_found}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def list_instance_statuses(conn, %{"instance" => instance} = params) do
|
def list_instance_statuses(conn, %{"instance" => instance} = params) do
|
||||||
with_reblogs = params["with_reblogs"] == "true" || params["with_reblogs"] == true
|
with_reblogs = params["with_reblogs"] == "true" || params["with_reblogs"] == true
|
||||||
{page, page_size} = page_params(params)
|
{page, page_size} = page_params(params)
|
||||||
|
@ -274,69 +134,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_toggle_activation(%{assigns: %{user: admin}} = conn, %{"nickname" => nickname}) do
|
|
||||||
user = User.get_cached_by_nickname(nickname)
|
|
||||||
|
|
||||||
{:ok, updated_user} = User.deactivate(user, !user.deactivated)
|
|
||||||
|
|
||||||
action = if user.deactivated, do: "activate", else: "deactivate"
|
|
||||||
|
|
||||||
ModerationLog.insert_log(%{
|
|
||||||
actor: admin,
|
|
||||||
subject: [user],
|
|
||||||
action: action
|
|
||||||
})
|
|
||||||
|
|
||||||
conn
|
|
||||||
|> put_view(AccountView)
|
|
||||||
|> render("show.json", %{user: updated_user})
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_activate(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do
|
|
||||||
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
|
|
||||||
{:ok, updated_users} = User.deactivate(users, false)
|
|
||||||
|
|
||||||
ModerationLog.insert_log(%{
|
|
||||||
actor: admin,
|
|
||||||
subject: users,
|
|
||||||
action: "activate"
|
|
||||||
})
|
|
||||||
|
|
||||||
conn
|
|
||||||
|> put_view(AccountView)
|
|
||||||
|> render("index.json", %{users: Keyword.values(updated_users)})
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_deactivate(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do
|
|
||||||
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
|
|
||||||
{:ok, updated_users} = User.deactivate(users, true)
|
|
||||||
|
|
||||||
ModerationLog.insert_log(%{
|
|
||||||
actor: admin,
|
|
||||||
subject: users,
|
|
||||||
action: "deactivate"
|
|
||||||
})
|
|
||||||
|
|
||||||
conn
|
|
||||||
|> put_view(AccountView)
|
|
||||||
|> render("index.json", %{users: Keyword.values(updated_users)})
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_approve(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do
|
|
||||||
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
|
|
||||||
{:ok, updated_users} = User.approve(users)
|
|
||||||
|
|
||||||
ModerationLog.insert_log(%{
|
|
||||||
actor: admin,
|
|
||||||
subject: users,
|
|
||||||
action: "approve"
|
|
||||||
})
|
|
||||||
|
|
||||||
conn
|
|
||||||
|> put_view(AccountView)
|
|
||||||
|> render("index.json", %{users: updated_users})
|
|
||||||
end
|
|
||||||
|
|
||||||
def tag_users(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames, "tags" => tags}) do
|
def tag_users(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames, "tags" => tags}) do
|
||||||
with {:ok, _} <- User.tag(nicknames, tags) do
|
with {:ok, _} <- User.tag(nicknames, tags) do
|
||||||
ModerationLog.insert_log(%{
|
ModerationLog.insert_log(%{
|
||||||
|
@ -363,43 +160,6 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def list_users(conn, params) do
|
|
||||||
{page, page_size} = page_params(params)
|
|
||||||
filters = maybe_parse_filters(params["filters"])
|
|
||||||
|
|
||||||
search_params = %{
|
|
||||||
query: params["query"],
|
|
||||||
page: page,
|
|
||||||
page_size: page_size,
|
|
||||||
tags: params["tags"],
|
|
||||||
name: params["name"],
|
|
||||||
email: params["email"]
|
|
||||||
}
|
|
||||||
|
|
||||||
with {:ok, users, count} <- Search.user(Map.merge(search_params, filters)) do
|
|
||||||
json(
|
|
||||||
conn,
|
|
||||||
AccountView.render("index.json",
|
|
||||||
users: users,
|
|
||||||
count: count,
|
|
||||||
page_size: page_size
|
|
||||||
)
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@filters ~w(local external active deactivated need_approval is_admin is_moderator)
|
|
||||||
|
|
||||||
@spec maybe_parse_filters(String.t()) :: %{required(String.t()) => true} | %{}
|
|
||||||
defp maybe_parse_filters(filters) when is_nil(filters) or filters == "", do: %{}
|
|
||||||
|
|
||||||
defp maybe_parse_filters(filters) do
|
|
||||||
filters
|
|
||||||
|> String.split(",")
|
|
||||||
|> Enum.filter(&Enum.member?(@filters, &1))
|
|
||||||
|> Map.new(&{String.to_existing_atom(&1), true})
|
|
||||||
end
|
|
||||||
|
|
||||||
def right_add_multiple(%{assigns: %{user: admin}} = conn, %{
|
def right_add_multiple(%{assigns: %{user: admin}} = conn, %{
|
||||||
"permission_group" => permission_group,
|
"permission_group" => permission_group,
|
||||||
"nicknames" => nicknames
|
"nicknames" => nicknames
|
||||||
|
@ -681,25 +441,19 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
|
||||||
json(conn, %{"status_visibility" => counters})
|
json(conn, %{"status_visibility" => counters})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_backup(%{assigns: %{user: admin}} = conn, %{"nickname" => nickname}) do
|
||||||
|
with %User{} = user <- User.get_by_nickname(nickname),
|
||||||
|
{:ok, _} <- Pleroma.User.Backup.create(user, admin.id) do
|
||||||
|
ModerationLog.insert_log(%{actor: admin, subject: user, action: "create_backup"})
|
||||||
|
|
||||||
|
json(conn, "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp page_params(params) do
|
defp page_params(params) do
|
||||||
{get_page(params["page"]), get_page_size(params["page_size"])}
|
{
|
||||||
end
|
fetch_integer_param(params, "page", 1),
|
||||||
|
fetch_integer_param(params, "page_size", @users_page_size)
|
||||||
defp get_page(page_string) when is_nil(page_string), do: 1
|
}
|
||||||
|
|
||||||
defp get_page(page_string) do
|
|
||||||
case Integer.parse(page_string) do
|
|
||||||
{page, _} -> page
|
|
||||||
:error -> 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp get_page_size(page_size_string) when is_nil(page_size_string), do: @users_page_size
|
|
||||||
|
|
||||||
defp get_page_size(page_size_string) do
|
|
||||||
case Integer.parse(page_size_string) do
|
|
||||||
{page_size, _} -> page_size
|
|
||||||
:error -> @users_page_size
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -38,7 +38,7 @@ defmodule Pleroma.Web.AdminAPI.ReportController do
|
||||||
end
|
end
|
||||||
|
|
||||||
def show(conn, %{id: id}) do
|
def show(conn, %{id: id}) do
|
||||||
with %Activity{} = report <- Activity.get_by_id(id) do
|
with %Activity{} = report <- Activity.get_report(id) do
|
||||||
render(conn, "show.json", Report.extract_report_info(report))
|
render(conn, "show.json", Report.extract_report_info(report))
|
||||||
else
|
else
|
||||||
_ -> {:error, :not_found}
|
_ -> {:error, :not_found}
|
||||||
|
|
281
lib/pleroma/web/admin_api/controllers/user_controller.ex
Normal file
281
lib/pleroma/web/admin_api/controllers/user_controller.ex
Normal file
|
@ -0,0 +1,281 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.AdminAPI.UserController do
|
||||||
|
use Pleroma.Web, :controller
|
||||||
|
|
||||||
|
import Pleroma.Web.ControllerHelper,
|
||||||
|
only: [fetch_integer_param: 3]
|
||||||
|
|
||||||
|
alias Pleroma.ModerationLog
|
||||||
|
alias Pleroma.User
|
||||||
|
alias Pleroma.Web.ActivityPub.Builder
|
||||||
|
alias Pleroma.Web.ActivityPub.Pipeline
|
||||||
|
alias Pleroma.Web.AdminAPI
|
||||||
|
alias Pleroma.Web.AdminAPI.AccountView
|
||||||
|
alias Pleroma.Web.AdminAPI.Search
|
||||||
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||||
|
|
||||||
|
@users_page_size 50
|
||||||
|
|
||||||
|
plug(
|
||||||
|
OAuthScopesPlug,
|
||||||
|
%{scopes: ["read:accounts"], admin: true}
|
||||||
|
when action in [:list, :show]
|
||||||
|
)
|
||||||
|
|
||||||
|
plug(
|
||||||
|
OAuthScopesPlug,
|
||||||
|
%{scopes: ["write:accounts"], admin: true}
|
||||||
|
when action in [
|
||||||
|
:delete,
|
||||||
|
:create,
|
||||||
|
:toggle_activation,
|
||||||
|
:activate,
|
||||||
|
:deactivate,
|
||||||
|
:approve
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
plug(
|
||||||
|
OAuthScopesPlug,
|
||||||
|
%{scopes: ["write:follows"], admin: true}
|
||||||
|
when action in [:follow, :unfollow]
|
||||||
|
)
|
||||||
|
|
||||||
|
action_fallback(AdminAPI.FallbackController)
|
||||||
|
|
||||||
|
def delete(conn, %{"nickname" => nickname}) do
|
||||||
|
delete(conn, %{"nicknames" => [nickname]})
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do
|
||||||
|
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
|
||||||
|
|
||||||
|
Enum.each(users, fn user ->
|
||||||
|
{:ok, delete_data, _} = Builder.delete(admin, user.ap_id)
|
||||||
|
Pipeline.common_pipeline(delete_data, local: true)
|
||||||
|
end)
|
||||||
|
|
||||||
|
ModerationLog.insert_log(%{
|
||||||
|
actor: admin,
|
||||||
|
subject: users,
|
||||||
|
action: "delete"
|
||||||
|
})
|
||||||
|
|
||||||
|
json(conn, nicknames)
|
||||||
|
end
|
||||||
|
|
||||||
|
def follow(%{assigns: %{user: admin}} = conn, %{
|
||||||
|
"follower" => follower_nick,
|
||||||
|
"followed" => followed_nick
|
||||||
|
}) do
|
||||||
|
with %User{} = follower <- User.get_cached_by_nickname(follower_nick),
|
||||||
|
%User{} = followed <- User.get_cached_by_nickname(followed_nick) do
|
||||||
|
User.follow(follower, followed)
|
||||||
|
|
||||||
|
ModerationLog.insert_log(%{
|
||||||
|
actor: admin,
|
||||||
|
followed: followed,
|
||||||
|
follower: follower,
|
||||||
|
action: "follow"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
json(conn, "ok")
|
||||||
|
end
|
||||||
|
|
||||||
|
def unfollow(%{assigns: %{user: admin}} = conn, %{
|
||||||
|
"follower" => follower_nick,
|
||||||
|
"followed" => followed_nick
|
||||||
|
}) do
|
||||||
|
with %User{} = follower <- User.get_cached_by_nickname(follower_nick),
|
||||||
|
%User{} = followed <- User.get_cached_by_nickname(followed_nick) do
|
||||||
|
User.unfollow(follower, followed)
|
||||||
|
|
||||||
|
ModerationLog.insert_log(%{
|
||||||
|
actor: admin,
|
||||||
|
followed: followed,
|
||||||
|
follower: follower,
|
||||||
|
action: "unfollow"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
json(conn, "ok")
|
||||||
|
end
|
||||||
|
|
||||||
|
def create(%{assigns: %{user: admin}} = conn, %{"users" => users}) do
|
||||||
|
changesets =
|
||||||
|
Enum.map(users, fn %{"nickname" => nickname, "email" => email, "password" => password} ->
|
||||||
|
user_data = %{
|
||||||
|
nickname: nickname,
|
||||||
|
name: nickname,
|
||||||
|
email: email,
|
||||||
|
password: password,
|
||||||
|
password_confirmation: password,
|
||||||
|
bio: "."
|
||||||
|
}
|
||||||
|
|
||||||
|
User.register_changeset(%User{}, user_data, need_confirmation: false)
|
||||||
|
end)
|
||||||
|
|> Enum.reduce(Ecto.Multi.new(), fn changeset, multi ->
|
||||||
|
Ecto.Multi.insert(multi, Ecto.UUID.generate(), changeset)
|
||||||
|
end)
|
||||||
|
|
||||||
|
case Pleroma.Repo.transaction(changesets) do
|
||||||
|
{:ok, users} ->
|
||||||
|
res =
|
||||||
|
users
|
||||||
|
|> Map.values()
|
||||||
|
|> Enum.map(fn user ->
|
||||||
|
{:ok, user} = User.post_register_action(user)
|
||||||
|
|
||||||
|
user
|
||||||
|
end)
|
||||||
|
|> Enum.map(&AccountView.render("created.json", %{user: &1}))
|
||||||
|
|
||||||
|
ModerationLog.insert_log(%{
|
||||||
|
actor: admin,
|
||||||
|
subjects: Map.values(users),
|
||||||
|
action: "create"
|
||||||
|
})
|
||||||
|
|
||||||
|
json(conn, res)
|
||||||
|
|
||||||
|
{:error, id, changeset, _} ->
|
||||||
|
res =
|
||||||
|
Enum.map(changesets.operations, fn
|
||||||
|
{current_id, {:changeset, _current_changeset, _}} when current_id == id ->
|
||||||
|
AccountView.render("create-error.json", %{changeset: changeset})
|
||||||
|
|
||||||
|
{_, {:changeset, current_changeset, _}} ->
|
||||||
|
AccountView.render("create-error.json", %{changeset: current_changeset})
|
||||||
|
end)
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> put_status(:conflict)
|
||||||
|
|> json(res)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show(%{assigns: %{user: admin}} = conn, %{"nickname" => nickname}) do
|
||||||
|
with %User{} = user <- User.get_cached_by_nickname_or_id(nickname, for: admin) do
|
||||||
|
conn
|
||||||
|
|> put_view(AccountView)
|
||||||
|
|> render("show.json", %{user: user})
|
||||||
|
else
|
||||||
|
_ -> {:error, :not_found}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def toggle_activation(%{assigns: %{user: admin}} = conn, %{"nickname" => nickname}) do
|
||||||
|
user = User.get_cached_by_nickname(nickname)
|
||||||
|
|
||||||
|
{:ok, updated_user} = User.deactivate(user, !user.deactivated)
|
||||||
|
|
||||||
|
action = if user.deactivated, do: "activate", else: "deactivate"
|
||||||
|
|
||||||
|
ModerationLog.insert_log(%{
|
||||||
|
actor: admin,
|
||||||
|
subject: [user],
|
||||||
|
action: action
|
||||||
|
})
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> put_view(AccountView)
|
||||||
|
|> render("show.json", %{user: updated_user})
|
||||||
|
end
|
||||||
|
|
||||||
|
def activate(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do
|
||||||
|
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
|
||||||
|
{:ok, updated_users} = User.deactivate(users, false)
|
||||||
|
|
||||||
|
ModerationLog.insert_log(%{
|
||||||
|
actor: admin,
|
||||||
|
subject: users,
|
||||||
|
action: "activate"
|
||||||
|
})
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> put_view(AccountView)
|
||||||
|
|> render("index.json", %{users: Keyword.values(updated_users)})
|
||||||
|
end
|
||||||
|
|
||||||
|
def deactivate(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do
|
||||||
|
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
|
||||||
|
{:ok, updated_users} = User.deactivate(users, true)
|
||||||
|
|
||||||
|
ModerationLog.insert_log(%{
|
||||||
|
actor: admin,
|
||||||
|
subject: users,
|
||||||
|
action: "deactivate"
|
||||||
|
})
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> put_view(AccountView)
|
||||||
|
|> render("index.json", %{users: Keyword.values(updated_users)})
|
||||||
|
end
|
||||||
|
|
||||||
|
def approve(%{assigns: %{user: admin}} = conn, %{"nicknames" => nicknames}) do
|
||||||
|
users = Enum.map(nicknames, &User.get_cached_by_nickname/1)
|
||||||
|
{:ok, updated_users} = User.approve(users)
|
||||||
|
|
||||||
|
ModerationLog.insert_log(%{
|
||||||
|
actor: admin,
|
||||||
|
subject: users,
|
||||||
|
action: "approve"
|
||||||
|
})
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> put_view(AccountView)
|
||||||
|
|> render("index.json", %{users: updated_users})
|
||||||
|
end
|
||||||
|
|
||||||
|
def list(conn, params) do
|
||||||
|
{page, page_size} = page_params(params)
|
||||||
|
filters = maybe_parse_filters(params["filters"])
|
||||||
|
|
||||||
|
search_params =
|
||||||
|
%{
|
||||||
|
query: params["query"],
|
||||||
|
page: page,
|
||||||
|
page_size: page_size,
|
||||||
|
tags: params["tags"],
|
||||||
|
name: params["name"],
|
||||||
|
email: params["email"],
|
||||||
|
actor_types: params["actor_types"]
|
||||||
|
}
|
||||||
|
|> Map.merge(filters)
|
||||||
|
|
||||||
|
with {:ok, users, count} <- Search.user(search_params) do
|
||||||
|
json(
|
||||||
|
conn,
|
||||||
|
AccountView.render("index.json",
|
||||||
|
users: users,
|
||||||
|
count: count,
|
||||||
|
page_size: page_size
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@filters ~w(local external active deactivated need_approval unconfirmed is_admin is_moderator)
|
||||||
|
|
||||||
|
@spec maybe_parse_filters(String.t()) :: %{required(String.t()) => true} | %{}
|
||||||
|
defp maybe_parse_filters(filters) when is_nil(filters) or filters == "", do: %{}
|
||||||
|
|
||||||
|
defp maybe_parse_filters(filters) do
|
||||||
|
filters
|
||||||
|
|> String.split(",")
|
||||||
|
|> Enum.filter(&Enum.member?(@filters, &1))
|
||||||
|
|> Map.new(&{String.to_existing_atom(&1), true})
|
||||||
|
end
|
||||||
|
|
||||||
|
defp page_params(params) do
|
||||||
|
{
|
||||||
|
fetch_integer_param(params, "page", 1),
|
||||||
|
fetch_integer_param(params, "page_size", @users_page_size)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
|
@ -39,7 +39,7 @@ defmodule Pleroma.Web.AdminAPI.AccountView do
|
||||||
:fields,
|
:fields,
|
||||||
:name,
|
:name,
|
||||||
:nickname,
|
:nickname,
|
||||||
:locked,
|
:is_locked,
|
||||||
:no_rich_text,
|
:no_rich_text,
|
||||||
:default_scope,
|
:default_scope,
|
||||||
:hide_follows,
|
:hide_follows,
|
||||||
|
@ -52,7 +52,7 @@ defmodule Pleroma.Web.AdminAPI.AccountView do
|
||||||
:skip_thread_containment,
|
:skip_thread_containment,
|
||||||
:pleroma_settings_store,
|
:pleroma_settings_store,
|
||||||
:raw_fields,
|
:raw_fields,
|
||||||
:discoverable,
|
:is_discoverable,
|
||||||
:actor_type
|
:actor_type
|
||||||
])
|
])
|
||||||
|> Map.merge(%{
|
|> Map.merge(%{
|
||||||
|
|
|
@ -52,7 +52,7 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("index_notes.json", %{notes: notes}) when is_list(notes) do
|
def render("index_notes.json", %{notes: notes}) when is_list(notes) do
|
||||||
Enum.map(notes, &render(__MODULE__, "show_note.json", &1))
|
Enum.map(notes, &render(__MODULE__, "show_note.json", Map.from_struct(&1)))
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("index_notes.json", _), do: []
|
def render("index_notes.json", _), do: []
|
||||||
|
|
|
@ -335,6 +335,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
||||||
operationId: "AccountController.mutes",
|
operationId: "AccountController.mutes",
|
||||||
description: "Accounts the user has muted.",
|
description: "Accounts the user has muted.",
|
||||||
security: [%{"oAuth" => ["follow", "read:mutes"]}],
|
security: [%{"oAuth" => ["follow", "read:mutes"]}],
|
||||||
|
parameters: pagination_params(),
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => Operation.response("Accounts", "application/json", array_of_accounts())
|
200 => Operation.response("Accounts", "application/json", array_of_accounts())
|
||||||
}
|
}
|
||||||
|
@ -348,6 +349,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
||||||
operationId: "AccountController.blocks",
|
operationId: "AccountController.blocks",
|
||||||
description: "View your blocks. See also accounts/:id/{block,unblock}",
|
description: "View your blocks. See also accounts/:id/{block,unblock}",
|
||||||
security: [%{"oAuth" => ["read:blocks"]}],
|
security: [%{"oAuth" => ["read:blocks"]}],
|
||||||
|
parameters: pagination_params(),
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => Operation.response("Accounts", "application/json", array_of_accounts())
|
200 => Operation.response("Accounts", "application/json", array_of_accounts())
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
alias OpenApiSpex.Operation
|
alias OpenApiSpex.Operation
|
||||||
alias OpenApiSpex.Schema
|
alias OpenApiSpex.Schema
|
||||||
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
||||||
|
alias Pleroma.Web.ApiSpec.Schemas.BooleanLike
|
||||||
alias Pleroma.Web.ApiSpec.Schemas.Chat
|
alias Pleroma.Web.ApiSpec.Schemas.Chat
|
||||||
alias Pleroma.Web.ApiSpec.Schemas.ChatMessage
|
alias Pleroma.Web.ApiSpec.Schemas.ChatMessage
|
||||||
|
|
||||||
|
@ -132,7 +133,10 @@ defmodule Pleroma.Web.ApiSpec.ChatOperation do
|
||||||
tags: ["chat"],
|
tags: ["chat"],
|
||||||
summary: "Get a list of chats that you participated in",
|
summary: "Get a list of chats that you participated in",
|
||||||
operationId: "ChatController.index",
|
operationId: "ChatController.index",
|
||||||
parameters: pagination_params(),
|
parameters: [
|
||||||
|
Operation.parameter(:with_muted, :query, BooleanLike, "Include chats from muted users")
|
||||||
|
| pagination_params()
|
||||||
|
],
|
||||||
responses: %{
|
responses: %{
|
||||||
200 => Operation.response("The chats of the user", "application/json", chats_response())
|
200 => Operation.response("The chats of the user", "application/json", chats_response())
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ApiSpec.PleromaBackupOperation do
|
||||||
|
alias OpenApiSpex.Operation
|
||||||
|
alias OpenApiSpex.Schema
|
||||||
|
alias Pleroma.Web.ApiSpec.Schemas.ApiError
|
||||||
|
|
||||||
|
def open_api_operation(action) do
|
||||||
|
operation = String.to_existing_atom("#{action}_operation")
|
||||||
|
apply(__MODULE__, operation, [])
|
||||||
|
end
|
||||||
|
|
||||||
|
def index_operation do
|
||||||
|
%Operation{
|
||||||
|
tags: ["Backups"],
|
||||||
|
summary: "List backups",
|
||||||
|
security: [%{"oAuth" => ["read:account"]}],
|
||||||
|
operationId: "PleromaAPI.BackupController.index",
|
||||||
|
responses: %{
|
||||||
|
200 =>
|
||||||
|
Operation.response(
|
||||||
|
"An array of backups",
|
||||||
|
"application/json",
|
||||||
|
%Schema{
|
||||||
|
type: :array,
|
||||||
|
items: backup()
|
||||||
|
}
|
||||||
|
),
|
||||||
|
400 => Operation.response("Bad Request", "application/json", ApiError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_operation do
|
||||||
|
%Operation{
|
||||||
|
tags: ["Backups"],
|
||||||
|
summary: "Create a backup",
|
||||||
|
security: [%{"oAuth" => ["read:account"]}],
|
||||||
|
operationId: "PleromaAPI.BackupController.create",
|
||||||
|
responses: %{
|
||||||
|
200 =>
|
||||||
|
Operation.response(
|
||||||
|
"An array of backups",
|
||||||
|
"application/json",
|
||||||
|
%Schema{
|
||||||
|
type: :array,
|
||||||
|
items: backup()
|
||||||
|
}
|
||||||
|
),
|
||||||
|
400 => Operation.response("Bad Request", "application/json", ApiError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp backup do
|
||||||
|
%Schema{
|
||||||
|
title: "Backup",
|
||||||
|
description: "Response schema for a backup",
|
||||||
|
type: :object,
|
||||||
|
properties: %{
|
||||||
|
inserted_at: %Schema{type: :string, format: :"date-time"},
|
||||||
|
content_type: %Schema{type: :string},
|
||||||
|
file_name: %Schema{type: :string},
|
||||||
|
file_size: %Schema{type: :integer},
|
||||||
|
processed: %Schema{type: :boolean}
|
||||||
|
},
|
||||||
|
example: %{
|
||||||
|
"content_type" => "application/zip",
|
||||||
|
"file_name" =>
|
||||||
|
"https://cofe.fe:4000/media/backups/archive-foobar-20200908T164207-Yr7vuT5Wycv-sN3kSN2iJ0k-9pMo60j9qmvRCdDqIew.zip",
|
||||||
|
"file_size" => 4105,
|
||||||
|
"inserted_at" => "2020-09-08T16:42:07.000Z",
|
||||||
|
"processed" => true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
|
@ -50,7 +50,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Chat do
|
||||||
"fields" => []
|
"fields" => []
|
||||||
},
|
},
|
||||||
"statuses_count" => 1,
|
"statuses_count" => 1,
|
||||||
"locked" => false,
|
"is_locked" => false,
|
||||||
"created_at" => "2020-04-16T13:40:15.000Z",
|
"created_at" => "2020-04-16T13:40:15.000Z",
|
||||||
"display_name" => "lain",
|
"display_name" => "lain",
|
||||||
"fields" => [],
|
"fields" => [],
|
||||||
|
|
|
@ -252,7 +252,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Status do
|
||||||
"header" => "http://localhost:4001/images/banner.png",
|
"header" => "http://localhost:4001/images/banner.png",
|
||||||
"header_static" => "http://localhost:4001/images/banner.png",
|
"header_static" => "http://localhost:4001/images/banner.png",
|
||||||
"id" => "9toJCsKN7SmSf3aj5c",
|
"id" => "9toJCsKN7SmSf3aj5c",
|
||||||
"locked" => false,
|
"is_locked" => false,
|
||||||
"note" => "Tester Number 6",
|
"note" => "Tester Number 6",
|
||||||
"pleroma" => %{
|
"pleroma" => %{
|
||||||
"background_image" => nil,
|
"background_image" => nil,
|
||||||
|
|
|
@ -45,7 +45,8 @@ defmodule Pleroma.Web.CommonAPI do
|
||||||
{_, {:ok, %Activity{} = activity, _meta}} <-
|
{_, {:ok, %Activity{} = activity, _meta}} <-
|
||||||
{:common_pipeline,
|
{:common_pipeline,
|
||||||
Pipeline.common_pipeline(create_activity_data,
|
Pipeline.common_pipeline(create_activity_data,
|
||||||
local: true
|
local: true,
|
||||||
|
idempotency_key: opts[:idempotency_key]
|
||||||
)} do
|
)} do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
|
|
|
@ -274,7 +274,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
||||||
def format_input(text, format, options \\ [])
|
def format_input(text, format, options \\ [])
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Formatting text to plain text.
|
Formatting text to plain text, BBCode, HTML, or Markdown
|
||||||
"""
|
"""
|
||||||
def format_input(text, "text/plain", options) do
|
def format_input(text, "text/plain", options) do
|
||||||
text
|
text
|
||||||
|
@ -285,9 +285,6 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
||||||
end).()
|
end).()
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
|
||||||
Formatting text as BBCode.
|
|
||||||
"""
|
|
||||||
def format_input(text, "text/bbcode", options) do
|
def format_input(text, "text/bbcode", options) do
|
||||||
text
|
text
|
||||||
|> String.replace(~r/\r/, "")
|
|> String.replace(~r/\r/, "")
|
||||||
|
@ -297,18 +294,12 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|
||||||
|> Formatter.linkify(options)
|
|> Formatter.linkify(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
|
||||||
Formatting text to html.
|
|
||||||
"""
|
|
||||||
def format_input(text, "text/html", options) do
|
def format_input(text, "text/html", options) do
|
||||||
text
|
text
|
||||||
|> Formatter.html_escape("text/html")
|
|> Formatter.html_escape("text/html")
|
||||||
|> Formatter.linkify(options)
|
|> Formatter.linkify(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
|
||||||
Formatting text to markdown.
|
|
||||||
"""
|
|
||||||
def format_input(text, "text/markdown", options) do
|
def format_input(text, "text/markdown", options) do
|
||||||
text
|
text
|
||||||
|> Formatter.mentions_escape(options)
|
|> Formatter.mentions_escape(options)
|
||||||
|
|
|
@ -7,8 +7,12 @@ defmodule Pleroma.Web.Endpoint do
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
|
alias Pleroma.Config
|
||||||
|
|
||||||
socket("/socket", Pleroma.Web.UserSocket)
|
socket("/socket", Pleroma.Web.UserSocket)
|
||||||
|
|
||||||
|
plug(Plug.Telemetry, event_prefix: [:phoenix, :endpoint])
|
||||||
|
|
||||||
plug(Pleroma.Web.Plugs.SetLocalePlug)
|
plug(Pleroma.Web.Plugs.SetLocalePlug)
|
||||||
plug(CORSPlug)
|
plug(CORSPlug)
|
||||||
plug(Pleroma.Web.Plugs.HTTPSecurityPlug)
|
plug(Pleroma.Web.Plugs.HTTPSecurityPlug)
|
||||||
|
@ -86,19 +90,19 @@ defmodule Pleroma.Web.Endpoint do
|
||||||
plug(Plug.Parsers,
|
plug(Plug.Parsers,
|
||||||
parsers: [
|
parsers: [
|
||||||
:urlencoded,
|
:urlencoded,
|
||||||
{:multipart, length: {Pleroma.Config, :get, [[:instance, :upload_limit]]}},
|
{:multipart, length: {Config, :get, [[:instance, :upload_limit]]}},
|
||||||
:json
|
:json
|
||||||
],
|
],
|
||||||
pass: ["*/*"],
|
pass: ["*/*"],
|
||||||
json_decoder: Jason,
|
json_decoder: Jason,
|
||||||
length: Pleroma.Config.get([:instance, :upload_limit]),
|
length: Config.get([:instance, :upload_limit]),
|
||||||
body_reader: {Pleroma.Web.Plugs.DigestPlug, :read_body, []}
|
body_reader: {Pleroma.Web.Plugs.DigestPlug, :read_body, []}
|
||||||
)
|
)
|
||||||
|
|
||||||
plug(Plug.MethodOverride)
|
plug(Plug.MethodOverride)
|
||||||
plug(Plug.Head)
|
plug(Plug.Head)
|
||||||
|
|
||||||
secure_cookies = Pleroma.Config.get([__MODULE__, :secure_cookie_flag])
|
secure_cookies = Config.get([__MODULE__, :secure_cookie_flag])
|
||||||
|
|
||||||
cookie_name =
|
cookie_name =
|
||||||
if secure_cookies,
|
if secure_cookies,
|
||||||
|
@ -106,7 +110,7 @@ defmodule Pleroma.Web.Endpoint do
|
||||||
else: "pleroma_key"
|
else: "pleroma_key"
|
||||||
|
|
||||||
extra =
|
extra =
|
||||||
Pleroma.Config.get([__MODULE__, :extra_cookie_attrs])
|
Config.get([__MODULE__, :extra_cookie_attrs])
|
||||||
|> Enum.join(";")
|
|> Enum.join(";")
|
||||||
|
|
||||||
# The session will be stored in the cookie and signed,
|
# The session will be stored in the cookie and signed,
|
||||||
|
@ -116,7 +120,7 @@ defmodule Pleroma.Web.Endpoint do
|
||||||
Plug.Session,
|
Plug.Session,
|
||||||
store: :cookie,
|
store: :cookie,
|
||||||
key: cookie_name,
|
key: cookie_name,
|
||||||
signing_salt: Pleroma.Config.get([__MODULE__, :signing_salt], "CqaoopA2"),
|
signing_salt: Config.get([__MODULE__, :signing_salt], "CqaoopA2"),
|
||||||
http_only: true,
|
http_only: true,
|
||||||
secure: secure_cookies,
|
secure: secure_cookies,
|
||||||
extra: extra
|
extra: extra
|
||||||
|
@ -136,8 +140,34 @@ defmodule Pleroma.Web.Endpoint do
|
||||||
use Prometheus.PlugExporter
|
use Prometheus.PlugExporter
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defmodule MetricsExporterCaller do
|
||||||
|
@behaviour Plug
|
||||||
|
|
||||||
|
def init(opts), do: opts
|
||||||
|
|
||||||
|
def call(conn, opts) do
|
||||||
|
prometheus_config = Application.get_env(:prometheus, MetricsExporter, [])
|
||||||
|
ip_whitelist = List.wrap(prometheus_config[:ip_whitelist])
|
||||||
|
|
||||||
|
cond do
|
||||||
|
!prometheus_config[:enabled] ->
|
||||||
|
conn
|
||||||
|
|
||||||
|
ip_whitelist != [] and
|
||||||
|
!Enum.find(ip_whitelist, fn ip ->
|
||||||
|
Pleroma.Helpers.InetHelper.parse_address(ip) == {:ok, conn.remote_ip}
|
||||||
|
end) ->
|
||||||
|
conn
|
||||||
|
|
||||||
|
true ->
|
||||||
|
MetricsExporter.call(conn, opts)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
plug(PipelineInstrumenter)
|
plug(PipelineInstrumenter)
|
||||||
plug(MetricsExporter)
|
|
||||||
|
plug(MetricsExporterCaller)
|
||||||
|
|
||||||
plug(Pleroma.Web.Router)
|
plug(Pleroma.Web.Router)
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,14 @@ defmodule Pleroma.Web.Feed.TagController do
|
||||||
alias Pleroma.Web.Feed.FeedView
|
alias Pleroma.Web.Feed.FeedView
|
||||||
|
|
||||||
def feed(conn, params) do
|
def feed(conn, params) do
|
||||||
unless Pleroma.Config.restrict_unauthenticated_access?(:activities, :local) do
|
if Config.get!([:instance, :public]) do
|
||||||
render_feed(conn, params)
|
render_feed(conn, params)
|
||||||
else
|
else
|
||||||
render_error(conn, :not_found, "Not found")
|
render_error(conn, :not_found, "Not found")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_feed(conn, %{"tag" => raw_tag} = params) do
|
defp render_feed(conn, %{"tag" => raw_tag} = params) do
|
||||||
{format, tag} = parse_tag(raw_tag)
|
{format, tag} = parse_tag(raw_tag)
|
||||||
|
|
||||||
activities =
|
activities =
|
||||||
|
@ -36,12 +36,13 @@ defmodule Pleroma.Web.Feed.TagController do
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec parse_tag(binary() | any()) :: {format :: String.t(), tag :: String.t()}
|
@spec parse_tag(binary() | any()) :: {format :: String.t(), tag :: String.t()}
|
||||||
defp parse_tag(raw_tag) when is_binary(raw_tag) do
|
defp parse_tag(raw_tag) do
|
||||||
case Enum.reverse(String.split(raw_tag, ".")) do
|
case is_binary(raw_tag) && Enum.reverse(String.split(raw_tag, ".")) do
|
||||||
[format | tag] when format in ["atom", "rss"] -> {format, Enum.join(tag, ".")}
|
[format | tag] when format in ["rss", "atom"] ->
|
||||||
_ -> {"rss", raw_tag}
|
{format, Enum.join(tag, ".")}
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
{"atom", raw_tag}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp parse_tag(raw_tag), do: {"rss", raw_tag}
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
defmodule Pleroma.Web.Feed.UserController do
|
defmodule Pleroma.Web.Feed.UserController do
|
||||||
use Pleroma.Web, :controller
|
use Pleroma.Web, :controller
|
||||||
|
|
||||||
|
alias Pleroma.Config
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPubController
|
alias Pleroma.Web.ActivityPub.ActivityPubController
|
||||||
|
@ -22,12 +23,7 @@ defmodule Pleroma.Web.Feed.UserController do
|
||||||
|
|
||||||
def feed_redirect(%{assigns: %{format: format}} = conn, _params)
|
def feed_redirect(%{assigns: %{format: format}} = conn, _params)
|
||||||
when format in ["json", "activity+json"] do
|
when format in ["json", "activity+json"] do
|
||||||
with %{halted: false} = conn <-
|
ActivityPubController.call(conn, :user)
|
||||||
Pleroma.Web.Plugs.EnsureAuthenticatedPlug.call(conn,
|
|
||||||
unless_func: &Pleroma.Web.Plugs.FederatingPlug.federating?/1
|
|
||||||
) do
|
|
||||||
ActivityPubController.call(conn, :user)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def feed_redirect(conn, %{"nickname" => nickname}) do
|
def feed_redirect(conn, %{"nickname" => nickname}) do
|
||||||
|
@ -36,25 +32,18 @@ defmodule Pleroma.Web.Feed.UserController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def feed(conn, params) do
|
def feed(conn, %{"nickname" => nickname} = params) do
|
||||||
unless Pleroma.Config.restrict_unauthenticated_access?(:profiles, :local) do
|
|
||||||
render_feed(conn, params)
|
|
||||||
else
|
|
||||||
errors(conn, {:error, :not_found})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def render_feed(conn, %{"nickname" => nickname} = params) do
|
|
||||||
format = get_format(conn)
|
format = get_format(conn)
|
||||||
|
|
||||||
format =
|
format =
|
||||||
if format in ["rss", "atom"] do
|
if format in ["atom", "rss"] do
|
||||||
format
|
format
|
||||||
else
|
else
|
||||||
"atom"
|
"atom"
|
||||||
end
|
end
|
||||||
|
|
||||||
with {_, %User{local: true} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do
|
with {_, %User{local: true} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)},
|
||||||
|
{_, :visible} <- {:visibility, User.visible_for(user, _reading_user = nil)} do
|
||||||
activities =
|
activities =
|
||||||
%{
|
%{
|
||||||
type: ["Create"],
|
type: ["Create"],
|
||||||
|
@ -69,7 +58,7 @@ defmodule Pleroma.Web.Feed.UserController do
|
||||||
|> render("user.#{format}",
|
|> render("user.#{format}",
|
||||||
user: user,
|
user: user,
|
||||||
activities: activities,
|
activities: activities,
|
||||||
feed_config: Pleroma.Config.get([:feed])
|
feed_config: Config.get([:feed])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -81,6 +70,8 @@ defmodule Pleroma.Web.Feed.UserController do
|
||||||
def errors(conn, {:fetch_user, %User{local: false}}), do: errors(conn, {:error, :not_found})
|
def errors(conn, {:fetch_user, %User{local: false}}), do: errors(conn, {:error, :not_found})
|
||||||
def errors(conn, {:fetch_user, nil}), do: errors(conn, {:error, :not_found})
|
def errors(conn, {:fetch_user, nil}), do: errors(conn, {:error, :not_found})
|
||||||
|
|
||||||
|
def errors(conn, {:visibility, _}), do: errors(conn, {:error, :not_found})
|
||||||
|
|
||||||
def errors(conn, _) do
|
def errors(conn, _) do
|
||||||
render_error(conn, :internal_server_error, "Something went wrong")
|
render_error(conn, :internal_server_error, "Something went wrong")
|
||||||
end
|
end
|
||||||
|
|
|
@ -177,7 +177,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
||||||
user_params =
|
user_params =
|
||||||
[
|
[
|
||||||
:no_rich_text,
|
:no_rich_text,
|
||||||
:locked,
|
|
||||||
:hide_followers_count,
|
:hide_followers_count,
|
||||||
:hide_follows_count,
|
:hide_follows_count,
|
||||||
:hide_followers,
|
:hide_followers,
|
||||||
|
@ -186,7 +185,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
||||||
:show_role,
|
:show_role,
|
||||||
:skip_thread_containment,
|
:skip_thread_containment,
|
||||||
:allow_following_move,
|
:allow_following_move,
|
||||||
:discoverable,
|
|
||||||
:accepts_chat_messages
|
:accepts_chat_messages
|
||||||
]
|
]
|
||||||
|> Enum.reduce(%{}, fn key, acc ->
|
|> Enum.reduce(%{}, fn key, acc ->
|
||||||
|
@ -210,6 +208,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
||||||
if bot, do: {:ok, "Service"}, else: {:ok, "Person"}
|
if bot, do: {:ok, "Service"}, else: {:ok, "Person"}
|
||||||
end)
|
end)
|
||||||
|> Maps.put_if_present(:actor_type, params[:actor_type])
|
|> Maps.put_if_present(:actor_type, params[:actor_type])
|
||||||
|
|> Maps.put_if_present(:is_locked, params[:locked])
|
||||||
|
|> Maps.put_if_present(:is_discoverable, params[:discoverable])
|
||||||
|
|
||||||
# What happens here:
|
# What happens here:
|
||||||
#
|
#
|
||||||
|
@ -442,15 +442,27 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "GET /api/v1/mutes"
|
@doc "GET /api/v1/mutes"
|
||||||
def mutes(%{assigns: %{user: user}} = conn, _) do
|
def mutes(%{assigns: %{user: user}} = conn, params) do
|
||||||
users = User.muted_users(user, _restrict_deactivated = true)
|
users =
|
||||||
render(conn, "index.json", users: users, for: user, as: :user)
|
user
|
||||||
|
|> User.muted_users_relation(_restrict_deactivated = true)
|
||||||
|
|> Pleroma.Pagination.fetch_paginated(Map.put(params, :skip_order, true))
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> add_link_headers(users)
|
||||||
|
|> render("index.json", users: users, for: user, as: :user)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "GET /api/v1/blocks"
|
@doc "GET /api/v1/blocks"
|
||||||
def blocks(%{assigns: %{user: user}} = conn, _) do
|
def blocks(%{assigns: %{user: user}} = conn, params) do
|
||||||
users = User.blocked_users(user, _restrict_deactivated = true)
|
users =
|
||||||
render(conn, "index.json", users: users, for: user, as: :user)
|
user
|
||||||
|
|> User.blocked_users_relation(_restrict_deactivated = true)
|
||||||
|
|> Pleroma.Pagination.fetch_paginated(Map.put(params, :skip_order, true))
|
||||||
|
|
||||||
|
conn
|
||||||
|
|> add_link_headers(users)
|
||||||
|
|> render("index.json", users: users, for: user, as: :user)
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "GET /api/v1/endorsements"
|
@doc "GET /api/v1/endorsements"
|
||||||
|
|
|
@ -24,7 +24,7 @@ defmodule Pleroma.Web.MastodonAPI.AuthController do
|
||||||
redirect(conn, to: local_mastodon_root_path(conn))
|
redirect(conn, to: local_mastodon_root_path(conn))
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "Local Mastodon FE login init action"
|
# Local Mastodon FE login init action
|
||||||
def login(conn, %{"code" => auth_token}) do
|
def login(conn, %{"code" => auth_token}) do
|
||||||
with {:ok, app} <- get_or_make_app(),
|
with {:ok, app} <- get_or_make_app(),
|
||||||
{:ok, auth} <- Authorization.get_by_token(app, auth_token),
|
{:ok, auth} <- Authorization.get_by_token(app, auth_token),
|
||||||
|
@ -35,7 +35,7 @@ defmodule Pleroma.Web.MastodonAPI.AuthController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc "Local Mastodon FE callback action"
|
# Local Mastodon FE callback action
|
||||||
def login(conn, _) do
|
def login(conn, _) do
|
||||||
with {:ok, app} <- get_or_make_app() do
|
with {:ok, app} <- get_or_make_app() do
|
||||||
path =
|
path =
|
||||||
|
|
|
@ -11,6 +11,7 @@ defmodule Pleroma.Web.MastodonAPI.MediaController do
|
||||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||||
|
|
||||||
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
|
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
|
||||||
|
plug(Majic.Plug, [pool: Pleroma.MajicPool] when action in [:create, :create2])
|
||||||
plug(Pleroma.Web.ApiSpec.CastAndValidate)
|
plug(Pleroma.Web.ApiSpec.CastAndValidate)
|
||||||
plug(:put_view, Pleroma.Web.MastodonAPI.StatusView)
|
plug(:put_view, Pleroma.Web.MastodonAPI.StatusView)
|
||||||
|
|
||||||
|
|
|
@ -127,9 +127,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
POST /api/v1/statuses
|
POST /api/v1/statuses
|
||||||
|
|
||||||
Creates a scheduled status when `scheduled_at` param is present and it's far enough
|
|
||||||
"""
|
"""
|
||||||
|
# Creates a scheduled status when `scheduled_at` param is present and it's far enough
|
||||||
def create(
|
def create(
|
||||||
%{
|
%{
|
||||||
assigns: %{user: user},
|
assigns: %{user: user},
|
||||||
|
@ -160,11 +159,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
# Creates a regular status
|
||||||
POST /api/v1/statuses
|
|
||||||
|
|
||||||
Creates a regular status
|
|
||||||
"""
|
|
||||||
def create(%{assigns: %{user: user}, body_params: %{status: _} = params} = conn, _) do
|
def create(%{assigns: %{user: user}, body_params: %{status: _} = params} = conn, _) do
|
||||||
params = Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id])
|
params = Map.put(params, :in_reply_to_status_id, params[:in_reply_to_id])
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
||||||
username: username_from_nickname(user.nickname),
|
username: username_from_nickname(user.nickname),
|
||||||
acct: user.nickname,
|
acct: user.nickname,
|
||||||
display_name: display_name,
|
display_name: display_name,
|
||||||
locked: user.locked,
|
locked: user.is_locked,
|
||||||
created_at: Utils.to_masto_date(user.inserted_at),
|
created_at: Utils.to_masto_date(user.inserted_at),
|
||||||
followers_count: followers_count,
|
followers_count: followers_count,
|
||||||
following_count: following_count,
|
following_count: following_count,
|
||||||
|
@ -261,7 +261,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
fields: user.raw_fields,
|
fields: user.raw_fields,
|
||||||
pleroma: %{
|
pleroma: %{
|
||||||
discoverable: user.discoverable,
|
discoverable: user.is_discoverable,
|
||||||
actor_type: user.actor_type
|
actor_type: user.actor_type
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -388,7 +388,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
||||||
data
|
data
|
||||||
|> Kernel.put_in(
|
|> Kernel.put_in(
|
||||||
[:pleroma, :unread_conversation_count],
|
[:pleroma, :unread_conversation_count],
|
||||||
user.unread_conversation_count
|
Pleroma.Conversation.Participation.unread_count(user)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,15 @@ defmodule Pleroma.Web.MastodonAPI.ConversationView do
|
||||||
end
|
end
|
||||||
|
|
||||||
activity = Activity.get_by_id_with_object(last_activity_id)
|
activity = Activity.get_by_id_with_object(last_activity_id)
|
||||||
# Conversations return all users except the current user.
|
|
||||||
users = Enum.reject(participation.recipients, &(&1.id == user.id))
|
# Conversations return all users except the current user,
|
||||||
|
# except when the current user is the only participant
|
||||||
|
users =
|
||||||
|
if length(participation.recipients) > 1 do
|
||||||
|
Enum.reject(participation.recipients, &(&1.id == user.id))
|
||||||
|
else
|
||||||
|
participation.recipients
|
||||||
|
end
|
||||||
|
|
||||||
%{
|
%{
|
||||||
id: participation.id |> to_string(),
|
id: participation.id |> to_string(),
|
||||||
|
@ -43,7 +50,8 @@ defmodule Pleroma.Web.MastodonAPI.ConversationView do
|
||||||
last_status:
|
last_status:
|
||||||
render(StatusView, "show.json",
|
render(StatusView, "show.json",
|
||||||
activity: activity,
|
activity: activity,
|
||||||
direct_conversation_id: participation.id
|
direct_conversation_id: participation.id,
|
||||||
|
for: user
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,7 +30,7 @@ defmodule Pleroma.Web.MediaProxy.Invalidation.Http do
|
||||||
{:ok, %{status: status} = env} when 400 <= status and status < 500 ->
|
{:ok, %{status: status} = env} when 400 <= status and status < 500 ->
|
||||||
{:error, env}
|
{:error, env}
|
||||||
|
|
||||||
{:error, error} = error ->
|
{:error, _} = error ->
|
||||||
error
|
error
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
|
|
|
@ -10,7 +10,7 @@ defmodule Pleroma.Web.Metadata.Providers.RestrictIndexing do
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def build_tags(%{user: %{local: true, discoverable: true}}), do: []
|
def build_tags(%{user: %{local: true, is_discoverable: true}}), do: []
|
||||||
|
|
||||||
def build_tags(_) do
|
def build_tags(_) do
|
||||||
[
|
[
|
||||||
|
|
|
@ -16,10 +16,6 @@ defmodule Pleroma.Web.OStatus.OStatusController do
|
||||||
alias Pleroma.Web.Plugs.RateLimiter
|
alias Pleroma.Web.Plugs.RateLimiter
|
||||||
alias Pleroma.Web.Router
|
alias Pleroma.Web.Router
|
||||||
|
|
||||||
plug(Pleroma.Web.Plugs.EnsureAuthenticatedPlug,
|
|
||||||
unless_func: &Pleroma.Web.Plugs.FederatingPlug.federating?/1
|
|
||||||
)
|
|
||||||
|
|
||||||
plug(
|
plug(
|
||||||
RateLimiter,
|
RateLimiter,
|
||||||
[name: :ap_routes, params: ["uuid"]] when action in [:object, :activity]
|
[name: :ap_routes, params: ["uuid"]] when action in [:object, :activity]
|
||||||
|
@ -37,14 +33,12 @@ defmodule Pleroma.Web.OStatus.OStatusController do
|
||||||
ActivityPubController.call(conn, :object)
|
ActivityPubController.call(conn, :object)
|
||||||
end
|
end
|
||||||
|
|
||||||
def object(%{assigns: %{format: format}} = conn, _params) do
|
def object(conn, _params) do
|
||||||
with id <- Endpoint.url() <> conn.request_path,
|
with id <- Endpoint.url() <> conn.request_path,
|
||||||
{_, %Activity{} = activity} <-
|
{_, %Activity{} = activity} <-
|
||||||
{:activity, Activity.get_create_by_object_ap_id_with_object(id)},
|
{:activity, Activity.get_create_by_object_ap_id_with_object(id)},
|
||||||
{_, true} <- {:public?, Visibility.is_public?(activity)} do
|
{_, true} <- {:public?, Visibility.is_public?(activity)} do
|
||||||
case format do
|
redirect(conn, to: "/notice/#{activity.id}")
|
||||||
_ -> redirect(conn, to: "/notice/#{activity.id}")
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
reason when reason in [{:public?, false}, {:activity, nil}] ->
|
reason when reason in [{:public?, false}, {:activity, nil}] ->
|
||||||
{:error, :not_found}
|
{:error, :not_found}
|
||||||
|
@ -59,13 +53,11 @@ defmodule Pleroma.Web.OStatus.OStatusController do
|
||||||
ActivityPubController.call(conn, :activity)
|
ActivityPubController.call(conn, :activity)
|
||||||
end
|
end
|
||||||
|
|
||||||
def activity(%{assigns: %{format: format}} = conn, _params) do
|
def activity(conn, _params) do
|
||||||
with id <- Endpoint.url() <> conn.request_path,
|
with id <- Endpoint.url() <> conn.request_path,
|
||||||
{_, %Activity{} = activity} <- {:activity, Activity.normalize(id)},
|
{_, %Activity{} = activity} <- {:activity, Activity.normalize(id)},
|
||||||
{_, true} <- {:public?, Visibility.is_public?(activity)} do
|
{_, true} <- {:public?, Visibility.is_public?(activity)} do
|
||||||
case format do
|
redirect(conn, to: "/notice/#{activity.id}")
|
||||||
_ -> redirect(conn, to: "/notice/#{activity.id}")
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
reason when reason in [{:public?, false}, {:activity, nil}] ->
|
reason when reason in [{:public?, false}, {:activity, nil}] ->
|
||||||
{:error, :not_found}
|
{:error, :not_found}
|
||||||
|
@ -119,6 +111,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
|
||||||
def notice_player(conn, %{"id" => id}) do
|
def notice_player(conn, %{"id" => id}) do
|
||||||
with %Activity{data: %{"type" => "Create"}} = activity <- Activity.get_by_id_with_object(id),
|
with %Activity{data: %{"type" => "Create"}} = activity <- Activity.get_by_id_with_object(id),
|
||||||
true <- Visibility.is_public?(activity),
|
true <- Visibility.is_public?(activity),
|
||||||
|
{_, true} <- {:visible?, Visibility.visible_for_user?(activity, _reading_user = nil)},
|
||||||
%Object{} = object <- Object.normalize(activity),
|
%Object{} = object <- Object.normalize(activity),
|
||||||
%{data: %{"attachment" => [%{"url" => [url | _]} | _]}} <- object,
|
%{data: %{"attachment" => [%{"url" => [url | _]} | _]}} <- object,
|
||||||
true <- String.starts_with?(url["mediaType"], ["audio", "video"]) do
|
true <- String.starts_with?(url["mediaType"], ["audio", "video"]) do
|
||||||
|
|
|
@ -17,6 +17,11 @@ defmodule Pleroma.Web.PleromaAPI.AccountController do
|
||||||
|
|
||||||
require Pleroma.Constants
|
require Pleroma.Constants
|
||||||
|
|
||||||
|
plug(
|
||||||
|
Majic.Plug,
|
||||||
|
[pool: Pleroma.MajicPool] when action in [:update_avatar, :update_background, :update_banner]
|
||||||
|
)
|
||||||
|
|
||||||
plug(
|
plug(
|
||||||
OpenApiSpex.Plug.PutApiSpec,
|
OpenApiSpex.Plug.PutApiSpec,
|
||||||
[module: Pleroma.Web.ApiSpec] when action == :confirmation_resend
|
[module: Pleroma.Web.ApiSpec] when action == :confirmation_resend
|
||||||
|
|
28
lib/pleroma/web/pleroma_api/controllers/backup_controller.ex
Normal file
28
lib/pleroma/web/pleroma_api/controllers/backup_controller.ex
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.PleromaAPI.BackupController do
|
||||||
|
use Pleroma.Web, :controller
|
||||||
|
|
||||||
|
alias Pleroma.User.Backup
|
||||||
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||||
|
|
||||||
|
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
|
||||||
|
plug(OAuthScopesPlug, %{scopes: ["read:accounts"]} when action in [:index, :create])
|
||||||
|
plug(OpenApiSpex.Plug.CastAndValidate, render_error: Pleroma.Web.ApiSpec.RenderError)
|
||||||
|
|
||||||
|
defdelegate open_api_operation(action), to: Pleroma.Web.ApiSpec.PleromaBackupOperation
|
||||||
|
|
||||||
|
def index(%{assigns: %{user: user}} = conn, _params) do
|
||||||
|
backups = Backup.list(user)
|
||||||
|
render(conn, "index.json", backups: backups)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create(%{assigns: %{user: user}} = conn, _params) do
|
||||||
|
with {:ok, _} <- Backup.create(user) do
|
||||||
|
backups = Backup.list(user)
|
||||||
|
render(conn, "index.json", backups: backups)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -15,7 +15,6 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.CommonAPI
|
alias Pleroma.Web.CommonAPI
|
||||||
alias Pleroma.Web.PleromaAPI.Chat.MessageReferenceView
|
alias Pleroma.Web.PleromaAPI.Chat.MessageReferenceView
|
||||||
alias Pleroma.Web.PleromaAPI.ChatView
|
|
||||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||||
|
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
@ -80,7 +79,8 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
|
||||||
%User{} = recipient <- User.get_cached_by_ap_id(chat.recipient),
|
%User{} = recipient <- User.get_cached_by_ap_id(chat.recipient),
|
||||||
{:ok, activity} <-
|
{:ok, activity} <-
|
||||||
CommonAPI.post_chat_message(user, recipient, params[:content],
|
CommonAPI.post_chat_message(user, recipient, params[:content],
|
||||||
media_id: params[:media_id]
|
media_id: params[:media_id],
|
||||||
|
idempotency_key: idempotency_key(conn)
|
||||||
),
|
),
|
||||||
message <- Object.normalize(activity, false),
|
message <- Object.normalize(activity, false),
|
||||||
cm_ref <- MessageReference.for_chat_and_object(chat, message) do
|
cm_ref <- MessageReference.for_chat_and_object(chat, message) do
|
||||||
|
@ -120,9 +120,7 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
|
||||||
) do
|
) do
|
||||||
with {:ok, chat} <- Chat.get_by_user_and_id(user, id),
|
with {:ok, chat} <- Chat.get_by_user_and_id(user, id),
|
||||||
{_n, _} <- MessageReference.set_all_seen_for_chat(chat, last_read_id) do
|
{_n, _} <- MessageReference.set_all_seen_for_chat(chat, last_read_id) do
|
||||||
conn
|
render(conn, "show.json", chat: chat)
|
||||||
|> put_view(ChatView)
|
|
||||||
|> render("show.json", chat: chat)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -140,33 +138,37 @@ defmodule Pleroma.Web.PleromaAPI.ChatController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def index(%{assigns: %{user: %{id: user_id} = user}} = conn, _params) do
|
def index(%{assigns: %{user: %{id: user_id} = user}} = conn, params) do
|
||||||
blocked_ap_ids = User.blocked_users_ap_ids(user)
|
exclude_users =
|
||||||
|
User.blocked_users_ap_ids(user) ++
|
||||||
|
if params[:with_muted], do: [], else: User.muted_users_ap_ids(user)
|
||||||
|
|
||||||
chats =
|
chats =
|
||||||
Chat.for_user_query(user_id)
|
user_id
|
||||||
|> where([c], c.recipient not in ^blocked_ap_ids)
|
|> Chat.for_user_query()
|
||||||
|
|> where([c], c.recipient not in ^exclude_users)
|
||||||
|> Repo.all()
|
|> Repo.all()
|
||||||
|
|
||||||
conn
|
render(conn, "index.json", chats: chats)
|
||||||
|> put_view(ChatView)
|
|
||||||
|> render("index.json", chats: chats)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create(%{assigns: %{user: user}} = conn, %{id: id}) do
|
def create(%{assigns: %{user: user}} = conn, %{id: id}) do
|
||||||
with %User{ap_id: recipient} <- User.get_cached_by_id(id),
|
with %User{ap_id: recipient} <- User.get_cached_by_id(id),
|
||||||
{:ok, %Chat{} = chat} <- Chat.get_or_create(user.id, recipient) do
|
{:ok, %Chat{} = chat} <- Chat.get_or_create(user.id, recipient) do
|
||||||
conn
|
render(conn, "show.json", chat: chat)
|
||||||
|> put_view(ChatView)
|
|
||||||
|> render("show.json", chat: chat)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show(%{assigns: %{user: user}} = conn, %{id: id}) do
|
def show(%{assigns: %{user: user}} = conn, %{id: id}) do
|
||||||
with {:ok, chat} <- Chat.get_by_user_and_id(user, id) do
|
with {:ok, chat} <- Chat.get_by_user_and_id(user, id) do
|
||||||
conn
|
render(conn, "show.json", chat: chat)
|
||||||
|> put_view(ChatView)
|
end
|
||||||
|> render("show.json", chat: chat)
|
end
|
||||||
|
|
||||||
|
defp idempotency_key(conn) do
|
||||||
|
case get_req_header(conn, "idempotency-key") do
|
||||||
|
[key] -> key
|
||||||
|
_ -> nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ defmodule Pleroma.Web.PleromaAPI.MascotController do
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
alias Pleroma.Web.Plugs.OAuthScopesPlug
|
||||||
|
|
||||||
|
plug(Majic.Plug, [pool: Pleroma.MajicPool] when action in [:update])
|
||||||
plug(Pleroma.Web.ApiSpec.CastAndValidate)
|
plug(Pleroma.Web.ApiSpec.CastAndValidate)
|
||||||
plug(OAuthScopesPlug, %{scopes: ["read:accounts"]} when action == :show)
|
plug(OAuthScopesPlug, %{scopes: ["read:accounts"]} when action == :show)
|
||||||
plug(OAuthScopesPlug, %{scopes: ["write:accounts"]} when action != :show)
|
plug(OAuthScopesPlug, %{scopes: ["write:accounts"]} when action != :show)
|
||||||
|
@ -22,14 +23,15 @@ defmodule Pleroma.Web.PleromaAPI.MascotController do
|
||||||
|
|
||||||
@doc "PUT /api/v1/pleroma/mascot"
|
@doc "PUT /api/v1/pleroma/mascot"
|
||||||
def update(%{assigns: %{user: user}, body_params: %{file: file}} = conn, _) do
|
def update(%{assigns: %{user: user}, body_params: %{file: file}} = conn, _) do
|
||||||
with {:ok, object} <- ActivityPub.upload(file, actor: User.ap_id(user)),
|
with {:content_type, "image" <> _} <- {:content_type, file.content_type},
|
||||||
# Reject if not an image
|
{:ok, object} <- ActivityPub.upload(file, actor: User.ap_id(user)) do
|
||||||
%{type: "image"} = attachment <- render_attachment(object) do
|
attachment = render_attachment(object)
|
||||||
{:ok, _user} = User.mascot_update(user, attachment)
|
{:ok, _user} = User.mascot_update(user, attachment)
|
||||||
|
|
||||||
json(conn, attachment)
|
json(conn, attachment)
|
||||||
else
|
else
|
||||||
%{type: _} -> render_error(conn, :unsupported_media_type, "mascots can only be images")
|
{:content_type, _} ->
|
||||||
|
render_error(conn, :unsupported_media_type, "mascots can only be images")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
28
lib/pleroma/web/pleroma_api/views/backup_view.ex
Normal file
28
lib/pleroma/web/pleroma_api/views/backup_view.ex
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.PleromaAPI.BackupView do
|
||||||
|
use Pleroma.Web, :view
|
||||||
|
|
||||||
|
alias Pleroma.User.Backup
|
||||||
|
alias Pleroma.Web.CommonAPI.Utils
|
||||||
|
|
||||||
|
def render("show.json", %{backup: %Backup{} = backup}) do
|
||||||
|
%{
|
||||||
|
content_type: backup.content_type,
|
||||||
|
url: download_url(backup),
|
||||||
|
file_size: backup.file_size,
|
||||||
|
processed: backup.processed,
|
||||||
|
inserted_at: Utils.to_masto_date(backup.inserted_at)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def render("index.json", %{backups: backups}) do
|
||||||
|
render_many(backups, __MODULE__, "show.json")
|
||||||
|
end
|
||||||
|
|
||||||
|
def download_url(%Backup{file_name: file_name}) do
|
||||||
|
Pleroma.Web.Endpoint.url() <> "/media/backups/" <> file_name
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,6 +5,7 @@
|
||||||
defmodule Pleroma.Web.PleromaAPI.Chat.MessageReferenceView do
|
defmodule Pleroma.Web.PleromaAPI.Chat.MessageReferenceView do
|
||||||
use Pleroma.Web, :view
|
use Pleroma.Web, :view
|
||||||
|
|
||||||
|
alias Pleroma.Maps
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.CommonAPI.Utils
|
alias Pleroma.Web.CommonAPI.Utils
|
||||||
alias Pleroma.Web.MastodonAPI.StatusView
|
alias Pleroma.Web.MastodonAPI.StatusView
|
||||||
|
@ -37,6 +38,7 @@ defmodule Pleroma.Web.PleromaAPI.Chat.MessageReferenceView do
|
||||||
Pleroma.Web.RichMedia.Helpers.fetch_data_for_object(object)
|
Pleroma.Web.RichMedia.Helpers.fetch_data_for_object(object)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|> put_idempotency_key()
|
||||||
end
|
end
|
||||||
|
|
||||||
def render("index.json", opts) do
|
def render("index.json", opts) do
|
||||||
|
@ -47,4 +49,13 @@ defmodule Pleroma.Web.PleromaAPI.Chat.MessageReferenceView do
|
||||||
Map.put(opts, :as, :chat_message_reference)
|
Map.put(opts, :as, :chat_message_reference)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp put_idempotency_key(data) do
|
||||||
|
with {:ok, idempotency_key} <- Cachex.get(:chat_message_id_idempotency_key_cache, data.id) do
|
||||||
|
data
|
||||||
|
|> Maps.put_if_present(:idempotency_key, idempotency_key)
|
||||||
|
else
|
||||||
|
_ -> data
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,22 +34,26 @@ defmodule Pleroma.Web.Plugs.FrontendStatic do
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(conn, opts) do
|
def call(conn, opts) do
|
||||||
frontend_type = Map.get(opts, :frontend_type, :primary)
|
with false <- invalid_path?(conn.path_info),
|
||||||
path = file_path("", frontend_type)
|
frontend_type <- Map.get(opts, :frontend_type, :primary),
|
||||||
|
path when not is_nil(path) <- file_path("", frontend_type) do
|
||||||
if path do
|
call_static(conn, opts, path)
|
||||||
conn
|
|
||||||
|> call_static(opts, path)
|
|
||||||
else
|
else
|
||||||
conn
|
_ ->
|
||||||
|
conn
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp call_static(conn, opts, from) do
|
defp invalid_path?(list) do
|
||||||
opts =
|
invalid_path?(list, :binary.compile_pattern(["/", "\\", ":", "\0"]))
|
||||||
opts
|
end
|
||||||
|> Map.put(:from, from)
|
|
||||||
|
|
||||||
|
defp invalid_path?([h | _], _match) when h in [".", "..", ""], do: true
|
||||||
|
defp invalid_path?([h | t], match), do: String.contains?(h, match) or invalid_path?(t)
|
||||||
|
defp invalid_path?([], _match), do: false
|
||||||
|
|
||||||
|
defp call_static(conn, opts, from) do
|
||||||
|
opts = Map.put(opts, :from, from)
|
||||||
Plug.Static.call(conn, opts)
|
Plug.Static.call(conn, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,26 @@
|
||||||
defmodule Pleroma.Web.Router do
|
defmodule Pleroma.Web.Router do
|
||||||
use Pleroma.Web, :router
|
use Pleroma.Web, :router
|
||||||
|
|
||||||
|
pipeline :accepts_html do
|
||||||
|
plug(:accepts, ["html"])
|
||||||
|
end
|
||||||
|
|
||||||
|
pipeline :accepts_html_xml do
|
||||||
|
plug(:accepts, ["html", "xml", "rss", "atom"])
|
||||||
|
end
|
||||||
|
|
||||||
|
pipeline :accepts_html_json do
|
||||||
|
plug(:accepts, ["html", "activity+json", "json"])
|
||||||
|
end
|
||||||
|
|
||||||
|
pipeline :accepts_html_xml_json do
|
||||||
|
plug(:accepts, ["html", "xml", "rss", "atom", "activity+json", "json"])
|
||||||
|
end
|
||||||
|
|
||||||
|
pipeline :accepts_xml_rss_atom do
|
||||||
|
plug(:accepts, ["xml", "rss", "atom"])
|
||||||
|
end
|
||||||
|
|
||||||
pipeline :browser do
|
pipeline :browser do
|
||||||
plug(:accepts, ["html"])
|
plug(:accepts, ["html"])
|
||||||
plug(:fetch_session)
|
plug(:fetch_session)
|
||||||
|
@ -129,16 +149,7 @@ defmodule Pleroma.Web.Router do
|
||||||
scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
|
scope "/api/pleroma/admin", Pleroma.Web.AdminAPI do
|
||||||
pipe_through(:admin_api)
|
pipe_through(:admin_api)
|
||||||
|
|
||||||
post("/users/follow", AdminAPIController, :user_follow)
|
|
||||||
post("/users/unfollow", AdminAPIController, :user_unfollow)
|
|
||||||
|
|
||||||
put("/users/disable_mfa", AdminAPIController, :disable_mfa)
|
put("/users/disable_mfa", AdminAPIController, :disable_mfa)
|
||||||
delete("/users", AdminAPIController, :user_delete)
|
|
||||||
post("/users", AdminAPIController, :users_create)
|
|
||||||
patch("/users/:nickname/toggle_activation", AdminAPIController, :user_toggle_activation)
|
|
||||||
patch("/users/activate", AdminAPIController, :user_activate)
|
|
||||||
patch("/users/deactivate", AdminAPIController, :user_deactivate)
|
|
||||||
patch("/users/approve", AdminAPIController, :user_approve)
|
|
||||||
put("/users/tag", AdminAPIController, :tag_users)
|
put("/users/tag", AdminAPIController, :tag_users)
|
||||||
delete("/users/tag", AdminAPIController, :untag_users)
|
delete("/users/tag", AdminAPIController, :untag_users)
|
||||||
|
|
||||||
|
@ -161,6 +172,15 @@ defmodule Pleroma.Web.Router do
|
||||||
:right_delete_multiple
|
:right_delete_multiple
|
||||||
)
|
)
|
||||||
|
|
||||||
|
post("/users/follow", UserController, :follow)
|
||||||
|
post("/users/unfollow", UserController, :unfollow)
|
||||||
|
delete("/users", UserController, :delete)
|
||||||
|
post("/users", UserController, :create)
|
||||||
|
patch("/users/:nickname/toggle_activation", UserController, :toggle_activation)
|
||||||
|
patch("/users/activate", UserController, :activate)
|
||||||
|
patch("/users/deactivate", UserController, :deactivate)
|
||||||
|
patch("/users/approve", UserController, :approve)
|
||||||
|
|
||||||
get("/relay", RelayController, :index)
|
get("/relay", RelayController, :index)
|
||||||
post("/relay", RelayController, :follow)
|
post("/relay", RelayController, :follow)
|
||||||
delete("/relay", RelayController, :unfollow)
|
delete("/relay", RelayController, :unfollow)
|
||||||
|
@ -175,8 +195,8 @@ defmodule Pleroma.Web.Router do
|
||||||
get("/users/:nickname/credentials", AdminAPIController, :show_user_credentials)
|
get("/users/:nickname/credentials", AdminAPIController, :show_user_credentials)
|
||||||
patch("/users/:nickname/credentials", AdminAPIController, :update_user_credentials)
|
patch("/users/:nickname/credentials", AdminAPIController, :update_user_credentials)
|
||||||
|
|
||||||
get("/users", AdminAPIController, :list_users)
|
get("/users", UserController, :list)
|
||||||
get("/users/:nickname", AdminAPIController, :user_show)
|
get("/users/:nickname", UserController, :show)
|
||||||
get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
|
get("/users/:nickname/statuses", AdminAPIController, :list_user_statuses)
|
||||||
get("/users/:nickname/chats", AdminAPIController, :list_user_chats)
|
get("/users/:nickname/chats", AdminAPIController, :list_user_chats)
|
||||||
|
|
||||||
|
@ -223,6 +243,8 @@ defmodule Pleroma.Web.Router do
|
||||||
get("/chats/:id", ChatController, :show)
|
get("/chats/:id", ChatController, :show)
|
||||||
get("/chats/:id/messages", ChatController, :messages)
|
get("/chats/:id/messages", ChatController, :messages)
|
||||||
delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
|
delete("/chats/:id/messages/:message_id", ChatController, :delete_message)
|
||||||
|
|
||||||
|
post("/backups", AdminAPIController, :create_backup)
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/api/pleroma/emoji", Pleroma.Web.PleromaAPI do
|
scope "/api/pleroma/emoji", Pleroma.Web.PleromaAPI do
|
||||||
|
@ -353,6 +375,9 @@ defmodule Pleroma.Web.Router do
|
||||||
put("/mascot", MascotController, :update)
|
put("/mascot", MascotController, :update)
|
||||||
|
|
||||||
post("/scrobble", ScrobbleController, :create)
|
post("/scrobble", ScrobbleController, :create)
|
||||||
|
|
||||||
|
get("/backups", BackupController, :index)
|
||||||
|
post("/backups", BackupController, :create)
|
||||||
end
|
end
|
||||||
|
|
||||||
scope [] do
|
scope [] do
|
||||||
|
@ -566,30 +591,43 @@ defmodule Pleroma.Web.Router do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
pipeline :ostatus do
|
|
||||||
plug(:accepts, ["html", "xml", "rss", "atom", "activity+json", "json"])
|
|
||||||
plug(Pleroma.Web.Plugs.StaticFEPlug)
|
|
||||||
end
|
|
||||||
|
|
||||||
pipeline :oembed do
|
|
||||||
plug(:accepts, ["json", "xml"])
|
|
||||||
end
|
|
||||||
|
|
||||||
scope "/", Pleroma.Web do
|
scope "/", Pleroma.Web do
|
||||||
pipe_through([:ostatus, :http_signature])
|
# Note: html format is supported only if static FE is enabled
|
||||||
|
# Note: http signature is only considered for json requests (no auth for non-json requests)
|
||||||
|
pipe_through([:accepts_html_json, :http_signature, Pleroma.Web.Plugs.StaticFEPlug])
|
||||||
|
|
||||||
get("/objects/:uuid", OStatus.OStatusController, :object)
|
get("/objects/:uuid", OStatus.OStatusController, :object)
|
||||||
get("/activities/:uuid", OStatus.OStatusController, :activity)
|
get("/activities/:uuid", OStatus.OStatusController, :activity)
|
||||||
get("/notice/:id", OStatus.OStatusController, :notice)
|
get("/notice/:id", OStatus.OStatusController, :notice)
|
||||||
get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
|
|
||||||
|
|
||||||
# Mastodon compatibility routes
|
# Mastodon compatibility routes
|
||||||
get("/users/:nickname/statuses/:id", OStatus.OStatusController, :object)
|
get("/users/:nickname/statuses/:id", OStatus.OStatusController, :object)
|
||||||
get("/users/:nickname/statuses/:id/activity", OStatus.OStatusController, :activity)
|
get("/users/:nickname/statuses/:id/activity", OStatus.OStatusController, :activity)
|
||||||
|
end
|
||||||
|
|
||||||
|
scope "/", Pleroma.Web do
|
||||||
|
# Note: html format is supported only if static FE is enabled
|
||||||
|
# Note: http signature is only considered for json requests (no auth for non-json requests)
|
||||||
|
pipe_through([:accepts_html_xml_json, :http_signature, Pleroma.Web.Plugs.StaticFEPlug])
|
||||||
|
|
||||||
|
# Note: returns user _profile_ for json requests, redirects to user _feed_ for non-json ones
|
||||||
|
get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
|
||||||
|
end
|
||||||
|
|
||||||
|
scope "/", Pleroma.Web do
|
||||||
|
# Note: html format is supported only if static FE is enabled
|
||||||
|
pipe_through([:accepts_html_xml, Pleroma.Web.Plugs.StaticFEPlug])
|
||||||
|
|
||||||
get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
|
get("/users/:nickname/feed", Feed.UserController, :feed, as: :user_feed)
|
||||||
get("/users/:nickname", Feed.UserController, :feed_redirect, as: :user_feed)
|
end
|
||||||
|
|
||||||
|
scope "/", Pleroma.Web do
|
||||||
|
pipe_through(:accepts_html)
|
||||||
|
get("/notice/:id/embed_player", OStatus.OStatusController, :notice_player)
|
||||||
|
end
|
||||||
|
|
||||||
|
scope "/", Pleroma.Web do
|
||||||
|
pipe_through(:accepts_xml_rss_atom)
|
||||||
get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
|
get("/tags/:tag", Feed.TagController, :feed, as: :tag_feed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,96 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
|
||||||
plug(:put_view, Pleroma.Web.StaticFE.StaticFEView)
|
plug(:put_view, Pleroma.Web.StaticFE.StaticFEView)
|
||||||
plug(:assign_id)
|
plug(:assign_id)
|
||||||
|
|
||||||
plug(Pleroma.Web.Plugs.EnsureAuthenticatedPlug,
|
|
||||||
unless_func: &Pleroma.Web.Plugs.FederatingPlug.federating?/1
|
|
||||||
)
|
|
||||||
|
|
||||||
@page_keys ["max_id", "min_id", "limit", "since_id", "order"]
|
@page_keys ["max_id", "min_id", "limit", "since_id", "order"]
|
||||||
|
|
||||||
|
@doc "Renders requested local public activity or public activities of requested user"
|
||||||
|
def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do
|
||||||
|
with %Activity{local: true} = activity <-
|
||||||
|
Activity.get_by_id_with_object(notice_id),
|
||||||
|
true <- Visibility.is_public?(activity.object),
|
||||||
|
{_, true} <- {:visible?, Visibility.visible_for_user?(activity, _reading_user = nil)},
|
||||||
|
%User{} = user <- User.get_by_ap_id(activity.object.data["actor"]) do
|
||||||
|
meta = Metadata.build_tags(%{activity_id: notice_id, object: activity.object, user: user})
|
||||||
|
|
||||||
|
timeline =
|
||||||
|
activity.object.data["context"]
|
||||||
|
|> ActivityPub.fetch_activities_for_context(%{})
|
||||||
|
|> Enum.reverse()
|
||||||
|
|> Enum.map(&represent(&1, &1.object.id == activity.object.id))
|
||||||
|
|
||||||
|
render(conn, "conversation.html", %{activities: timeline, meta: meta})
|
||||||
|
else
|
||||||
|
%Activity{object: %Object{data: data}} ->
|
||||||
|
conn
|
||||||
|
|> put_status(:found)
|
||||||
|
|> redirect(external: data["url"] || data["external_url"] || data["id"])
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
not_found(conn, "Post not found.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do
|
||||||
|
with {_, %User{local: true} = user} <-
|
||||||
|
{:fetch_user, User.get_cached_by_nickname_or_id(username_or_id)},
|
||||||
|
{_, :visible} <- {:visibility, User.visible_for(user, _reading_user = nil)} do
|
||||||
|
meta = Metadata.build_tags(%{user: user})
|
||||||
|
|
||||||
|
params =
|
||||||
|
params
|
||||||
|
|> Map.take(@page_keys)
|
||||||
|
|> Map.new(fn {k, v} -> {String.to_existing_atom(k), v} end)
|
||||||
|
|
||||||
|
timeline =
|
||||||
|
user
|
||||||
|
|> ActivityPub.fetch_user_activities(_reading_user = nil, params)
|
||||||
|
|> Enum.map(&represent/1)
|
||||||
|
|
||||||
|
prev_page_id =
|
||||||
|
(params["min_id"] || params["max_id"]) &&
|
||||||
|
List.first(timeline) && List.first(timeline).id
|
||||||
|
|
||||||
|
next_page_id = List.last(timeline) && List.last(timeline).id
|
||||||
|
|
||||||
|
render(conn, "profile.html", %{
|
||||||
|
user: User.sanitize_html(user),
|
||||||
|
timeline: timeline,
|
||||||
|
prev_page_id: prev_page_id,
|
||||||
|
next_page_id: next_page_id,
|
||||||
|
meta: meta
|
||||||
|
})
|
||||||
|
else
|
||||||
|
_ ->
|
||||||
|
not_found(conn, "User not found.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show(%{assigns: %{object_id: _}} = conn, _params) do
|
||||||
|
url = Helpers.url(conn) <> conn.request_path
|
||||||
|
|
||||||
|
case Activity.get_create_by_object_ap_id_with_object(url) do
|
||||||
|
%Activity{} = activity ->
|
||||||
|
to = Helpers.o_status_path(Pleroma.Web.Endpoint, :notice, activity)
|
||||||
|
redirect(conn, to: to)
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
not_found(conn, "Post not found.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show(%{assigns: %{activity_id: _}} = conn, _params) do
|
||||||
|
url = Helpers.url(conn) <> conn.request_path
|
||||||
|
|
||||||
|
case Activity.get_by_ap_id(url) do
|
||||||
|
%Activity{} = activity ->
|
||||||
|
to = Helpers.o_status_path(Pleroma.Web.Endpoint, :notice, activity)
|
||||||
|
redirect(conn, to: to)
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
not_found(conn, "Post not found.")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp get_title(%Object{data: %{"name" => name}}) when is_binary(name),
|
defp get_title(%Object{data: %{"name" => name}}) when is_binary(name),
|
||||||
do: name
|
do: name
|
||||||
|
|
||||||
|
@ -81,91 +165,6 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def show(%{assigns: %{notice_id: notice_id}} = conn, _params) do
|
|
||||||
with %Activity{local: true} = activity <-
|
|
||||||
Activity.get_by_id_with_object(notice_id),
|
|
||||||
true <- Visibility.is_public?(activity.object),
|
|
||||||
%User{} = user <- User.get_by_ap_id(activity.object.data["actor"]) do
|
|
||||||
meta = Metadata.build_tags(%{activity_id: notice_id, object: activity.object, user: user})
|
|
||||||
|
|
||||||
timeline =
|
|
||||||
activity.object.data["context"]
|
|
||||||
|> ActivityPub.fetch_activities_for_context(%{})
|
|
||||||
|> Enum.reverse()
|
|
||||||
|> Enum.map(&represent(&1, &1.object.id == activity.object.id))
|
|
||||||
|
|
||||||
render(conn, "conversation.html", %{activities: timeline, meta: meta})
|
|
||||||
else
|
|
||||||
%Activity{object: %Object{data: data}} ->
|
|
||||||
conn
|
|
||||||
|> put_status(:found)
|
|
||||||
|> redirect(external: data["url"] || data["external_url"] || data["id"])
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
not_found(conn, "Post not found.")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def show(%{assigns: %{username_or_id: username_or_id}} = conn, params) do
|
|
||||||
case User.get_cached_by_nickname_or_id(username_or_id) do
|
|
||||||
%User{} = user ->
|
|
||||||
meta = Metadata.build_tags(%{user: user})
|
|
||||||
|
|
||||||
params =
|
|
||||||
params
|
|
||||||
|> Map.take(@page_keys)
|
|
||||||
|> Map.new(fn {k, v} -> {String.to_existing_atom(k), v} end)
|
|
||||||
|
|
||||||
timeline =
|
|
||||||
user
|
|
||||||
|> ActivityPub.fetch_user_activities(nil, params)
|
|
||||||
|> Enum.map(&represent/1)
|
|
||||||
|
|
||||||
prev_page_id =
|
|
||||||
(params["min_id"] || params["max_id"]) &&
|
|
||||||
List.first(timeline) && List.first(timeline).id
|
|
||||||
|
|
||||||
next_page_id = List.last(timeline) && List.last(timeline).id
|
|
||||||
|
|
||||||
render(conn, "profile.html", %{
|
|
||||||
user: User.sanitize_html(user),
|
|
||||||
timeline: timeline,
|
|
||||||
prev_page_id: prev_page_id,
|
|
||||||
next_page_id: next_page_id,
|
|
||||||
meta: meta
|
|
||||||
})
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
not_found(conn, "User not found.")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def show(%{assigns: %{object_id: _}} = conn, _params) do
|
|
||||||
url = Helpers.url(conn) <> conn.request_path
|
|
||||||
|
|
||||||
case Activity.get_create_by_object_ap_id_with_object(url) do
|
|
||||||
%Activity{} = activity ->
|
|
||||||
to = Helpers.o_status_path(Pleroma.Web.Endpoint, :notice, activity)
|
|
||||||
redirect(conn, to: to)
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
not_found(conn, "Post not found.")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def show(%{assigns: %{activity_id: _}} = conn, _params) do
|
|
||||||
url = Helpers.url(conn) <> conn.request_path
|
|
||||||
|
|
||||||
case Activity.get_by_ap_id(url) do
|
|
||||||
%Activity{} = activity ->
|
|
||||||
to = Helpers.o_status_path(Pleroma.Web.Endpoint, :notice, activity)
|
|
||||||
redirect(conn, to: to)
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
not_found(conn, "Post not found.")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp assign_id(%{path_info: ["notice", notice_id]} = conn, _opts),
|
defp assign_id(%{path_info: ["notice", notice_id]} = conn, _opts),
|
||||||
do: assign(conn, :notice_id, notice_id)
|
do: assign(conn, :notice_id, notice_id)
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1><%= Pleroma.Config.get([:instance, :name]) %></h1>
|
<h1><%= Pleroma.Config.get([:instance, :name]) %></h1>
|
||||||
<%= render @view_module, @view_template, assigns %>
|
<%= @inner_content %>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -181,7 +181,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= render @view_module, @view_template, assigns %>
|
<%= @inner_content %>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -10,7 +10,7 @@ video, audio {
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<%= render @view_module, @view_template, assigns %>
|
<%= @inner_content %>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<%= render @view_module, @view_template, assigns %>
|
<%= @inner_content %>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
54
lib/pleroma/workers/backup_worker.ex
Normal file
54
lib/pleroma/workers/backup_worker.ex
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Workers.BackupWorker do
|
||||||
|
use Oban.Worker, queue: :backup, max_attempts: 1
|
||||||
|
|
||||||
|
alias Oban.Job
|
||||||
|
alias Pleroma.User.Backup
|
||||||
|
|
||||||
|
def process(backup, admin_user_id \\ nil) do
|
||||||
|
%{"op" => "process", "backup_id" => backup.id, "admin_user_id" => admin_user_id}
|
||||||
|
|> new()
|
||||||
|
|> Oban.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
def schedule_deletion(backup) do
|
||||||
|
days = Pleroma.Config.get([Backup, :purge_after_days])
|
||||||
|
time = 60 * 60 * 24 * days
|
||||||
|
scheduled_at = Calendar.NaiveDateTime.add!(backup.inserted_at, time)
|
||||||
|
|
||||||
|
%{"op" => "delete", "backup_id" => backup.id}
|
||||||
|
|> new(scheduled_at: scheduled_at)
|
||||||
|
|> Oban.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
def delete(backup) do
|
||||||
|
%{"op" => "delete", "backup_id" => backup.id}
|
||||||
|
|> new()
|
||||||
|
|> Oban.insert()
|
||||||
|
end
|
||||||
|
|
||||||
|
def perform(%Job{
|
||||||
|
args: %{"op" => "process", "backup_id" => backup_id, "admin_user_id" => admin_user_id}
|
||||||
|
}) do
|
||||||
|
with {:ok, %Backup{} = backup} <-
|
||||||
|
backup_id |> Backup.get() |> Backup.process(),
|
||||||
|
{:ok, _job} <- schedule_deletion(backup),
|
||||||
|
:ok <- Backup.remove_outdated(backup),
|
||||||
|
{:ok, _} <-
|
||||||
|
backup
|
||||||
|
|> Pleroma.Emails.UserEmail.backup_is_ready_email(admin_user_id)
|
||||||
|
|> Pleroma.Emails.Mailer.deliver() do
|
||||||
|
{:ok, backup}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def perform(%Job{args: %{"op" => "delete", "backup_id" => backup_id}}) do
|
||||||
|
case Backup.get(backup_id) do
|
||||||
|
%Backup{} = backup -> Backup.delete(backup)
|
||||||
|
nil -> :ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
17
mix.exs
17
mix.exs
|
@ -114,10 +114,10 @@ defmodule Pleroma.Mixfile do
|
||||||
# Type `mix help deps` for examples and options.
|
# Type `mix help deps` for examples and options.
|
||||||
defp deps do
|
defp deps do
|
||||||
[
|
[
|
||||||
{:phoenix, "~> 1.4.17"},
|
{:phoenix, "~> 1.5.5"},
|
||||||
{:tzdata, "~> 1.0.3"},
|
{:tzdata, "~> 1.0.3"},
|
||||||
{:plug_cowboy, "~> 2.3"},
|
{:plug_cowboy, "~> 2.3"},
|
||||||
{:phoenix_pubsub, "~> 1.1"},
|
{:phoenix_pubsub, "~> 2.0"},
|
||||||
{:phoenix_ecto, "~> 4.0"},
|
{:phoenix_ecto, "~> 4.0"},
|
||||||
{:ecto_enum, "~> 1.4"},
|
{:ecto_enum, "~> 1.4"},
|
||||||
{:ecto_sql, "~> 3.4.4"},
|
{:ecto_sql, "~> 3.4.4"},
|
||||||
|
@ -134,7 +134,7 @@ defmodule Pleroma.Mixfile do
|
||||||
{:cachex, "~> 3.2"},
|
{:cachex, "~> 3.2"},
|
||||||
{:poison, "~> 3.0", override: true},
|
{:poison, "~> 3.0", override: true},
|
||||||
{:tesla,
|
{:tesla,
|
||||||
git: "https://github.com/teamon/tesla/",
|
git: "https://github.com/teamon/tesla.git",
|
||||||
ref: "9f7261ca49f9f901ceb73b60219ad6f8a9f6aa30",
|
ref: "9f7261ca49f9f901ceb73b60219ad6f8a9f6aa30",
|
||||||
override: true},
|
override: true},
|
||||||
{:castore, "~> 0.1"},
|
{:castore, "~> 0.1"},
|
||||||
|
@ -165,9 +165,16 @@ defmodule Pleroma.Mixfile do
|
||||||
{:telemetry, "~> 0.3"},
|
{:telemetry, "~> 0.3"},
|
||||||
{:poolboy, "~> 1.5"},
|
{:poolboy, "~> 1.5"},
|
||||||
{:prometheus, "~> 4.6"},
|
{:prometheus, "~> 4.6"},
|
||||||
{:prometheus_ex, "~> 3.0"},
|
{:prometheus_ex,
|
||||||
|
git: "https://git.pleroma.social/pleroma/elixir-libraries/prometheus.ex.git",
|
||||||
|
ref: "a4e9beb3c1c479d14b352fd9d6dd7b1f6d7deee5",
|
||||||
|
override: true},
|
||||||
{:prometheus_plugs, "~> 1.1"},
|
{:prometheus_plugs, "~> 1.1"},
|
||||||
{:prometheus_phoenix, "~> 1.3"},
|
{:prometheus_phoenix, "~> 1.3"},
|
||||||
|
# Note: once `prometheus_phx` is integrated into `prometheus_phoenix`, remove the former:
|
||||||
|
{:prometheus_phx,
|
||||||
|
git: "https://git.pleroma.social/pleroma/elixir-libraries/prometheus-phx.git",
|
||||||
|
branch: "no-logging"},
|
||||||
{:prometheus_ecto, "~> 1.4"},
|
{:prometheus_ecto, "~> 1.4"},
|
||||||
{:recon, "~> 2.5"},
|
{:recon, "~> 2.5"},
|
||||||
{:quack, "~> 0.1.1"},
|
{:quack, "~> 0.1.1"},
|
||||||
|
@ -188,6 +195,8 @@ defmodule Pleroma.Mixfile do
|
||||||
git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
|
git: "https://git.pleroma.social/pleroma/elixir-libraries/elixir-captcha.git",
|
||||||
ref: "e0f16822d578866e186a0974d65ad58cddc1e2ab"},
|
ref: "e0f16822d578866e186a0974d65ad58cddc1e2ab"},
|
||||||
{:restarter, path: "./restarter"},
|
{:restarter, path: "./restarter"},
|
||||||
|
{:majic,
|
||||||
|
git: "https://git.pleroma.social/pleroma/elixir-libraries/majic.git", branch: "develop"},
|
||||||
{:open_api_spex,
|
{:open_api_spex,
|
||||||
git: "https://git.pleroma.social/pleroma/elixir-libraries/open_api_spex.git",
|
git: "https://git.pleroma.social/pleroma/elixir-libraries/open_api_spex.git",
|
||||||
ref: "f296ac0924ba3cf79c7a588c4c252889df4c2edd"},
|
ref: "f296ac0924ba3cf79c7a588c4c252889df4c2edd"},
|
||||||
|
|
27
mix.lock
27
mix.lock
|
@ -18,8 +18,9 @@
|
||||||
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"},
|
"connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm", "4a0850c9be22a43af9920a71ab17c051f5f7d45c209e40269a1938832510e4d9"},
|
||||||
"cors_plug": {:hex, :cors_plug, "2.0.2", "2b46083af45e4bc79632bd951550509395935d3e7973275b2b743bd63cc942ce", [:mix], [{:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "f0d0e13f71c51fd4ef8b2c7e051388e4dfb267522a83a22392c856de7e46465f"},
|
"cors_plug": {:hex, :cors_plug, "2.0.2", "2b46083af45e4bc79632bd951550509395935d3e7973275b2b743bd63cc942ce", [:mix], [{:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "f0d0e13f71c51fd4ef8b2c7e051388e4dfb267522a83a22392c856de7e46465f"},
|
||||||
"cowboy": {:hex, :cowboy, "2.8.0", "f3dc62e35797ecd9ac1b50db74611193c29815401e53bac9a5c0577bd7bc667d", [:rebar3], [{:cowlib, "~> 2.9.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "4643e4fba74ac96d4d152c75803de6fad0b3fa5df354c71afdd6cbeeb15fac8a"},
|
"cowboy": {:hex, :cowboy, "2.8.0", "f3dc62e35797ecd9ac1b50db74611193c29815401e53bac9a5c0577bd7bc667d", [:rebar3], [{:cowlib, "~> 2.9.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.7.1", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "4643e4fba74ac96d4d152c75803de6fad0b3fa5df354c71afdd6cbeeb15fac8a"},
|
||||||
|
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.3.0", "69fdb5cf92df6373e15675eb4018cf629f5d8e35e74841bb637d6596cb797bbc", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "42868c229d9a2900a1501c5d0355bfd46e24c862c322b0b4f5a6f14fe0216753"},
|
||||||
"cowlib": {:hex, :cowlib, "2.9.1", "61a6c7c50cf07fdd24b2f45b89500bb93b6686579b069a89f88cb211e1125c78", [:rebar3], [], "hexpm", "e4175dc240a70d996156160891e1c62238ede1729e45740bdd38064dad476170"},
|
"cowlib": {:hex, :cowlib, "2.9.1", "61a6c7c50cf07fdd24b2f45b89500bb93b6686579b069a89f88cb211e1125c78", [:rebar3], [], "hexpm", "e4175dc240a70d996156160891e1c62238ede1729e45740bdd38064dad476170"},
|
||||||
"credo": {:hex, :credo, "1.4.0", "92339d4cbadd1e88b5ee43d427b639b68a11071b6f73854e33638e30a0ea11f5", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "1fd3b70dce216574ce3c18bdf510b57e7c4c85c2ec9cad4bff854abaf7e58658"},
|
"credo": {:hex, :credo, "1.4.1", "16392f1edd2cdb1de9fe4004f5ab0ae612c92e230433968eab00aafd976282fc", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "155f8a2989ad77504de5d8291fa0d41320fdcaa6a1030472e9967f285f8c7692"},
|
||||||
"crontab": {:hex, :crontab, "1.1.8", "2ce0e74777dfcadb28a1debbea707e58b879e6aa0ffbf9c9bb540887bce43617", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"},
|
"crontab": {:hex, :crontab, "1.1.8", "2ce0e74777dfcadb28a1debbea707e58b879e6aa0ffbf9c9bb540887bce43617", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm"},
|
||||||
"crypt": {:git, "https://github.com/msantos/crypt.git", "f63a705f92c26955977ee62a313012e309a4d77a", [ref: "f63a705f92c26955977ee62a313012e309a4d77a"]},
|
"crypt": {:git, "https://github.com/msantos/crypt.git", "f63a705f92c26955977ee62a313012e309a4d77a", [ref: "f63a705f92c26955977ee62a313012e309a4d77a"]},
|
||||||
"custom_base": {:hex, :custom_base, "0.2.1", "4a832a42ea0552299d81652aa0b1f775d462175293e99dfbe4d7dbaab785a706", [:mix], [], "hexpm", "8df019facc5ec9603e94f7270f1ac73ddf339f56ade76a721eaa57c1493ba463"},
|
"custom_base": {:hex, :custom_base, "0.2.1", "4a832a42ea0552299d81652aa0b1f775d462175293e99dfbe4d7dbaab785a706", [:mix], [], "hexpm", "8df019facc5ec9603e94f7270f1ac73ddf339f56ade76a721eaa57c1493ba463"},
|
||||||
|
@ -32,7 +33,7 @@
|
||||||
"ecto_enum": {:hex, :ecto_enum, "1.4.0", "d14b00e04b974afc69c251632d1e49594d899067ee2b376277efd8233027aec8", [:mix], [{:ecto, ">= 3.0.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "> 3.0.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:mariaex, ">= 0.0.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "8fb55c087181c2b15eee406519dc22578fa60dd82c088be376d0010172764ee4"},
|
"ecto_enum": {:hex, :ecto_enum, "1.4.0", "d14b00e04b974afc69c251632d1e49594d899067ee2b376277efd8233027aec8", [:mix], [{:ecto, ">= 3.0.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_sql, "> 3.0.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:mariaex, ">= 0.0.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:postgrex, ">= 0.0.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "8fb55c087181c2b15eee406519dc22578fa60dd82c088be376d0010172764ee4"},
|
||||||
"ecto_sql": {:hex, :ecto_sql, "3.4.5", "30161f81b167d561a9a2df4329c10ae05ff36eca7ccc84628f2c8b9fa1e43323", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0 or ~> 0.4.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.0", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "31990c6a3579b36a3c0841d34a94c275e727de8b84f58509da5f1b2032c98ac2"},
|
"ecto_sql": {:hex, :ecto_sql, "3.4.5", "30161f81b167d561a9a2df4329c10ae05ff36eca7ccc84628f2c8b9fa1e43323", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.3.0 or ~> 0.4.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.0", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "31990c6a3579b36a3c0841d34a94c275e727de8b84f58509da5f1b2032c98ac2"},
|
||||||
"eimp": {:hex, :eimp, "1.0.14", "fc297f0c7e2700457a95a60c7010a5f1dcb768a083b6d53f49cd94ab95a28f22", [:rebar3], [{:p1_utils, "1.0.18", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "501133f3112079b92d9e22da8b88bf4f0e13d4d67ae9c15c42c30bd25ceb83b6"},
|
"eimp": {:hex, :eimp, "1.0.14", "fc297f0c7e2700457a95a60c7010a5f1dcb768a083b6d53f49cd94ab95a28f22", [:rebar3], [{:p1_utils, "1.0.18", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "501133f3112079b92d9e22da8b88bf4f0e13d4d67ae9c15c42c30bd25ceb83b6"},
|
||||||
"elixir_make": {:hex, :elixir_make, "0.6.0", "38349f3e29aff4864352084fc736fa7fa0f2995a819a737554f7ebd28b85aaab", [:mix], [], "hexpm", "d522695b93b7f0b4c0fcb2dfe73a6b905b1c301226a5a55cb42e5b14d509e050"},
|
"elixir_make": {:hex, :elixir_make, "0.6.1", "8faa29a5597faba999aeeb72bbb9c91694ef8068f0131192fb199f98d32994ef", [:mix], [], "hexpm", "35d33270680f8d839a4003c3e9f43afb595310a592405a00afc12de4c7f55a18"},
|
||||||
"esshd": {:hex, :esshd, "0.1.1", "d4dd4c46698093a40a56afecce8a46e246eb35463c457c246dacba2e056f31b5", [:mix], [], "hexpm", "d73e341e3009d390aa36387dc8862860bf9f874c94d9fd92ade2926376f49981"},
|
"esshd": {:hex, :esshd, "0.1.1", "d4dd4c46698093a40a56afecce8a46e246eb35463c457c246dacba2e056f31b5", [:mix], [], "hexpm", "d73e341e3009d390aa36387dc8862860bf9f874c94d9fd92ade2926376f49981"},
|
||||||
"eternal": {:hex, :eternal, "1.2.1", "d5b6b2499ba876c57be2581b5b999ee9bdf861c647401066d3eeed111d096bc4", [:mix], [], "hexpm", "b14f1dc204321429479c569cfbe8fb287541184ed040956c8862cb7a677b8406"},
|
"eternal": {:hex, :eternal, "1.2.1", "d5b6b2499ba876c57be2581b5b999ee9bdf861c647401066d3eeed111d096bc4", [:mix], [], "hexpm", "b14f1dc204321429479c569cfbe8fb287541184ed040956c8862cb7a677b8406"},
|
||||||
"ex2ms": {:hex, :ex2ms, "1.5.0", "19e27f9212be9a96093fed8cdfbef0a2b56c21237196d26760f11dfcfae58e97", [:mix], [], "hexpm"},
|
"ex2ms": {:hex, :ex2ms, "1.5.0", "19e27f9212be9a96093fed8cdfbef0a2b56c21237196d26760f11dfcfae58e97", [:mix], [], "hexpm"},
|
||||||
|
@ -65,6 +66,7 @@
|
||||||
"jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"},
|
"jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"},
|
||||||
"libring": {:hex, :libring, "1.4.0", "41246ba2f3fbc76b3971f6bce83119dfec1eee17e977a48d8a9cfaaf58c2a8d6", [:mix], [], "hexpm"},
|
"libring": {:hex, :libring, "1.4.0", "41246ba2f3fbc76b3971f6bce83119dfec1eee17e977a48d8a9cfaaf58c2a8d6", [:mix], [], "hexpm"},
|
||||||
"linkify": {:hex, :linkify, "0.2.0", "2518bbbea21d2caa9d372424e1ad845b640c6630e2d016f1bd1f518f9ebcca28", [:mix], [], "hexpm", "b8ca8a68b79e30b7938d6c996085f3db14939f29538a59ca5101988bb7f917f6"},
|
"linkify": {:hex, :linkify, "0.2.0", "2518bbbea21d2caa9d372424e1ad845b640c6630e2d016f1bd1f518f9ebcca28", [:mix], [], "hexpm", "b8ca8a68b79e30b7938d6c996085f3db14939f29538a59ca5101988bb7f917f6"},
|
||||||
|
"majic": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/majic.git", "4c692e544b28d1f5e543fb8a44be090f8cd96f80", [branch: "develop"]},
|
||||||
"makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"},
|
"makeup": {:hex, :makeup, "1.0.3", "e339e2f766d12e7260e6672dd4047405963c5ec99661abdc432e6ec67d29ef95", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "2e9b4996d11832947731f7608fed7ad2f9443011b3b479ae288011265cdd3dad"},
|
||||||
"makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"},
|
"makeup_elixir": {:hex, :makeup_elixir, "0.14.1", "4f0e96847c63c17841d42c08107405a005a2680eb9c7ccadfd757bd31dabccfb", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "f2438b1a80eaec9ede832b5c41cd4f373b38fd7aa33e3b22d9db79e640cbde11"},
|
||||||
"meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm", "d34f013c156db51ad57cc556891b9720e6a1c1df5fe2e15af999c84d6cebeb1a"},
|
"meck": {:hex, :meck, "0.8.13", "ffedb39f99b0b99703b8601c6f17c7f76313ee12de6b646e671e3188401f7866", [:rebar3], [], "hexpm", "d34f013c156db51ad57cc556891b9720e6a1c1df5fe2e15af999c84d6cebeb1a"},
|
||||||
|
@ -84,14 +86,14 @@
|
||||||
"p1_utils": {:hex, :p1_utils, "1.0.18", "3fe224de5b2e190d730a3c5da9d6e8540c96484cf4b4692921d1e28f0c32b01c", [:rebar3], [], "hexpm", "1fc8773a71a15553b179c986b22fbeead19b28fe486c332d4929700ffeb71f88"},
|
"p1_utils": {:hex, :p1_utils, "1.0.18", "3fe224de5b2e190d730a3c5da9d6e8540c96484cf4b4692921d1e28f0c32b01c", [:rebar3], [], "hexpm", "1fc8773a71a15553b179c986b22fbeead19b28fe486c332d4929700ffeb71f88"},
|
||||||
"parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"},
|
"parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"},
|
||||||
"pbkdf2_elixir": {:hex, :pbkdf2_elixir, "1.2.1", "9cbe354b58121075bd20eb83076900a3832324b7dd171a6895fab57b6bb2752c", [:mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}], "hexpm", "d3b40a4a4630f0b442f19eca891fcfeeee4c40871936fed2f68e1c4faa30481f"},
|
"pbkdf2_elixir": {:hex, :pbkdf2_elixir, "1.2.1", "9cbe354b58121075bd20eb83076900a3832324b7dd171a6895fab57b6bb2752c", [:mix], [{:comeonin, "~> 5.3", [hex: :comeonin, repo: "hexpm", optional: false]}], "hexpm", "d3b40a4a4630f0b442f19eca891fcfeeee4c40871936fed2f68e1c4faa30481f"},
|
||||||
"phoenix": {:hex, :phoenix, "1.4.17", "1b1bd4cff7cfc87c94deaa7d60dd8c22e04368ab95499483c50640ef3bd838d8", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.8.1 or ~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3a8e5d7a3d76d452bb5fb86e8b7bd115f737e4f8efe202a463d4aeb4a5809611"},
|
"phoenix": {:hex, :phoenix, "1.5.6", "8298cdb4e0f943242ba8410780a6a69cbbe972fef199b341a36898dd751bdd66", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 2.13", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.1.2 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "0dc4d39af1306b6aa5122729b0a95ca779e42c708c6fe7abbb3d336d5379e956"},
|
||||||
"phoenix_ecto": {:hex, :phoenix_ecto, "4.1.0", "a044d0756d0464c5a541b4a0bf4bcaf89bffcaf92468862408290682c73ae50d", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "c5e666a341ff104d0399d8f0e4ff094559b2fde13a5985d4cb5023b2c2ac558b"},
|
"phoenix_ecto": {:hex, :phoenix_ecto, "4.2.1", "13f124cf0a3ce0f1948cf24654c7b9f2347169ff75c1123f44674afee6af3b03", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 2.15", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "478a1bae899cac0a6e02be1deec7e2944b7754c04e7d4107fc5a517f877743c0"},
|
||||||
"phoenix_html": {:hex, :phoenix_html, "2.14.2", "b8a3899a72050f3f48a36430da507dd99caf0ac2d06c77529b1646964f3d563e", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "58061c8dfd25da5df1ea0ca47c972f161beb6c875cd293917045b92ffe1bf617"},
|
"phoenix_html": {:hex, :phoenix_html, "2.14.2", "b8a3899a72050f3f48a36430da507dd99caf0ac2d06c77529b1646964f3d563e", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "58061c8dfd25da5df1ea0ca47c972f161beb6c875cd293917045b92ffe1bf617"},
|
||||||
"phoenix_pubsub": {:hex, :phoenix_pubsub, "1.1.2", "496c303bdf1b2e98a9d26e89af5bba3ab487ba3a3735f74bf1f4064d2a845a3e", [:mix], [], "hexpm", "1f13f9f0f3e769a667a6b6828d29dec37497a082d195cc52dbef401a9b69bf38"},
|
"phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"},
|
||||||
"phoenix_swoosh": {:hex, :phoenix_swoosh, "0.3.0", "2acfa0db038a7649e0a4614eee970e6ed9a39d191ccd79a03583b51d0da98165", [:mix], [{:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:swoosh, "~> 1.0", [hex: :swoosh, repo: "hexpm", optional: false]}], "hexpm", "b8bbae4b59a676de6b8bd8675eda37bc8b4424812ae429d6fdcb2b039e00003b"},
|
"phoenix_swoosh": {:hex, :phoenix_swoosh, "0.3.2", "43d3518349a22b8b1910ea28b4dd5119926d5017b3187db3fbd1a1e05769a851", [:mix], [{:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:swoosh, "~> 1.0", [hex: :swoosh, repo: "hexpm", optional: false]}], "hexpm", "3e2ac4e883db7af0702d75ba00c19901760e8342b91f8f66e13941de552e777f"},
|
||||||
"plug": {:hex, :plug, "1.10.4", "41eba7d1a2d671faaf531fa867645bd5a3dce0957d8e2a3f398ccff7d2ef017f", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad1e233fe73d2eec56616568d260777b67f53148a999dc2d048f4eb9778fe4a0"},
|
"plug": {:hex, :plug, "1.10.4", "41eba7d1a2d671faaf531fa867645bd5a3dce0957d8e2a3f398ccff7d2ef017f", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad1e233fe73d2eec56616568d260777b67f53148a999dc2d048f4eb9778fe4a0"},
|
||||||
"plug_cowboy": {:hex, :plug_cowboy, "2.3.0", "149a50e05cb73c12aad6506a371cd75750c0b19a32f81866e1a323dda9e0e99d", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "bc595a1870cef13f9c1e03df56d96804db7f702175e4ccacdb8fc75c02a7b97e"},
|
"plug_cowboy": {:hex, :plug_cowboy, "2.4.0", "e936ef151751f386804c51f87f7300f5aaae6893cdad726559c3930c6c032948", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e25ddcfc06b1b76e55af79d078b03cbc86bbcb99ce4e5e0a5e4a8114ee039be6"},
|
||||||
"plug_crypto": {:hex, :plug_crypto, "1.1.2", "bdd187572cc26dbd95b87136290425f2b580a116d3fb1f564216918c9730d227", [:mix], [], "hexpm", "6b8b608f895b6ffcfad49c37c7883e8df98ae19c6a28113b02aa1e9c5b22d6b5"},
|
"plug_crypto": {:hex, :plug_crypto, "1.2.0", "1cb20793aa63a6c619dd18bb33d7a3aa94818e5fd39ad357051a67f26dfa2df6", [:mix], [], "hexpm", "a48b538ae8bf381ffac344520755f3007cc10bd8e90b240af98ea29b69683fc2"},
|
||||||
"plug_static_index_html": {:hex, :plug_static_index_html, "1.0.0", "840123d4d3975585133485ea86af73cb2600afd7f2a976f9f5fd8b3808e636a0", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "79fd4fcf34d110605c26560cbae8f23c603ec4158c08298bd4360fdea90bb5cf"},
|
"plug_static_index_html": {:hex, :plug_static_index_html, "1.0.0", "840123d4d3975585133485ea86af73cb2600afd7f2a976f9f5fd8b3808e636a0", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "79fd4fcf34d110605c26560cbae8f23c603ec4158c08298bd4360fdea90bb5cf"},
|
||||||
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"},
|
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"},
|
||||||
"poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm", "dad79704ce5440f3d5a3681c8590b9dc25d1a561e8f5a9c995281012860901e3"},
|
"poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm", "dad79704ce5440f3d5a3681c8590b9dc25d1a561e8f5a9c995281012860901e3"},
|
||||||
|
@ -99,8 +101,9 @@
|
||||||
"pot": {:hex, :pot, "0.11.0", "61bad869a94534739dd4614a25a619bc5c47b9970e9a0ea5bef4628036fc7a16", [:rebar3], [], "hexpm", "57ee6ee6bdeb639661ffafb9acefe3c8f966e45394de6a766813bb9e1be4e54b"},
|
"pot": {:hex, :pot, "0.11.0", "61bad869a94534739dd4614a25a619bc5c47b9970e9a0ea5bef4628036fc7a16", [:rebar3], [], "hexpm", "57ee6ee6bdeb639661ffafb9acefe3c8f966e45394de6a766813bb9e1be4e54b"},
|
||||||
"prometheus": {:hex, :prometheus, "4.6.0", "20510f381db1ccab818b4cf2fac5fa6ab5cc91bc364a154399901c001465f46f", [:mix, :rebar3], [], "hexpm", "4905fd2992f8038eccd7aa0cd22f40637ed618c0bed1f75c05aacec15b7545de"},
|
"prometheus": {:hex, :prometheus, "4.6.0", "20510f381db1ccab818b4cf2fac5fa6ab5cc91bc364a154399901c001465f46f", [:mix, :rebar3], [], "hexpm", "4905fd2992f8038eccd7aa0cd22f40637ed618c0bed1f75c05aacec15b7545de"},
|
||||||
"prometheus_ecto": {:hex, :prometheus_ecto, "1.4.3", "3dd4da1812b8e0dbee81ea58bb3b62ed7588f2eae0c9e97e434c46807ff82311", [:mix], [{:ecto, "~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.1 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}], "hexpm", "8d66289f77f913b37eda81fd287340c17e61a447549deb28efc254532b2bed82"},
|
"prometheus_ecto": {:hex, :prometheus_ecto, "1.4.3", "3dd4da1812b8e0dbee81ea58bb3b62ed7588f2eae0c9e97e434c46807ff82311", [:mix], [{:ecto, "~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.1 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}], "hexpm", "8d66289f77f913b37eda81fd287340c17e61a447549deb28efc254532b2bed82"},
|
||||||
"prometheus_ex": {:hex, :prometheus_ex, "3.0.5", "fa58cfd983487fc5ead331e9a3e0aa622c67232b3ec71710ced122c4c453a02f", [:mix], [{:prometheus, "~> 4.0", [hex: :prometheus, repo: "hexpm", optional: false]}], "hexpm", "9fd13404a48437e044b288b41f76e64acd9735fb8b0e3809f494811dfa66d0fb"},
|
"prometheus_ex": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/prometheus.ex.git", "a4e9beb3c1c479d14b352fd9d6dd7b1f6d7deee5", [ref: "a4e9beb3c1c479d14b352fd9d6dd7b1f6d7deee5"]},
|
||||||
"prometheus_phoenix": {:hex, :prometheus_phoenix, "1.3.0", "c4b527e0b3a9ef1af26bdcfbfad3998f37795b9185d475ca610fe4388fdd3bb5", [:mix], [{:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.3 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}], "hexpm", "c4d1404ac4e9d3d963da601db2a7d8ea31194f0017057fabf0cfb9bf5a6c8c75"},
|
"prometheus_phoenix": {:hex, :prometheus_phoenix, "1.3.0", "c4b527e0b3a9ef1af26bdcfbfad3998f37795b9185d475ca610fe4388fdd3bb5", [:mix], [{:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.3 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}], "hexpm", "c4d1404ac4e9d3d963da601db2a7d8ea31194f0017057fabf0cfb9bf5a6c8c75"},
|
||||||
|
"prometheus_phx": {:git, "https://git.pleroma.social/pleroma/elixir-libraries/prometheus-phx.git", "9cd8f248c9381ffedc799905050abce194a97514", [branch: "no-logging"]},
|
||||||
"prometheus_plugs": {:hex, :prometheus_plugs, "1.1.5", "25933d48f8af3a5941dd7b621c889749894d8a1082a6ff7c67cc99dec26377c5", [:mix], [{:accept, "~> 0.1", [hex: :accept, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.1 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}, {:prometheus_process_collector, "~> 1.1", [hex: :prometheus_process_collector, repo: "hexpm", optional: true]}], "hexpm", "0273a6483ccb936d79ca19b0ab629aef0dba958697c94782bb728b920dfc6a79"},
|
"prometheus_plugs": {:hex, :prometheus_plugs, "1.1.5", "25933d48f8af3a5941dd7b621c889749894d8a1082a6ff7c67cc99dec26377c5", [:mix], [{:accept, "~> 0.1", [hex: :accept, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}, {:prometheus_ex, "~> 1.1 or ~> 2.0 or ~> 3.0", [hex: :prometheus_ex, repo: "hexpm", optional: false]}, {:prometheus_process_collector, "~> 1.1", [hex: :prometheus_process_collector, repo: "hexpm", optional: true]}], "hexpm", "0273a6483ccb936d79ca19b0ab629aef0dba958697c94782bb728b920dfc6a79"},
|
||||||
"quack": {:hex, :quack, "0.1.1", "cca7b4da1a233757fdb44b3334fce80c94785b3ad5a602053b7a002b5a8967bf", [:mix], [{:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: false]}, {:tesla, "~> 1.2.0", [hex: :tesla, repo: "hexpm", optional: false]}], "hexpm", "d736bfa7444112eb840027bb887832a0e403a4a3437f48028c3b29a2dbbd2543"},
|
"quack": {:hex, :quack, "0.1.1", "cca7b4da1a233757fdb44b3334fce80c94785b3ad5a602053b7a002b5a8967bf", [:mix], [{:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: false]}, {:tesla, "~> 1.2.0", [hex: :tesla, repo: "hexpm", optional: false]}], "hexpm", "d736bfa7444112eb840027bb887832a0e403a4a3437f48028c3b29a2dbbd2543"},
|
||||||
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm", "451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"},
|
"ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm", "451d8527787df716d99dc36162fca05934915db0b6141bbdac2ea8d3c7afc7d7"},
|
||||||
|
@ -109,13 +112,13 @@
|
||||||
"sleeplocks": {:hex, :sleeplocks, "1.1.1", "3d462a0639a6ef36cc75d6038b7393ae537ab394641beb59830a1b8271faeed3", [:rebar3], [], "hexpm", "84ee37aeff4d0d92b290fff986d6a95ac5eedf9b383fadfd1d88e9b84a1c02e1"},
|
"sleeplocks": {:hex, :sleeplocks, "1.1.1", "3d462a0639a6ef36cc75d6038b7393ae537ab394641beb59830a1b8271faeed3", [:rebar3], [], "hexpm", "84ee37aeff4d0d92b290fff986d6a95ac5eedf9b383fadfd1d88e9b84a1c02e1"},
|
||||||
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm", "13104d7897e38ed7f044c4de953a6c28597d1c952075eb2e328bc6d6f2bfc496"},
|
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm", "13104d7897e38ed7f044c4de953a6c28597d1c952075eb2e328bc6d6f2bfc496"},
|
||||||
"sweet_xml": {:hex, :sweet_xml, "0.6.6", "fc3e91ec5dd7c787b6195757fbcf0abc670cee1e4172687b45183032221b66b8", [:mix], [], "hexpm", "2e1ec458f892ffa81f9f8386e3f35a1af6db7a7a37748a64478f13163a1f3573"},
|
"sweet_xml": {:hex, :sweet_xml, "0.6.6", "fc3e91ec5dd7c787b6195757fbcf0abc670cee1e4172687b45183032221b66b8", [:mix], [], "hexpm", "2e1ec458f892ffa81f9f8386e3f35a1af6db7a7a37748a64478f13163a1f3573"},
|
||||||
"swoosh": {:hex, :swoosh, "1.0.0", "c547cfc83f30e12d5d1fdcb623d7de2c2e29a5becfc68bf8f42ba4d23d2c2756", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm", "b3b08e463f876cb6167f7168e9ad99a069a724e124bcee61847e0e1ed13f4a0d"},
|
"swoosh": {:hex, :swoosh, "1.0.6", "6765e334c67dacabe721f0d701c7e5a6f06e4595c90df6f91e73ebd54d555833", [:mix], [{:cowboy, "~> 1.1 or ~> 2.4", [hex: :cowboy, repo: "hexpm", optional: true]}, {:gen_smtp, "~> 0.13 or ~> 1.0", [hex: :gen_smtp, repo: "hexpm", optional: true]}, {:hackney, "~> 1.9", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mail, "~> 0.2", [hex: :mail, repo: "hexpm", optional: true]}, {:mime, "~> 1.1", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_cowboy, ">= 1.0.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}], "hexpm", "7c50ef78e4acfd1cbd4907dc1fa87b5540675a6be9dc979d04890f49d7ec1830"},
|
||||||
"syslog": {:hex, :syslog, "1.1.0", "6419a232bea84f07b56dc575225007ffe34d9fdc91abe6f1b2f254fd71d8efc2", [:rebar3], [], "hexpm", "4c6a41373c7e20587be33ef841d3de6f3beba08519809329ecc4d27b15b659e1"},
|
"syslog": {:hex, :syslog, "1.1.0", "6419a232bea84f07b56dc575225007ffe34d9fdc91abe6f1b2f254fd71d8efc2", [:rebar3], [], "hexpm", "4c6a41373c7e20587be33ef841d3de6f3beba08519809329ecc4d27b15b659e1"},
|
||||||
"telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"},
|
"telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"},
|
||||||
"tesla": {:git, "https://github.com/teamon/tesla/", "9f7261ca49f9f901ceb73b60219ad6f8a9f6aa30", [ref: "9f7261ca49f9f901ceb73b60219ad6f8a9f6aa30"]},
|
"tesla": {:git, "https://github.com/teamon/tesla.git", "9f7261ca49f9f901ceb73b60219ad6f8a9f6aa30", [ref: "9f7261ca49f9f901ceb73b60219ad6f8a9f6aa30"]},
|
||||||
"timex": {:hex, :timex, "3.6.2", "845cdeb6119e2fef10751c0b247b6c59d86d78554c83f78db612e3290f819bc2", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5 or ~> 1.0.0", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "26030b46199d02a590be61c2394b37ea25a3664c02fafbeca0b24c972025d47a"},
|
"timex": {:hex, :timex, "3.6.2", "845cdeb6119e2fef10751c0b247b6c59d86d78554c83f78db612e3290f819bc2", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5 or ~> 1.0.0", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "26030b46199d02a590be61c2394b37ea25a3664c02fafbeca0b24c972025d47a"},
|
||||||
"trailing_format_plug": {:hex, :trailing_format_plug, "0.0.7", "64b877f912cf7273bed03379936df39894149e35137ac9509117e59866e10e45", [:mix], [{:plug, "> 0.12.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "bd4fde4c15f3e993a999e019d64347489b91b7a9096af68b2bdadd192afa693f"},
|
"trailing_format_plug": {:hex, :trailing_format_plug, "0.0.7", "64b877f912cf7273bed03379936df39894149e35137ac9509117e59866e10e45", [:mix], [{:plug, "> 0.12.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "bd4fde4c15f3e993a999e019d64347489b91b7a9096af68b2bdadd192afa693f"},
|
||||||
"tzdata": {:hex, :tzdata, "1.0.3", "73470ad29dde46e350c60a66e6b360d3b99d2d18b74c4c349dbebbc27a09a3eb", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "a6e1ee7003c4d04ecbd21dd3ec690d4c6662db5d3bbdd7262d53cdf5e7c746c1"},
|
"tzdata": {:hex, :tzdata, "1.0.4", "a3baa4709ea8dba552dca165af6ae97c624a2d6ac14bd265165eaa8e8af94af6", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "b02637db3df1fd66dd2d3c4f194a81633d0e4b44308d36c1b2fdfd1e4e6f169b"},
|
||||||
"ueberauth": {:hex, :ueberauth, "0.6.3", "d42ace28b870e8072cf30e32e385579c57b9cc96ec74fa1f30f30da9c14f3cc0", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "afc293d8a1140d6591b53e3eaf415ca92842cb1d32fad3c450c6f045f7f91b60"},
|
"ueberauth": {:hex, :ueberauth, "0.6.3", "d42ace28b870e8072cf30e32e385579c57b9cc96ec74fa1f30f30da9c14f3cc0", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "afc293d8a1140d6591b53e3eaf415ca92842cb1d32fad3c450c6f045f7f91b60"},
|
||||||
"unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"},
|
"unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm", "1d1848c40487cdb0b30e8ed975e34e025860c02e419cb615d255849f3427439d"},
|
||||||
"unsafe": {:hex, :unsafe, "1.0.1", "a27e1874f72ee49312e0a9ec2e0b27924214a05e3ddac90e91727bc76f8613d8", [:mix], [], "hexpm", "6c7729a2d214806450d29766abc2afaa7a2cbecf415be64f36a6691afebb50e5"},
|
"unsafe": {:hex, :unsafe, "1.0.1", "a27e1874f72ee49312e0a9ec2e0b27924214a05e3ddac90e91727bc76f8613d8", [:mix], [], "hexpm", "6c7729a2d214806450d29766abc2afaa7a2cbecf415be64f36a6691afebb50e5"},
|
||||||
|
|
|
@ -3,8 +3,8 @@ msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2020-09-20 13:18+0000\n"
|
"POT-Creation-Date: 2020-09-20 13:18+0000\n"
|
||||||
"PO-Revision-Date: 2020-09-20 14:48+0000\n"
|
"PO-Revision-Date: 2020-10-22 18:25+0000\n"
|
||||||
"Last-Translator: Kana <gudzpoz@live.com>\n"
|
"Last-Translator: shironeko <shironeko@tesaguri.club>\n"
|
||||||
"Language-Team: Chinese (Simplified) <https://translate.pleroma.social/"
|
"Language-Team: Chinese (Simplified) <https://translate.pleroma.social/"
|
||||||
"projects/pleroma/pleroma/zh_Hans/>\n"
|
"projects/pleroma/pleroma/zh_Hans/>\n"
|
||||||
"Language: zh_Hans\n"
|
"Language: zh_Hans\n"
|
||||||
|
@ -49,7 +49,7 @@ msgstr "是被保留的"
|
||||||
|
|
||||||
## From Ecto.Changeset.validate_confirmation/3
|
## From Ecto.Changeset.validate_confirmation/3
|
||||||
msgid "does not match confirmation"
|
msgid "does not match confirmation"
|
||||||
msgstr ""
|
msgstr "与验证不符"
|
||||||
|
|
||||||
## From Ecto.Changeset.no_assoc_constraint/3
|
## From Ecto.Changeset.no_assoc_constraint/3
|
||||||
msgid "is still associated with this entry"
|
msgid "is still associated with this entry"
|
||||||
|
@ -138,12 +138,12 @@ msgstr "不能获取收藏"
|
||||||
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:438
|
#: lib/pleroma/web/activity_pub/activity_pub_controller.ex:438
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Can't like object"
|
msgid "Can't like object"
|
||||||
msgstr ""
|
msgstr "不能喜欢对象"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/utils.ex:563
|
#: lib/pleroma/web/common_api/utils.ex:563
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Cannot post an empty status without attachments"
|
msgid "Cannot post an empty status without attachments"
|
||||||
msgstr ""
|
msgstr "无法发送空白且不包含附件的状态"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/utils.ex:511
|
#: lib/pleroma/web/common_api/utils.ex:511
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
|
@ -153,100 +153,100 @@ msgstr ""
|
||||||
#: lib/pleroma/config/config_db.ex:191
|
#: lib/pleroma/config/config_db.ex:191
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Config with params %{params} not found"
|
msgid "Config with params %{params} not found"
|
||||||
msgstr ""
|
msgstr "无法找到包含参数 %{params} 的配置"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/common_api.ex:181
|
#: lib/pleroma/web/common_api/common_api.ex:181
|
||||||
#: lib/pleroma/web/common_api/common_api.ex:185
|
#: lib/pleroma/web/common_api/common_api.ex:185
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Could not delete"
|
msgid "Could not delete"
|
||||||
msgstr ""
|
msgstr "无法删除"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/common_api.ex:231
|
#: lib/pleroma/web/common_api/common_api.ex:231
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Could not favorite"
|
msgid "Could not favorite"
|
||||||
msgstr ""
|
msgstr "无法收藏"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/common_api.ex:453
|
#: lib/pleroma/web/common_api/common_api.ex:453
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Could not pin"
|
msgid "Could not pin"
|
||||||
msgstr ""
|
msgstr "无法置顶"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/common_api.ex:278
|
#: lib/pleroma/web/common_api/common_api.ex:278
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Could not unfavorite"
|
msgid "Could not unfavorite"
|
||||||
msgstr ""
|
msgstr "无法取消收藏"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/common_api.ex:463
|
#: lib/pleroma/web/common_api/common_api.ex:463
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Could not unpin"
|
msgid "Could not unpin"
|
||||||
msgstr ""
|
msgstr "无法取消置顶"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/common_api.ex:216
|
#: lib/pleroma/web/common_api/common_api.ex:216
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Could not unrepeat"
|
msgid "Could not unrepeat"
|
||||||
msgstr ""
|
msgstr "无法取消转发"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/common_api.ex:512
|
#: lib/pleroma/web/common_api/common_api.ex:512
|
||||||
#: lib/pleroma/web/common_api/common_api.ex:521
|
#: lib/pleroma/web/common_api/common_api.ex:521
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Could not update state"
|
msgid "Could not update state"
|
||||||
msgstr ""
|
msgstr "无法更新状态"
|
||||||
|
|
||||||
#: lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex:207
|
#: lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex:207
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Error."
|
msgid "Error."
|
||||||
msgstr ""
|
msgstr "错误。"
|
||||||
|
|
||||||
#: lib/pleroma/web/twitter_api/twitter_api.ex:106
|
#: lib/pleroma/web/twitter_api/twitter_api.ex:106
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Invalid CAPTCHA"
|
msgid "Invalid CAPTCHA"
|
||||||
msgstr ""
|
msgstr "无效的验证码"
|
||||||
|
|
||||||
#: lib/pleroma/web/mastodon_api/controllers/account_controller.ex:116
|
#: lib/pleroma/web/mastodon_api/controllers/account_controller.ex:116
|
||||||
#: lib/pleroma/web/oauth/oauth_controller.ex:568
|
#: lib/pleroma/web/oauth/oauth_controller.ex:568
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Invalid credentials"
|
msgid "Invalid credentials"
|
||||||
msgstr ""
|
msgstr "无效的凭据"
|
||||||
|
|
||||||
#: lib/pleroma/plugs/ensure_authenticated_plug.ex:38
|
#: lib/pleroma/plugs/ensure_authenticated_plug.ex:38
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Invalid credentials."
|
msgid "Invalid credentials."
|
||||||
msgstr ""
|
msgstr "无效的凭据。"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/common_api.ex:355
|
#: lib/pleroma/web/common_api/common_api.ex:355
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Invalid indices"
|
msgid "Invalid indices"
|
||||||
msgstr ""
|
msgstr "无效的索引"
|
||||||
|
|
||||||
#: lib/pleroma/web/admin_api/controllers/fallback_controller.ex:29
|
#: lib/pleroma/web/admin_api/controllers/fallback_controller.ex:29
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Invalid parameters"
|
msgid "Invalid parameters"
|
||||||
msgstr ""
|
msgstr "无效的参数"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/utils.ex:414
|
#: lib/pleroma/web/common_api/utils.ex:414
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Invalid password."
|
msgid "Invalid password."
|
||||||
msgstr ""
|
msgstr "无效的密码。"
|
||||||
|
|
||||||
#: lib/pleroma/web/mastodon_api/controllers/account_controller.ex:220
|
#: lib/pleroma/web/mastodon_api/controllers/account_controller.ex:220
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Invalid request"
|
msgid "Invalid request"
|
||||||
msgstr ""
|
msgstr "无效的请求"
|
||||||
|
|
||||||
#: lib/pleroma/web/twitter_api/twitter_api.ex:109
|
#: lib/pleroma/web/twitter_api/twitter_api.ex:109
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Kocaptcha service unavailable"
|
msgid "Kocaptcha service unavailable"
|
||||||
msgstr ""
|
msgstr "Kocaptcha 服务不可用"
|
||||||
|
|
||||||
#: lib/pleroma/web/mastodon_api/controllers/account_controller.ex:112
|
#: lib/pleroma/web/mastodon_api/controllers/account_controller.ex:112
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "Missing parameters"
|
msgid "Missing parameters"
|
||||||
msgstr ""
|
msgstr "缺少参数"
|
||||||
|
|
||||||
#: lib/pleroma/web/common_api/utils.ex:547
|
#: lib/pleroma/web/common_api/utils.ex:547
|
||||||
#, elixir-format
|
#, elixir-format
|
||||||
msgid "No such conversation"
|
msgid "No such conversation"
|
||||||
msgstr ""
|
msgstr "没有该对话"
|
||||||
|
|
||||||
#: lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:388
|
#: lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:388
|
||||||
#: lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:414 lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:456
|
#: lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:414 lib/pleroma/web/admin_api/controllers/admin_api_controller.ex:456
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.RemoveUnreadConversationCountFromUser do
|
||||||
|
use Ecto.Migration
|
||||||
|
import Ecto.Query
|
||||||
|
alias Pleroma.Repo
|
||||||
|
|
||||||
|
def up do
|
||||||
|
alter table(:users) do
|
||||||
|
remove_if_exists(:unread_conversation_count, :integer)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down do
|
||||||
|
alter table(:users) do
|
||||||
|
add_if_not_exists(:unread_conversation_count, :integer, default: 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
flush()
|
||||||
|
recalc_unread_conversation_count()
|
||||||
|
end
|
||||||
|
|
||||||
|
defp recalc_unread_conversation_count do
|
||||||
|
participations_subquery =
|
||||||
|
from(
|
||||||
|
p in "conversation_participations",
|
||||||
|
where: p.read == false,
|
||||||
|
group_by: p.user_id,
|
||||||
|
select: %{user_id: p.user_id, unread_conversation_count: count(p.id)}
|
||||||
|
)
|
||||||
|
|
||||||
|
from(
|
||||||
|
u in "users",
|
||||||
|
join: p in subquery(participations_subquery),
|
||||||
|
on: p.user_id == u.id,
|
||||||
|
update: [set: [unread_conversation_count: p.unread_conversation_count]]
|
||||||
|
)
|
||||||
|
|> Repo.update_all([])
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,12 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.AddUnreadIndexToConversationParticipation do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
create(
|
||||||
|
index(:conversation_participations, [:user_id],
|
||||||
|
where: "read = false",
|
||||||
|
name: "unread_conversation_participation_count_index"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
17
priv/repo/migrations/20200831192323_create_backups.exs
Normal file
17
priv/repo/migrations/20200831192323_create_backups.exs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.CreateBackups do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
create_if_not_exists table(:backups) do
|
||||||
|
add(:user_id, references(:users, type: :uuid, on_delete: :delete_all))
|
||||||
|
add(:file_name, :string, null: false)
|
||||||
|
add(:content_type, :string, null: false)
|
||||||
|
add(:processed, :boolean, null: false, default: false)
|
||||||
|
add(:file_size, :bigint)
|
||||||
|
|
||||||
|
timestamps()
|
||||||
|
end
|
||||||
|
|
||||||
|
create_if_not_exists(index(:backups, [:user_id]))
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Repo.Migrations.RefactorLockedUserField do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def up do
|
||||||
|
execute("ALTER TABLE users RENAME COLUMN locked TO is_locked;")
|
||||||
|
end
|
||||||
|
|
||||||
|
def down do
|
||||||
|
execute("ALTER TABLE users RENAME COLUMN is_locked TO locked;")
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Repo.Migrations.RefactorDiscoverableUserField do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def up do
|
||||||
|
execute("ALTER TABLE users RENAME COLUMN discoverable TO is_discoverable;")
|
||||||
|
end
|
||||||
|
|
||||||
|
def down do
|
||||||
|
execute("ALTER TABLE users RENAME COLUMN is_discoverable TO discoverable;")
|
||||||
|
end
|
||||||
|
end
|
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.5 KiB |
68
test/fixtures/mastodon-post-activity-nsfw.json
vendored
Normal file
68
test/fixtures/mastodon-post-activity-nsfw.json
vendored
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
{
|
||||||
|
"@context": [
|
||||||
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
"https://w3id.org/security/v1",
|
||||||
|
{
|
||||||
|
"Emoji": "toot:Emoji",
|
||||||
|
"Hashtag": "as:Hashtag",
|
||||||
|
"atomUri": "ostatus:atomUri",
|
||||||
|
"conversation": "ostatus:conversation",
|
||||||
|
"inReplyToAtomUri": "ostatus:inReplyToAtomUri",
|
||||||
|
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
||||||
|
"movedTo": "as:movedTo",
|
||||||
|
"ostatus": "http://ostatus.org#",
|
||||||
|
"toot": "http://joinmastodon.org/ns#"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actor": "http://mastodon.example.org/users/admin",
|
||||||
|
"cc": [
|
||||||
|
"http://mastodon.example.org/users/admin/followers",
|
||||||
|
"http://localtesting.pleroma.lol/users/lain"
|
||||||
|
],
|
||||||
|
"id": "http://mastodon.example.org/users/admin/statuses/99512778738411822/activity",
|
||||||
|
"nickname": "lain",
|
||||||
|
"object": {
|
||||||
|
"atomUri": "http://mastodon.example.org/users/admin/statuses/99512778738411822",
|
||||||
|
"attachment": [],
|
||||||
|
"attributedTo": "http://mastodon.example.org/users/admin",
|
||||||
|
"cc": [
|
||||||
|
"http://mastodon.example.org/users/admin/followers",
|
||||||
|
"http://localtesting.pleroma.lol/users/lain"
|
||||||
|
],
|
||||||
|
"content": "<p><span class=\"h-card\"><a href=\"http://localtesting.pleroma.lol/users/lain\" class=\"u-url mention\">@<span>lain</span></a></span> #moo</p>",
|
||||||
|
"conversation": "tag:mastodon.example.org,2018-02-12:objectId=20:objectType=Conversation",
|
||||||
|
"id": "http://mastodon.example.org/users/admin/statuses/99512778738411822",
|
||||||
|
"inReplyTo": null,
|
||||||
|
"inReplyToAtomUri": null,
|
||||||
|
"published": "2018-02-12T14:08:20Z",
|
||||||
|
"summary": "cw",
|
||||||
|
"tag": [
|
||||||
|
{
|
||||||
|
"href": "http://localtesting.pleroma.lol/users/lain",
|
||||||
|
"name": "@lain@localtesting.pleroma.lol",
|
||||||
|
"type": "Mention"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"href": "http://mastodon.example.org/tags/nsfw",
|
||||||
|
"name": "#NSFW",
|
||||||
|
"type": "Hashtag"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"type": "Note",
|
||||||
|
"url": "http://mastodon.example.org/@admin/99512778738411822"
|
||||||
|
},
|
||||||
|
"published": "2018-02-12T14:08:20Z",
|
||||||
|
"signature": {
|
||||||
|
"created": "2018-02-12T14:08:20Z",
|
||||||
|
"creator": "http://mastodon.example.org/users/admin#main-key",
|
||||||
|
"signatureValue": "rnNfcopkc6+Ju73P806popcfwrK9wGYHaJVG1/ZvrlEbWVDzaHjkXqj9Q3/xju5l8CSn9tvSgCCtPFqZsFQwn/pFIFUcw7ZWB2xi4bDm3NZ3S4XQ8JRaaX7og5hFxAhWkGhJhAkfxVnOg2hG+w2d/7d7vRVSC1vo5ip4erUaA/PkWusZvPIpxnRWoXaxJsFmVx0gJgjpJkYDyjaXUlp+jmaoseeZ4EPQUWqHLKJ59PRG0mg8j2xAjYH9nQaN14qMRmTGPxY8gfv/CUFcatA+8VJU9KEsJkDAwLVvglydNTLGrxpAJU78a2eaht0foV43XUIZGe3DKiJPgE+UOKGCJw==",
|
||||||
|
"type": "RsaSignature2017"
|
||||||
|
},
|
||||||
|
"to": [
|
||||||
|
"https://www.w3.org/ns/activitystreams#Public"
|
||||||
|
],
|
||||||
|
"type": "Create"
|
||||||
|
}
|
46
test/fixtures/mewmew_no_name.json
vendored
Normal file
46
test/fixtures/mewmew_no_name.json
vendored
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
"@context" : [
|
||||||
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
"https://princess.cat/schemas/litepub-0.1.jsonld",
|
||||||
|
{
|
||||||
|
"@language" : "und"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"attachment" : [],
|
||||||
|
"capabilities" : {
|
||||||
|
"acceptsChatMessages" : true
|
||||||
|
},
|
||||||
|
"discoverable" : false,
|
||||||
|
"endpoints" : {
|
||||||
|
"oauthAuthorizationEndpoint" : "https://princess.cat/oauth/authorize",
|
||||||
|
"oauthRegistrationEndpoint" : "https://princess.cat/api/v1/apps",
|
||||||
|
"oauthTokenEndpoint" : "https://princess.cat/oauth/token",
|
||||||
|
"sharedInbox" : "https://princess.cat/inbox",
|
||||||
|
"uploadMedia" : "https://princess.cat/api/ap/upload_media"
|
||||||
|
},
|
||||||
|
"followers" : "https://princess.cat/users/mewmew/followers",
|
||||||
|
"following" : "https://princess.cat/users/mewmew/following",
|
||||||
|
"icon" : {
|
||||||
|
"type" : "Image",
|
||||||
|
"url" : "https://princess.cat/media/12794fb50e86911e65be97f69196814049dcb398a2f8b58b99bb6591576e648c.png?name=blobcatpresentpink.png"
|
||||||
|
},
|
||||||
|
"id" : "https://princess.cat/users/mewmew",
|
||||||
|
"image" : {
|
||||||
|
"type" : "Image",
|
||||||
|
"url" : "https://princess.cat/media/05d8bf3953ab6028fc920494ffc643fbee9dcef40d7bdd06f107e19acbfbd7f9.png"
|
||||||
|
},
|
||||||
|
"inbox" : "https://princess.cat/users/mewmew/inbox",
|
||||||
|
"manuallyApprovesFollowers" : true,
|
||||||
|
"name" : " ",
|
||||||
|
"outbox" : "https://princess.cat/users/mewmew/outbox",
|
||||||
|
"preferredUsername" : "mewmew",
|
||||||
|
"publicKey" : {
|
||||||
|
"id" : "https://princess.cat/users/mewmew#main-key",
|
||||||
|
"owner" : "https://princess.cat/users/mewmew",
|
||||||
|
"publicKeyPem" : "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAru7VpygVef4zrFwnj0Mh\nrbO/2z2EdKN3rERtNrT8zWsLXNLQ50lfpRPnGDrd+xq7Rva4EIu0d5KJJ9n4vtY0\nuxK3On9vA2oyjLlR9O0lI3XTrHJborG3P7IPXrmNUMFpHiFHNqHp5tugUrs1gUFq\n7tmOmM92IP4Wjk8qNHFcsfnUbaPTX7sNIhteQKdi5HrTb/6lrEIe4G/FlMKRqxo3\nRNHuv6SNFQuiUKvFzjzazvjkjvBSm+aFROgdHa2tKl88StpLr7xmuY8qNFCRT6W0\nLacRp6c8ah5f03Kd+xCBVhCKvKaF1K0ERnQTBiitUh85md+Mtx/CoDoLnmpnngR3\nvQIDAQAB\n-----END PUBLIC KEY-----\n\n"
|
||||||
|
},
|
||||||
|
"summary" : "please reply to my posts as direct messages if you have many followers",
|
||||||
|
"tag" : [],
|
||||||
|
"type" : "Person",
|
||||||
|
"url" : "https://princess.cat/users/mewmew"
|
||||||
|
}
|
|
@ -5,6 +5,8 @@
|
||||||
defmodule Mix.Tasks.Pleroma.InstanceTest do
|
defmodule Mix.Tasks.Pleroma.InstanceTest do
|
||||||
use ExUnit.Case
|
use ExUnit.Case
|
||||||
|
|
||||||
|
@release_env_file "./test/pleroma.test.env"
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
File.mkdir_p!(tmp_path())
|
File.mkdir_p!(tmp_path())
|
||||||
|
|
||||||
|
@ -16,6 +18,8 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
|
||||||
File.rm_rf(Path.join(static_dir, "robots.txt"))
|
File.rm_rf(Path.join(static_dir, "robots.txt"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if File.exists?(@release_env_file), do: File.rm_rf(@release_env_file)
|
||||||
|
|
||||||
Pleroma.Config.put([:instance, :static_dir], static_dir)
|
Pleroma.Config.put([:instance, :static_dir], static_dir)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -69,7 +73,9 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
|
||||||
"--dedupe-uploads",
|
"--dedupe-uploads",
|
||||||
"n",
|
"n",
|
||||||
"--anonymize-uploads",
|
"--anonymize-uploads",
|
||||||
"n"
|
"n",
|
||||||
|
"--release-env-file",
|
||||||
|
@release_env_file
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -91,6 +97,9 @@ defmodule Mix.Tasks.Pleroma.InstanceTest do
|
||||||
assert generated_config =~ "filters: [Pleroma.Upload.Filter.ExifTool]"
|
assert generated_config =~ "filters: [Pleroma.Upload.Filter.ExifTool]"
|
||||||
assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
|
assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
|
||||||
assert File.exists?(Path.expand("./test/instance/static/robots.txt"))
|
assert File.exists?(Path.expand("./test/instance/static/robots.txt"))
|
||||||
|
assert File.exists?(@release_env_file)
|
||||||
|
|
||||||
|
assert File.read!(@release_env_file) =~ ~r/^RELEASE_COOKIE=.*/
|
||||||
end
|
end
|
||||||
|
|
||||||
defp generated_setup_psql do
|
defp generated_setup_psql do
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue