Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into emr_develop
This commit is contained in:
commit
a9b7355bc1
|
@ -70,6 +70,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Added Pleroma.Upload.Filter.Exiftool as an alternate EXIF stripping mechanism targeting GPS/location metadata.
|
- Added Pleroma.Upload.Filter.Exiftool as an alternate EXIF stripping mechanism targeting GPS/location metadata.
|
||||||
- "By approval" registrations mode.
|
- "By approval" registrations mode.
|
||||||
- Configuration: Added `:welcome` settings for the welcome message to newly registered users.
|
- Configuration: Added `:welcome` settings for the welcome message to newly registered users.
|
||||||
|
- Ability to hide favourites and emoji reactions in the API with `[:instance, :show_reactions]` config.
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>API Changes</summary>
|
<summary>API Changes</summary>
|
||||||
|
|
|
@ -172,7 +172,7 @@ config :mime, :types, %{
|
||||||
"application/ld+json" => ["activity+json"]
|
"application/ld+json" => ["activity+json"]
|
||||||
}
|
}
|
||||||
|
|
||||||
config :tesla, adapter: Tesla.Adapter.Gun
|
config :tesla, adapter: Tesla.Adapter.Hackney
|
||||||
|
|
||||||
# Configures http settings, upstream proxy etc.
|
# Configures http settings, upstream proxy etc.
|
||||||
config :pleroma, :http,
|
config :pleroma, :http,
|
||||||
|
@ -252,7 +252,8 @@ config :pleroma, :instance,
|
||||||
number: 5,
|
number: 5,
|
||||||
length: 16
|
length: 16
|
||||||
]
|
]
|
||||||
]
|
],
|
||||||
|
show_reactions: true
|
||||||
|
|
||||||
config :pleroma, :welcome,
|
config :pleroma, :welcome,
|
||||||
direct_message: [
|
direct_message: [
|
||||||
|
|
|
@ -955,6 +955,11 @@ config :pleroma, :config_description, [
|
||||||
description:
|
description:
|
||||||
"The instance thumbnail can be any image that represents your instance and is used by some apps or services when they display information about your instance.",
|
"The instance thumbnail can be any image that represents your instance and is used by some apps or services when they display information about your instance.",
|
||||||
suggestions: ["/instance/thumbnail.jpeg"]
|
suggestions: ["/instance/thumbnail.jpeg"]
|
||||||
|
},
|
||||||
|
%{
|
||||||
|
key: :show_reactions,
|
||||||
|
type: :boolean,
|
||||||
|
description: "Let favourites and emoji reactions be viewed through the API."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -50,7 +50,7 @@ Request parameters can be passed via [query strings](https://en.wikipedia.org/wi
|
||||||
* Authentication: not required
|
* Authentication: not required
|
||||||
* Params: none
|
* Params: none
|
||||||
* Response: Provider specific JSON, the only guaranteed parameter is `type`
|
* Response: Provider specific JSON, the only guaranteed parameter is `type`
|
||||||
* Example response: `{"type": "kocaptcha", "token": "whatever", "url": "https://captcha.kotobank.ch/endpoint", seconds_valid: 300}`
|
* Example response: `{"type": "kocaptcha", "token": "whatever", "url": "https://captcha.kotobank.ch/endpoint", "seconds_valid": 300}`
|
||||||
|
|
||||||
## `/api/pleroma/delete_account`
|
## `/api/pleroma/delete_account`
|
||||||
### Delete an account
|
### Delete an account
|
||||||
|
|
|
@ -62,6 +62,7 @@ To add configuration to your config file, you can copy it from the base config.
|
||||||
* `registration_reason_length`: Maximum registration reason length (default: `500`).
|
* `registration_reason_length`: Maximum registration reason length (default: `500`).
|
||||||
* `external_user_synchronization`: Enabling following/followers counters synchronization for external users.
|
* `external_user_synchronization`: Enabling following/followers counters synchronization for external users.
|
||||||
* `cleanup_attachments`: Remove attachments along with statuses. Does not affect duplicate files and attachments without status. Enabling this will increase load to database when deleting statuses on larger instances.
|
* `cleanup_attachments`: Remove attachments along with statuses. Does not affect duplicate files and attachments without status. Enabling this will increase load to database when deleting statuses on larger instances.
|
||||||
|
* `show_reactions`: Let favourites and emoji reactions be viewed through the API (default: `true`).
|
||||||
|
|
||||||
## Welcome
|
## Welcome
|
||||||
* `direct_message`: - welcome message sent as a direct message.
|
* `direct_message`: - welcome message sent as a direct message.
|
||||||
|
|
|
@ -5,13 +5,7 @@ The configuration of Pleroma has traditionally been managed with a config file,
|
||||||
|
|
||||||
## Migration to database config
|
## Migration to database config
|
||||||
|
|
||||||
1. Stop your Pleroma instance and edit your Pleroma config to enable database configuration:
|
1. Run the mix task to migrate to the database. You'll receive some debugging output and a few messages informing you of what happened.
|
||||||
|
|
||||||
```
|
|
||||||
config :pleroma, configurable_from_database: true
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Run the mix task to migrate to the database. You'll receive some debugging output and a few messages informing you of what happened.
|
|
||||||
|
|
||||||
**Source:**
|
**Source:**
|
||||||
|
|
||||||
|
@ -23,6 +17,8 @@ The configuration of Pleroma has traditionally been managed with a config file,
|
||||||
|
|
||||||
**OTP:**
|
**OTP:**
|
||||||
|
|
||||||
|
*Note: OTP users need Pleroma to be running for `pleroma_ctl` commands to work*
|
||||||
|
|
||||||
```
|
```
|
||||||
$ ./bin/pleroma_ctl config migrate_to_db
|
$ ./bin/pleroma_ctl config migrate_to_db
|
||||||
```
|
```
|
||||||
|
@ -47,14 +43,21 @@ INSERT INTO "config" ("group","key","value","inserted_at","updated_at") VALUES (
|
||||||
Settings for group :pleroma migrated.
|
Settings for group :pleroma migrated.
|
||||||
```
|
```
|
||||||
|
|
||||||
3. It is recommended to backup your config file now.
|
2. It is recommended to backup your config file now.
|
||||||
|
|
||||||
```
|
```
|
||||||
cp config/dev.secret.exs config/dev.secret.exs.orig
|
cp config/dev.secret.exs config/dev.secret.exs.orig
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Now you can edit your config file and strip it down to the only settings which are not possible to control in the database. e.g., the Postgres and webserver (Endpoint) settings cannot be controlled in the database because the application needs the settings to start up and access the database.
|
3. Edit your Pleroma config to enable database configuration:
|
||||||
|
|
||||||
⚠️ **THIS IS NOT REQUIRED**
|
```
|
||||||
|
config :pleroma, configurable_from_database: true
|
||||||
|
```
|
||||||
|
|
||||||
|
4. ⚠️ **THIS IS NOT REQUIRED** ⚠️
|
||||||
|
|
||||||
|
Now you can edit your config file and strip it down to the only settings which are not possible to control in the database. e.g., the Postgres (Repo) and webserver (Endpoint) settings cannot be controlled in the database because the application needs the settings to start up and access the database.
|
||||||
|
|
||||||
Any settings in the database will override those in the config file, but you may find it less confusing if the setting is only declared in one place.
|
Any settings in the database will override those in the config file, but you may find it less confusing if the setting is only declared in one place.
|
||||||
|
|
||||||
|
@ -62,7 +65,7 @@ INSERT INTO "config" ("group","key","value","inserted_at","updated_at") VALUES (
|
||||||
|
|
||||||
* config :pleroma, Pleroma.Web.Endpoint
|
* config :pleroma, Pleroma.Web.Endpoint
|
||||||
* config :pleroma, Pleroma.Repo
|
* config :pleroma, Pleroma.Repo
|
||||||
* config :pleroma, configurable_from_database
|
* config :pleroma, configurable\_from\_database
|
||||||
* config :pleroma, :database, rum_enabled
|
* config :pleroma, :database, rum_enabled
|
||||||
* config :pleroma, :connections_pool
|
* config :pleroma, :connections_pool
|
||||||
|
|
||||||
|
@ -74,7 +77,6 @@ use Mix.Config
|
||||||
config :pleroma, Pleroma.Web.Endpoint,
|
config :pleroma, Pleroma.Web.Endpoint,
|
||||||
url: [host: "cool.pleroma.site", scheme: "https", port: 443]
|
url: [host: "cool.pleroma.site", scheme: "https", port: 443]
|
||||||
|
|
||||||
|
|
||||||
config :pleroma, Pleroma.Repo,
|
config :pleroma, Pleroma.Repo,
|
||||||
adapter: Ecto.Adapters.Postgres,
|
adapter: Ecto.Adapters.Postgres,
|
||||||
username: "pleroma",
|
username: "pleroma",
|
||||||
|
@ -85,14 +87,12 @@ config :pleroma, Pleroma.Repo,
|
||||||
config :pleroma, configurable_from_database: true
|
config :pleroma, configurable_from_database: true
|
||||||
```
|
```
|
||||||
|
|
||||||
5. Start your instance back up and you can now access the Settings tab in AdminFE.
|
5. Restart your instance and you can now access the Settings tab in AdminFE.
|
||||||
|
|
||||||
|
|
||||||
## Reverting back from database config
|
## Reverting back from database config
|
||||||
|
|
||||||
1. Stop your Pleroma instance.
|
1. Run the mix task to migrate back from the database. You'll receive some debugging output and a few messages informing you of what happened.
|
||||||
|
|
||||||
2. Run the mix task to migrate back from the database. You'll receive some debugging output and a few messages informing you of what happened.
|
|
||||||
|
|
||||||
**Source:**
|
**Source:**
|
||||||
|
|
||||||
|
@ -117,7 +117,9 @@ SELECT c0."id", c0."key", c0."group", c0."value", c0."inserted_at", c0."updated_
|
||||||
Database configuration settings have been saved to config/dev.exported_from_db.secret.exs
|
Database configuration settings have been saved to config/dev.exported_from_db.secret.exs
|
||||||
```
|
```
|
||||||
|
|
||||||
3. The in-database configuration still exists, but it will not be used if you remove `config :pleroma, configurable_from_database: true` from your config.
|
2. Remove `config :pleroma, configurable_from_database: true` from your config. The in-database configuration still exists, but it will not be used. Future migrations will erase the database config before importing your config file again.
|
||||||
|
|
||||||
|
3. Restart your instance.
|
||||||
|
|
||||||
## Debugging
|
## Debugging
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,46 @@ defmodule Pleroma.Web.ApiSpec.Schemas.ChatMessage do
|
||||||
content: %Schema{type: :string, nullable: true},
|
content: %Schema{type: :string, nullable: true},
|
||||||
created_at: %Schema{type: :string, format: :"date-time"},
|
created_at: %Schema{type: :string, format: :"date-time"},
|
||||||
emojis: %Schema{type: :array},
|
emojis: %Schema{type: :array},
|
||||||
attachment: %Schema{type: :object, nullable: true}
|
attachment: %Schema{type: :object, nullable: true},
|
||||||
|
card: %Schema{
|
||||||
|
type: :object,
|
||||||
|
nullable: true,
|
||||||
|
description: "Preview card for links included within status content",
|
||||||
|
required: [:url, :title, :description, :type],
|
||||||
|
properties: %{
|
||||||
|
type: %Schema{
|
||||||
|
type: :string,
|
||||||
|
enum: ["link", "photo", "video", "rich"],
|
||||||
|
description: "The type of the preview card"
|
||||||
|
},
|
||||||
|
provider_name: %Schema{
|
||||||
|
type: :string,
|
||||||
|
nullable: true,
|
||||||
|
description: "The provider of the original resource"
|
||||||
|
},
|
||||||
|
provider_url: %Schema{
|
||||||
|
type: :string,
|
||||||
|
format: :uri,
|
||||||
|
description: "A link to the provider of the original resource"
|
||||||
|
},
|
||||||
|
url: %Schema{type: :string, format: :uri, description: "Location of linked resource"},
|
||||||
|
image: %Schema{
|
||||||
|
type: :string,
|
||||||
|
nullable: true,
|
||||||
|
format: :uri,
|
||||||
|
description: "Preview thumbnail"
|
||||||
|
},
|
||||||
|
title: %Schema{type: :string, description: "Title of linked resource"},
|
||||||
|
description: %Schema{type: :string, description: "Description of preview"}
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
example: %{
|
example: %{
|
||||||
"account_id" => "someflakeid",
|
"account_id" => "someflakeid",
|
||||||
"chat_id" => "1",
|
"chat_id" => "1",
|
||||||
"content" => "hey you again",
|
"content" => "hey you again",
|
||||||
"created_at" => "2020-04-21T15:06:45.000Z",
|
"created_at" => "2020-04-21T15:06:45.000Z",
|
||||||
|
"card" => nil,
|
||||||
"emojis" => [
|
"emojis" => [
|
||||||
%{
|
%{
|
||||||
"static_url" => "https://dontbulling.me/emoji/Firefox.gif",
|
"static_url" => "https://dontbulling.me/emoji/Firefox.gif",
|
||||||
|
|
|
@ -100,7 +100,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
||||||
def create(%{assigns: %{app: app}, body_params: params} = conn, _params) do
|
def create(%{assigns: %{app: app}, body_params: params} = conn, _params) do
|
||||||
with :ok <- validate_email_param(params),
|
with :ok <- validate_email_param(params),
|
||||||
:ok <- TwitterAPI.validate_captcha(app, params),
|
:ok <- TwitterAPI.validate_captcha(app, params),
|
||||||
{:ok, user} <- TwitterAPI.register_user(params, need_confirmation: true),
|
{:ok, user} <- TwitterAPI.register_user(params),
|
||||||
{:ok, token} <- Token.create_token(app, user, %{scopes: app.scopes}) do
|
{:ok, token} <- Token.create_token(app, user, %{scopes: app.scopes}) do
|
||||||
json(conn, OAuthView.render("token.json", %{user: user, token: token}))
|
json(conn, OAuthView.render("token.json", %{user: user, token: token}))
|
||||||
else
|
else
|
||||||
|
|
|
@ -314,7 +314,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
||||||
|
|
||||||
@doc "GET /api/v1/statuses/:id/favourited_by"
|
@doc "GET /api/v1/statuses/:id/favourited_by"
|
||||||
def favourited_by(%{assigns: %{user: user}} = conn, %{id: id}) do
|
def favourited_by(%{assigns: %{user: user}} = conn, %{id: id}) do
|
||||||
with %Activity{} = activity <- Activity.get_by_id_with_object(id),
|
with true <- Pleroma.Config.get([:instance, :show_reactions]),
|
||||||
|
%Activity{} = activity <- Activity.get_by_id_with_object(id),
|
||||||
{:visible, true} <- {:visible, Visibility.visible_for_user?(activity, user)},
|
{:visible, true} <- {:visible, Visibility.visible_for_user?(activity, user)},
|
||||||
%Object{data: %{"likes" => likes}} <- Object.normalize(activity) do
|
%Object{data: %{"likes" => likes}} <- Object.normalize(activity) do
|
||||||
users =
|
users =
|
||||||
|
|
|
@ -25,7 +25,8 @@ defmodule Pleroma.Web.PleromaAPI.EmojiReactionController do
|
||||||
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
|
action_fallback(Pleroma.Web.MastodonAPI.FallbackController)
|
||||||
|
|
||||||
def index(%{assigns: %{user: user}} = conn, %{id: activity_id} = params) do
|
def index(%{assigns: %{user: user}} = conn, %{id: activity_id} = params) do
|
||||||
with %Activity{} = activity <- Activity.get_by_id_with_object(activity_id),
|
with true <- Pleroma.Config.get([:instance, :show_reactions]),
|
||||||
|
%Activity{} = activity <- Activity.get_by_id_with_object(activity_id),
|
||||||
%Object{data: %{"reactions" => reactions}} when is_list(reactions) <-
|
%Object{data: %{"reactions" => reactions}} when is_list(reactions) <-
|
||||||
Object.normalize(activity) do
|
Object.normalize(activity) do
|
||||||
reactions = filter(reactions, params)
|
reactions = filter(reactions, params)
|
||||||
|
|
|
@ -14,7 +14,7 @@ defmodule Pleroma.Web.PleromaAPI.Chat.MessageReferenceView do
|
||||||
%{
|
%{
|
||||||
chat_message_reference: %{
|
chat_message_reference: %{
|
||||||
id: id,
|
id: id,
|
||||||
object: %{data: chat_message},
|
object: %{data: chat_message} = object,
|
||||||
chat_id: chat_id,
|
chat_id: chat_id,
|
||||||
unread: unread
|
unread: unread
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,12 @@ defmodule Pleroma.Web.PleromaAPI.Chat.MessageReferenceView do
|
||||||
attachment:
|
attachment:
|
||||||
chat_message["attachment"] &&
|
chat_message["attachment"] &&
|
||||||
StatusView.render("attachment.json", attachment: chat_message["attachment"]),
|
StatusView.render("attachment.json", attachment: chat_message["attachment"]),
|
||||||
unread: unread
|
unread: unread,
|
||||||
|
card:
|
||||||
|
StatusView.render(
|
||||||
|
"card.json",
|
||||||
|
Pleroma.Web.RichMedia.Helpers.fetch_data_for_object(object)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -49,11 +49,11 @@ defmodule Pleroma.Web.RichMedia.Helpers do
|
||||||
|> hd
|
|> hd
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_data_for_activity(%Activity{data: %{"type" => "Create"}} = activity) do
|
def fetch_data_for_object(object) do
|
||||||
with true <- Config.get([:rich_media, :enabled]),
|
with true <- Config.get([:rich_media, :enabled]),
|
||||||
%Object{} = object <- Object.normalize(activity),
|
|
||||||
false <- object.data["sensitive"] || false,
|
false <- object.data["sensitive"] || false,
|
||||||
{:ok, page_url} <- HTML.extract_first_external_url(object, object.data["content"]),
|
{:ok, page_url} <-
|
||||||
|
HTML.extract_first_external_url(object, object.data["content"]),
|
||||||
:ok <- validate_page_url(page_url),
|
:ok <- validate_page_url(page_url),
|
||||||
{:ok, rich_media} <- Parser.parse(page_url) do
|
{:ok, rich_media} <- Parser.parse(page_url) do
|
||||||
%{page_url: page_url, rich_media: rich_media}
|
%{page_url: page_url, rich_media: rich_media}
|
||||||
|
@ -62,6 +62,15 @@ defmodule Pleroma.Web.RichMedia.Helpers do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def fetch_data_for_activity(%Activity{data: %{"type" => "Create"}} = activity) do
|
||||||
|
with true <- Config.get([:rich_media, :enabled]),
|
||||||
|
%Object{} = object <- Object.normalize(activity) do
|
||||||
|
fetch_data_for_object(object)
|
||||||
|
else
|
||||||
|
_ -> %{}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def fetch_data_for_activity(_), do: %{}
|
def fetch_data_for_activity(_), do: %{}
|
||||||
|
|
||||||
def perform(:fetch, %Activity{} = activity) do
|
def perform(:fetch, %Activity{} = activity) do
|
||||||
|
|
|
@ -500,6 +500,24 @@ defmodule Pleroma.UserTest do
|
||||||
|
|
||||||
assert changeset.changes.follower_address == "#{changeset.changes.ap_id}/followers"
|
assert changeset.changes.follower_address == "#{changeset.changes.ap_id}/followers"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it sets the 'accepts_chat_messages' set to true" do
|
||||||
|
changeset = User.register_changeset(%User{}, @full_user_data)
|
||||||
|
assert changeset.valid?
|
||||||
|
|
||||||
|
{:ok, user} = Repo.insert(changeset)
|
||||||
|
|
||||||
|
assert user.accepts_chat_messages
|
||||||
|
end
|
||||||
|
|
||||||
|
test "it creates a confirmed user" do
|
||||||
|
changeset = User.register_changeset(%User{}, @full_user_data)
|
||||||
|
assert changeset.valid?
|
||||||
|
|
||||||
|
{:ok, user} = Repo.insert(changeset)
|
||||||
|
|
||||||
|
refute user.confirmation_pending
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "user registration, with :account_activation_required" do
|
describe "user registration, with :account_activation_required" do
|
||||||
|
@ -513,15 +531,6 @@ defmodule Pleroma.UserTest do
|
||||||
}
|
}
|
||||||
setup do: clear_config([:instance, :account_activation_required], true)
|
setup do: clear_config([:instance, :account_activation_required], true)
|
||||||
|
|
||||||
test "it sets the 'accepts_chat_messages' set to true" do
|
|
||||||
changeset = User.register_changeset(%User{}, @full_user_data)
|
|
||||||
assert changeset.valid?
|
|
||||||
|
|
||||||
{:ok, user} = Repo.insert(changeset)
|
|
||||||
|
|
||||||
assert user.accepts_chat_messages
|
|
||||||
end
|
|
||||||
|
|
||||||
test "it creates unconfirmed user" do
|
test "it creates unconfirmed user" do
|
||||||
changeset = User.register_changeset(%User{}, @full_user_data)
|
changeset = User.register_changeset(%User{}, @full_user_data)
|
||||||
assert changeset.valid?
|
assert changeset.valid?
|
||||||
|
|
|
@ -903,10 +903,75 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
[valid_params: valid_params]
|
[valid_params: valid_params]
|
||||||
end
|
end
|
||||||
|
|
||||||
setup do: clear_config([:instance, :account_activation_required])
|
test "Account registration via Application, no confirmation required", %{conn: conn} do
|
||||||
|
clear_config([:instance, :account_activation_required], false)
|
||||||
|
|
||||||
|
conn =
|
||||||
|
conn
|
||||||
|
|> put_req_header("content-type", "application/json")
|
||||||
|
|> post("/api/v1/apps", %{
|
||||||
|
client_name: "client_name",
|
||||||
|
redirect_uris: "urn:ietf:wg:oauth:2.0:oob",
|
||||||
|
scopes: "read, write, follow"
|
||||||
|
})
|
||||||
|
|
||||||
|
assert %{
|
||||||
|
"client_id" => client_id,
|
||||||
|
"client_secret" => client_secret,
|
||||||
|
"id" => _,
|
||||||
|
"name" => "client_name",
|
||||||
|
"redirect_uri" => "urn:ietf:wg:oauth:2.0:oob",
|
||||||
|
"vapid_key" => _,
|
||||||
|
"website" => nil
|
||||||
|
} = json_response_and_validate_schema(conn, 200)
|
||||||
|
|
||||||
|
conn =
|
||||||
|
post(conn, "/oauth/token", %{
|
||||||
|
grant_type: "client_credentials",
|
||||||
|
client_id: client_id,
|
||||||
|
client_secret: client_secret
|
||||||
|
})
|
||||||
|
|
||||||
|
assert %{"access_token" => token, "refresh_token" => refresh, "scope" => scope} =
|
||||||
|
json_response(conn, 200)
|
||||||
|
|
||||||
|
assert token
|
||||||
|
token_from_db = Repo.get_by(Token, token: token)
|
||||||
|
assert token_from_db
|
||||||
|
assert refresh
|
||||||
|
assert scope == "read write follow"
|
||||||
|
|
||||||
|
conn =
|
||||||
|
build_conn()
|
||||||
|
|> put_req_header("content-type", "multipart/form-data")
|
||||||
|
|> put_req_header("authorization", "Bearer " <> token)
|
||||||
|
|> post("/api/v1/accounts", %{
|
||||||
|
username: "lain",
|
||||||
|
email: "lain@example.org",
|
||||||
|
password: "PlzDontHackLain",
|
||||||
|
bio: "Test Bio",
|
||||||
|
agreement: true
|
||||||
|
})
|
||||||
|
|
||||||
|
%{
|
||||||
|
"access_token" => token,
|
||||||
|
"created_at" => _created_at,
|
||||||
|
"scope" => ^scope,
|
||||||
|
"token_type" => "Bearer"
|
||||||
|
} = json_response_and_validate_schema(conn, 200)
|
||||||
|
|
||||||
|
token_from_db = Repo.get_by(Token, token: token)
|
||||||
|
assert token_from_db
|
||||||
|
token_from_db = Repo.preload(token_from_db, :user)
|
||||||
|
assert token_from_db.user
|
||||||
|
refute token_from_db.user.confirmation_pending
|
||||||
|
end
|
||||||
|
|
||||||
setup do: clear_config([:instance, :account_approval_required])
|
setup do: clear_config([:instance, :account_approval_required])
|
||||||
|
|
||||||
test "Account registration via Application", %{conn: conn} do
|
test "Account registration via Application", %{conn: conn} do
|
||||||
|
clear_config([:instance, :account_activation_required], true)
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
conn
|
conn
|
||||||
|> put_req_header("content-type", "application/json")
|
|> put_req_header("content-type", "application/json")
|
||||||
|
@ -1032,7 +1097,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
token_from_db = Repo.preload(token_from_db, :user)
|
token_from_db = Repo.preload(token_from_db, :user)
|
||||||
assert token_from_db.user
|
assert token_from_db.user
|
||||||
|
|
||||||
assert token_from_db.user.confirmation_pending
|
|
||||||
assert token_from_db.user.approval_pending
|
assert token_from_db.user.approval_pending
|
||||||
|
|
||||||
assert token_from_db.user.registration_reason == "I'm a cool dude, bro"
|
assert token_from_db.user.registration_reason == "I'm a cool dude, bro"
|
||||||
|
@ -1258,8 +1322,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
||||||
assert token_from_db
|
assert token_from_db
|
||||||
token_from_db = Repo.preload(token_from_db, :user)
|
token_from_db = Repo.preload(token_from_db, :user)
|
||||||
assert token_from_db.user
|
assert token_from_db.user
|
||||||
|
|
||||||
assert token_from_db.user.confirmation_pending
|
|
||||||
end
|
end
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
|
|
|
@ -1432,6 +1432,20 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
||||||
[%{"id" => id}] = response
|
[%{"id" => id}] = response
|
||||||
assert id == other_user.id
|
assert id == other_user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "returns empty array when :show_reactions is disabled", %{conn: conn, activity: activity} do
|
||||||
|
clear_config([:instance, :show_reactions], false)
|
||||||
|
|
||||||
|
other_user = insert(:user)
|
||||||
|
{:ok, _} = CommonAPI.favorite(other_user, activity.id)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> get("/api/v1/statuses/#{activity.id}/favourited_by")
|
||||||
|
|> json_response_and_validate_schema(:ok)
|
||||||
|
|
||||||
|
assert Enum.empty?(response)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /api/v1/statuses/:id/reblogged_by" do
|
describe "GET /api/v1/statuses/:id/reblogged_by" do
|
||||||
|
|
|
@ -106,6 +106,23 @@ defmodule Pleroma.Web.PleromaAPI.EmojiReactionControllerTest do
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "GET /api/v1/pleroma/statuses/:id/reactions with :show_reactions disabled", %{conn: conn} do
|
||||||
|
clear_config([:instance, :show_reactions], false)
|
||||||
|
|
||||||
|
user = insert(:user)
|
||||||
|
other_user = insert(:user)
|
||||||
|
|
||||||
|
{:ok, activity} = CommonAPI.post(user, %{status: "#cofe"})
|
||||||
|
{:ok, _} = CommonAPI.react_with_emoji(activity.id, other_user, "🎅")
|
||||||
|
|
||||||
|
result =
|
||||||
|
conn
|
||||||
|
|> get("/api/v1/pleroma/statuses/#{activity.id}/reactions")
|
||||||
|
|> json_response_and_validate_schema(200)
|
||||||
|
|
||||||
|
assert result == []
|
||||||
|
end
|
||||||
|
|
||||||
test "GET /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do
|
test "GET /api/v1/pleroma/statuses/:id/reactions/:emoji", %{conn: conn} do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
other_user = insert(:user)
|
other_user = insert(:user)
|
||||||
|
|
|
@ -43,7 +43,17 @@ defmodule Pleroma.Web.PleromaAPI.Chat.MessageReferenceViewTest do
|
||||||
assert chat_message[:unread] == false
|
assert chat_message[:unread] == false
|
||||||
assert match?([%{shortcode: "firefox"}], chat_message[:emojis])
|
assert match?([%{shortcode: "firefox"}], chat_message[:emojis])
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.post_chat_message(recipient, user, "gkgkgk", media_id: upload.id)
|
clear_config([:rich_media, :enabled], true)
|
||||||
|
|
||||||
|
Tesla.Mock.mock(fn
|
||||||
|
%{url: "https://example.com/ogp"} ->
|
||||||
|
%Tesla.Env{status: 200, body: File.read!("test/fixtures/rich_media/ogp.html")}
|
||||||
|
end)
|
||||||
|
|
||||||
|
{:ok, activity} =
|
||||||
|
CommonAPI.post_chat_message(recipient, user, "gkgkgk https://example.com/ogp",
|
||||||
|
media_id: upload.id
|
||||||
|
)
|
||||||
|
|
||||||
object = Object.normalize(activity)
|
object = Object.normalize(activity)
|
||||||
|
|
||||||
|
@ -52,10 +62,11 @@ defmodule Pleroma.Web.PleromaAPI.Chat.MessageReferenceViewTest do
|
||||||
chat_message_two = MessageReferenceView.render("show.json", chat_message_reference: cm_ref)
|
chat_message_two = MessageReferenceView.render("show.json", chat_message_reference: cm_ref)
|
||||||
|
|
||||||
assert chat_message_two[:id] == cm_ref.id
|
assert chat_message_two[:id] == cm_ref.id
|
||||||
assert chat_message_two[:content] == "gkgkgk"
|
assert chat_message_two[:content] == object.data["content"]
|
||||||
assert chat_message_two[:account_id] == recipient.id
|
assert chat_message_two[:account_id] == recipient.id
|
||||||
assert chat_message_two[:chat_id] == chat_message[:chat_id]
|
assert chat_message_two[:chat_id] == chat_message[:chat_id]
|
||||||
assert chat_message_two[:attachment]
|
assert chat_message_two[:attachment]
|
||||||
assert chat_message_two[:unread] == true
|
assert chat_message_two[:unread] == true
|
||||||
|
assert chat_message_two[:card]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue