Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into feature/unrepeats
This commit is contained in:
commit
9e0dd21ed6
33 changed files with 242 additions and 61 deletions
3
.formatter.exs
Normal file
3
.formatter.exs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[
|
||||||
|
inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||||
|
]
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -5,6 +5,7 @@
|
||||||
/*.ez
|
/*.ez
|
||||||
/uploads
|
/uploads
|
||||||
/test/uploads
|
/test/uploads
|
||||||
|
/.elixir_ls
|
||||||
|
|
||||||
# Prevent committing custom emojis
|
# Prevent committing custom emojis
|
||||||
/priv/static/emoji/custom/*
|
/priv/static/emoji/custom/*
|
||||||
|
@ -22,3 +23,6 @@ erl_crash.dump
|
||||||
|
|
||||||
# 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
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
.env
|
|
@ -1,4 +1,4 @@
|
||||||
image: elixir:1.5
|
image: elixir:1.6.4
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- postgres:9.6.2
|
- postgres:9.6.2
|
||||||
|
@ -7,6 +7,7 @@ variables:
|
||||||
POSTGRES_DB: pleroma_test
|
POSTGRES_DB: pleroma_test
|
||||||
POSTGRES_USER: postgres
|
POSTGRES_USER: postgres
|
||||||
POSTGRES_PASSWORD: postgres
|
POSTGRES_PASSWORD: postgres
|
||||||
|
DB_HOST: postgres
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- lint
|
- lint
|
||||||
|
|
14
README.md
14
README.md
|
@ -27,27 +27,29 @@ While we don't provide docker files, other people have written very good ones. T
|
||||||
### Dependencies
|
### Dependencies
|
||||||
|
|
||||||
* Postgresql version 9.6 or newer
|
* Postgresql version 9.6 or newer
|
||||||
* Elixir version 1.5 or newer
|
* Elixir version 1.5 or newer. If your distribution only has an old version available, check [Elixir's install page](https://elixir-lang.org/install.html) or use a tool like [asdf](https://github.com/asdf-vm/asdf).
|
||||||
* Build-essential tools
|
* Build-essential tools
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
* Run `mix deps.get` to install elixir dependencies.
|
* Run `mix deps.get` to install elixir dependencies.
|
||||||
|
|
||||||
* Run `mix generate_config`. This will ask you a few questions about your instance and generate a configuration file in `config/generated_config.exs`. Check that and copy it to either `config/dev.secret.exs` or `config/prod.secret.exs`. It will also create a `config/setup_db.psql`, which you need to run as PostgreSQL superuser (i.e. `sudo su postgres -c "psql -f config/setup_db.psql"`). It will setup a pleroma db user, database and will setup needed extensions that need to be set up once as superuser.
|
* Run `mix generate_config`. This will ask you a few questions about your instance and generate a configuration file in `config/generated_config.exs`. Check that and copy it to either `config/dev.secret.exs` or `config/prod.secret.exs`. It will also create a `config/setup_db.psql`; you may want to double-check this file in case you wanted a different username, or database name than the default. Then you need to run the script as PostgreSQL superuser (i.e. `sudo su postgres -c "psql -f config/setup_db.psql"`). It will create a pleroma db user, database and will setup needed extensions that need to be set up. Postgresql super-user privileges are only needed for this step.
|
||||||
|
|
||||||
|
* For these next steps, the default will be to run pleroma using the dev configuration file, `config/dev.secret.exs`. To run them using the prod config file, prefix each command at the shell with `MIX_ENV=prod`. For example: `MIX_ENV=prod mix phx.server`.
|
||||||
|
|
||||||
* Run `mix ecto.migrate` to run the database migrations. You will have to do this again after certain updates.
|
* Run `mix ecto.migrate` to run the database migrations. You will have to do this again after certain updates.
|
||||||
|
|
||||||
* You can check if your instance is configured correctly by running it with `mix phx.server` and checking the instance info endpoint at `/api/v1/instance`. If it shows your uri, name and email correctly, you are configured correctly. If it shows something like `localhost:4000`, your configuration is probably wrong, unless you are running a local development setup.
|
* You can check if your instance is configured correctly by running it with `mix phx.server` and checking the instance info endpoint at `/api/v1/instance`. If it shows your uri, name and email correctly, you are configured correctly. If it shows something like `localhost:4000`, your configuration is probably wrong, unless you are running a local development setup.
|
||||||
|
|
||||||
* The common and convenient way for adding HTTPS is by using Nginx as a reverse proxy. You can look at example Nginx configuration in `installation/pleroma.nginx`. If you need TLS/SSL certificates for HTTPS, you can look get some for free with letsencrypt: https://letsencrypt.org/
|
* The common and convenient way for adding HTTPS is by using Nginx as a reverse proxy. You can look at example Nginx configuration in `installation/pleroma.nginx`. If you need TLS/SSL certificates for HTTPS, you can look get some for free with letsencrypt: https://letsencrypt.org/
|
||||||
On Debian you can use `certbot` package and command to manage letsencrypt certificates.
|
The simplest way to obtain and install a certificate is to use [Certbot.](https://certbot.eff.org) Depending on your specific setup, certbot may be able to get a certificate and configure your web server automatically.
|
||||||
|
|
||||||
* [Not tested with system reboot yet!] You'll also want to set up Pleroma to be run as a systemd service. Example .service file can be found in `installation/pleroma.service` you can put it in `/etc/systemd/system/`.
|
* [Not tested with system reboot yet!] You'll also want to set up Pleroma to be run as a systemd service. Example .service file can be found in `installation/pleroma.service` you can put it in `/etc/systemd/system/`.
|
||||||
|
|
||||||
## Running
|
## Running
|
||||||
|
|
||||||
By default, it listens on port 4000 (TCP), so you can access it on http://localhost:4000/ (if you are on the same machine). In case of an error it will restart automatically.
|
* By default, it listens on port 4000 (TCP), so you can access it on http://localhost:4000/ (if you are on the same machine). In case of an error it will restart automatically.
|
||||||
|
|
||||||
### Frontends
|
### Frontends
|
||||||
Pleroma comes with two frontends. The first one, Pleroma FE, can be reached by normally visiting the site. The other one, based on the Mastodon project, can be found by visiting the /web path of your site.
|
Pleroma comes with two frontends. The first one, Pleroma FE, can be reached by normally visiting the site. The other one, based on the Mastodon project, can be found by visiting the /web path of your site.
|
||||||
|
@ -70,6 +72,10 @@ This is useful for running pleroma inside Tor or i2p.
|
||||||
|
|
||||||
## Admin Tasks
|
## Admin Tasks
|
||||||
|
|
||||||
|
### Register a User
|
||||||
|
|
||||||
|
Run `mix register_user <name> <nickname> <email> <bio>`. The `name` appears on statuses, while the nickname corresponds to the user, e.g. `@nickname@instance.tld`
|
||||||
|
|
||||||
### Password reset
|
### Password reset
|
||||||
|
|
||||||
Run `mix generate_password_reset username` to generate a password reset link that you can then send to the user.
|
Run `mix generate_password_reset username` to generate a password reset link that you can then send to the user.
|
||||||
|
|
|
@ -52,7 +52,14 @@ config :pleroma, :instance,
|
||||||
limit: 5000,
|
limit: 5000,
|
||||||
upload_limit: 16_000_000,
|
upload_limit: 16_000_000,
|
||||||
registrations_open: true,
|
registrations_open: true,
|
||||||
federating: true
|
federating: true,
|
||||||
|
rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy
|
||||||
|
|
||||||
|
config :pleroma, :mrf_simple,
|
||||||
|
media_removal: [],
|
||||||
|
media_nsfw: [],
|
||||||
|
federated_timeline_removal: [],
|
||||||
|
reject: []
|
||||||
|
|
||||||
config :pleroma, :media_proxy,
|
config :pleroma, :media_proxy,
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# 1. Install your TLS certificate, possibly using Let's Encrypt.
|
# 1. Install your TLS certificate, possibly using Let's Encrypt.
|
||||||
# 2. Replace 'example.tld' with your instance's domain wherever it appears.
|
# 2. Replace 'example.tld' with your instance's domain wherever it appears.
|
||||||
# 3. Copy this file to /etc/nginx/sites-available/ and then add a symlink to it
|
# 3. Copy this file to /etc/nginx/sites-available/ and then add a symlink to it
|
||||||
# in /etc/nginx/sites-enabled/ and restart nginx.
|
# in /etc/nginx/sites-enabled/ and run 'nginx -s reload' or restart nginx.
|
||||||
|
|
||||||
proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=10g
|
proxy_cache_path /tmp/pleroma-media-cache levels=1:2 keys_zone=pleroma_media_cache:10m max_size=10g
|
||||||
inactive=720m use_temp_path=off;
|
inactive=720m use_temp_path=off;
|
||||||
|
@ -13,6 +13,15 @@ server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name example.tld;
|
server_name example.tld;
|
||||||
return 301 https://$server_name$request_uri;
|
return 301 https://$server_name$request_uri;
|
||||||
|
|
||||||
|
# Uncomment this if you need to use the 'webroot' method with certbot. Make sure
|
||||||
|
# that you also create the .well-known/acme-challenge directory structure in pleroma/priv/static and
|
||||||
|
# that is is accessible by the webserver. You may need to load this file with the ssl
|
||||||
|
# server block commented out, run certbot to get the certificate, and then uncomment it.
|
||||||
|
#
|
||||||
|
# location ~ /\.well-known/acme-challenge {
|
||||||
|
# root <path to install>/pleroma/priv/static/;
|
||||||
|
# }
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
|
|
|
@ -144,7 +144,7 @@ defmodule Pleroma.Formatter do
|
||||||
@emoji
|
@emoji
|
||||||
end
|
end
|
||||||
|
|
||||||
@link_regex ~r/https?:\/\/[\w\.\/?=\-#\+%&@~\(\):]+[\w\/]/u
|
@link_regex ~r/https?:\/\/[\w\.\/?=\-#\+%&@~'\(\):]+[\w\/]/u
|
||||||
|
|
||||||
def html_escape(text) do
|
def html_escape(text) do
|
||||||
Regex.split(@link_regex, text, include_captures: true)
|
Regex.split(@link_regex, text, include_captures: true)
|
||||||
|
@ -168,7 +168,13 @@ defmodule Pleroma.Formatter do
|
||||||
subs =
|
subs =
|
||||||
subs ++
|
subs ++
|
||||||
Enum.map(links, fn {uuid, url} ->
|
Enum.map(links, fn {uuid, url} ->
|
||||||
{uuid, "<a href='#{url}'>#{url}</a>"}
|
{:safe, link} = Phoenix.HTML.Link.link(url, to: url)
|
||||||
|
|
||||||
|
link =
|
||||||
|
link
|
||||||
|
|> IO.iodata_to_binary()
|
||||||
|
|
||||||
|
{uuid, link}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
{subs, uuid_text}
|
{subs, uuid_text}
|
||||||
|
|
|
@ -322,6 +322,16 @@ defmodule Pleroma.User do
|
||||||
update_and_set_cache(cs)
|
update_and_set_cache(cs)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def decrease_note_count(%User{} = user) do
|
||||||
|
note_count = user.info["note_count"] || 0
|
||||||
|
note_count = if note_count <= 0, do: 0, else: note_count - 1
|
||||||
|
new_info = Map.put(user.info, "note_count", note_count)
|
||||||
|
|
||||||
|
cs = info_changeset(user, %{info: new_info})
|
||||||
|
|
||||||
|
update_and_set_cache(cs)
|
||||||
|
end
|
||||||
|
|
||||||
def update_note_count(%User{} = user) do
|
def update_note_count(%User{} = user) do
|
||||||
note_count_query =
|
note_count_query =
|
||||||
from(
|
from(
|
||||||
|
|
|
@ -10,6 +10,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
|
|
||||||
@httpoison Application.get_env(:pleroma, :httpoison)
|
@httpoison Application.get_env(:pleroma, :httpoison)
|
||||||
|
|
||||||
|
@instance Application.get_env(:pleroma, :instance)
|
||||||
|
@rewrite_policy Keyword.get(@instance, :rewrite_policy)
|
||||||
|
|
||||||
def get_recipients(data) do
|
def get_recipients(data) do
|
||||||
(data["to"] || []) ++ (data["cc"] || [])
|
(data["to"] || []) ++ (data["cc"] || [])
|
||||||
end
|
end
|
||||||
|
@ -17,7 +20,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
def insert(map, local \\ true) when is_map(map) do
|
def insert(map, local \\ true) when is_map(map) do
|
||||||
with nil <- Activity.get_by_ap_id(map["id"]),
|
with nil <- Activity.get_by_ap_id(map["id"]),
|
||||||
map <- lazy_put_activity_defaults(map),
|
map <- lazy_put_activity_defaults(map),
|
||||||
:ok <- insert_full_object(map) do
|
:ok <- insert_full_object(map),
|
||||||
|
{:ok, map} <- @rewrite_policy.filter(map) do
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
Repo.insert(%Activity{
|
Repo.insert(%Activity{
|
||||||
data: map,
|
data: map,
|
||||||
|
@ -61,7 +65,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
additional
|
additional
|
||||||
),
|
),
|
||||||
{:ok, activity} <- insert(create_data, local),
|
{:ok, activity} <- insert(create_data, local),
|
||||||
:ok <- maybe_federate(activity) do
|
:ok <- maybe_federate(activity),
|
||||||
|
{:ok, actor} <- User.increase_note_count(actor) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -184,7 +189,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
with Repo.delete(object),
|
with Repo.delete(object),
|
||||||
Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id)),
|
Repo.delete_all(Activity.all_non_create_by_object_ap_id_q(id)),
|
||||||
{:ok, activity} <- insert(data, local),
|
{:ok, activity} <- insert(data, local),
|
||||||
:ok <- maybe_federate(activity) do
|
:ok <- maybe_federate(activity),
|
||||||
|
{:ok, actor} <- User.decrease_note_count(user) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
8
lib/pleroma/web/activity_pub/mrf/drop_policy.ex
Normal file
8
lib/pleroma/web/activity_pub/mrf/drop_policy.ex
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
defmodule Pleroma.Web.ActivityPub.MRF.DropPolicy do
|
||||||
|
require Logger
|
||||||
|
|
||||||
|
def filter(object) do
|
||||||
|
Logger.info("REJECTING #{inspect(object)}")
|
||||||
|
{:reject, object}
|
||||||
|
end
|
||||||
|
end
|
5
lib/pleroma/web/activity_pub/mrf/noop_policy.ex
Normal file
5
lib/pleroma/web/activity_pub/mrf/noop_policy.ex
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
defmodule Pleroma.Web.ActivityPub.MRF.NoOpPolicy do
|
||||||
|
def filter(object) do
|
||||||
|
{:ok, object}
|
||||||
|
end
|
||||||
|
end
|
75
lib/pleroma/web/activity_pub/mrf/simple_policy.ex
Normal file
75
lib/pleroma/web/activity_pub/mrf/simple_policy.ex
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicy do
|
||||||
|
alias Pleroma.User
|
||||||
|
|
||||||
|
@mrf_policy Application.get_env(:pleroma, :mrf_simple)
|
||||||
|
|
||||||
|
@reject Keyword.get(@mrf_policy, :reject)
|
||||||
|
defp check_reject(actor_info, object) do
|
||||||
|
if actor_info.host in @reject do
|
||||||
|
{:reject, nil}
|
||||||
|
else
|
||||||
|
{:ok, object}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
@media_removal Keyword.get(@mrf_policy, :media_removal)
|
||||||
|
defp check_media_removal(actor_info, object) do
|
||||||
|
if actor_info.host in @media_removal do
|
||||||
|
object = Map.delete(object, "attachments")
|
||||||
|
end
|
||||||
|
|
||||||
|
{:ok, object}
|
||||||
|
end
|
||||||
|
|
||||||
|
@media_nsfw Keyword.get(@mrf_policy, :media_nsfw)
|
||||||
|
defp check_media_nsfw(actor_info, object) do
|
||||||
|
child_object = object["object"]
|
||||||
|
|
||||||
|
if actor_info.host in @media_nsfw and child_object["attachment"] != nil and
|
||||||
|
length(child_object["attachment"]) > 0 do
|
||||||
|
tags = (child_object["tag"] || []) ++ ["nsfw"]
|
||||||
|
child_object = Map.put(child_object, "tags", tags)
|
||||||
|
child_object = Map.put(child_object, "sensitive", true)
|
||||||
|
object = Map.put(object, "object", child_object)
|
||||||
|
end
|
||||||
|
|
||||||
|
{:ok, object}
|
||||||
|
end
|
||||||
|
|
||||||
|
@ftl_removal Keyword.get(@mrf_policy, :federated_timeline_removal)
|
||||||
|
defp check_ftl_removal(actor_info, object) do
|
||||||
|
if actor_info.host in @ftl_removal do
|
||||||
|
user = User.get_by_ap_id(object["actor"])
|
||||||
|
|
||||||
|
# flip to/cc relationship to make the post unlisted
|
||||||
|
if "https://www.w3.org/ns/activitystreams#Public" in object["to"] and
|
||||||
|
user.follower_address in object["cc"] do
|
||||||
|
to =
|
||||||
|
List.delete(object["to"], "https://www.w3.org/ns/activitystreams#Public") ++
|
||||||
|
[user.follower_address]
|
||||||
|
|
||||||
|
cc =
|
||||||
|
List.delete(object["cc"], user.follower_address) ++
|
||||||
|
["https://www.w3.org/ns/activitystreams#Public"]
|
||||||
|
|
||||||
|
object = Map.put(object, "to", to)
|
||||||
|
object = Map.put(object, "cc", cc)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
{:ok, object}
|
||||||
|
end
|
||||||
|
|
||||||
|
def filter(object) do
|
||||||
|
actor_info = URI.parse(object["actor"])
|
||||||
|
|
||||||
|
with {:ok, object} <- check_reject(actor_info, object),
|
||||||
|
{:ok, object} <- check_media_removal(actor_info, object),
|
||||||
|
{:ok, object} <- check_media_nsfw(actor_info, object),
|
||||||
|
{:ok, object} <- check_ftl_removal(actor_info, object) do
|
||||||
|
{:ok, object}
|
||||||
|
else
|
||||||
|
e -> {:reject, nil}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -146,7 +146,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
%{"type" => "Like", "object" => object_id, "actor" => actor, "id" => id} = data
|
%{"type" => "Like", "object" => object_id, "actor" => actor, "id" => id} = data
|
||||||
) do
|
) do
|
||||||
with %User{} = actor <- User.get_or_fetch_by_ap_id(actor),
|
with %User{} = actor <- User.get_or_fetch_by_ap_id(actor),
|
||||||
{:ok, object} <- get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id),
|
{:ok, object} <-
|
||||||
|
get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id),
|
||||||
{:ok, activity, object} <- ActivityPub.like(actor, object, id, false) do
|
{:ok, activity, object} <- ActivityPub.like(actor, object, id, false) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
|
@ -158,7 +159,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
%{"type" => "Announce", "object" => object_id, "actor" => actor, "id" => id} = data
|
%{"type" => "Announce", "object" => object_id, "actor" => actor, "id" => id} = data
|
||||||
) do
|
) do
|
||||||
with %User{} = actor <- User.get_or_fetch_by_ap_id(actor),
|
with %User{} = actor <- User.get_or_fetch_by_ap_id(actor),
|
||||||
{:ok, object} <- get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id),
|
{:ok, object} <-
|
||||||
|
get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id),
|
||||||
{:ok, activity, object} <- ActivityPub.announce(actor, object, id, false) do
|
{:ok, activity, object} <- ActivityPub.announce(actor, object, id, false) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
|
@ -209,7 +211,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
end
|
end
|
||||||
|
|
||||||
with %User{} = actor <- User.get_or_fetch_by_ap_id(actor),
|
with %User{} = actor <- User.get_or_fetch_by_ap_id(actor),
|
||||||
{:ok, object} <- get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id),
|
{:ok, object} <-
|
||||||
|
get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id),
|
||||||
{:ok, activity} <- ActivityPub.delete(object, false) do
|
{:ok, activity} <- ActivityPub.delete(object, false) do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
|
|
|
@ -175,7 +175,8 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
||||||
|
|
||||||
def update_element_in_object(property, element, object) do
|
def update_element_in_object(property, element, object) do
|
||||||
with new_data <-
|
with new_data <-
|
||||||
object.data |> Map.put("#{property}_count", length(element))
|
object.data
|
||||||
|
|> Map.put("#{property}_count", length(element))
|
||||||
|> Map.put("#{property}s", element),
|
|> Map.put("#{property}s", element),
|
||||||
changeset <- Changeset.change(object, data: new_data),
|
changeset <- Changeset.change(object, data: new_data),
|
||||||
{:ok, object} <- Repo.update(changeset),
|
{:ok, object} <- Repo.update(changeset),
|
||||||
|
|
|
@ -113,7 +113,6 @@ defmodule Pleroma.Web.CommonAPI do
|
||||||
additional: %{"cc" => cc}
|
additional: %{"cc" => cc}
|
||||||
})
|
})
|
||||||
|
|
||||||
User.increase_note_count(user)
|
|
||||||
res
|
res
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,7 @@ defmodule Pleroma.Web.Endpoint do
|
||||||
Plug.Static,
|
Plug.Static,
|
||||||
at: "/",
|
at: "/",
|
||||||
from: :pleroma,
|
from: :pleroma,
|
||||||
only: ~w(index.html static finmoji emoji packs sounds images instance sw.js)
|
only: ~w(index.html static finmoji emoji packs sounds images instance sw.js favicon.png)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Code reloading can be explicitly enabled under the
|
# Code reloading can be explicitly enabled under the
|
||||||
|
|
|
@ -528,7 +528,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|
||||||
^query
|
^query
|
||||||
),
|
),
|
||||||
limit: 20,
|
limit: 20,
|
||||||
order_by: [desc: :inserted_at]
|
order_by: [desc: :id]
|
||||||
)
|
)
|
||||||
|
|
||||||
statuses = Repo.all(q) ++ fetched
|
statuses = Repo.all(q) ++ fetched
|
||||||
|
|
|
@ -63,7 +63,8 @@ defmodule Pleroma.Web.OAuth.OAuthController do
|
||||||
client_secret: params["client_secret"]
|
client_secret: params["client_secret"]
|
||||||
),
|
),
|
||||||
fixed_token = fix_padding(params["code"]),
|
fixed_token = fix_padding(params["code"]),
|
||||||
%Authorization{} = auth <- Repo.get_by(Authorization, token: fixed_token, app_id: app.id),
|
%Authorization{} = auth <-
|
||||||
|
Repo.get_by(Authorization, token: fixed_token, app_id: app.id),
|
||||||
{:ok, token} <- Token.exchange_token(app, auth) do
|
{:ok, token} <- Token.exchange_token(app, auth) do
|
||||||
response = %{
|
response = %{
|
||||||
token_type: "Bearer",
|
token_type: "Bearer",
|
||||||
|
|
|
@ -131,7 +131,8 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do
|
||||||
h.(activity.data["object"]["content"] |> String.replace(~r/[\n\r]/, ""))},
|
h.(activity.data["object"]["content"] |> String.replace(~r/[\n\r]/, ""))},
|
||||||
{:published, h.(inserted_at)},
|
{:published, h.(inserted_at)},
|
||||||
{:updated, h.(updated_at)},
|
{:updated, h.(updated_at)},
|
||||||
{:"ostatus:conversation", [ref: h.(activity.data["context"])], h.(activity.data["context"])},
|
{:"ostatus:conversation", [ref: h.(activity.data["context"])],
|
||||||
|
h.(activity.data["context"])},
|
||||||
{:link, [ref: h.(activity.data["context"]), rel: 'ostatus:conversation'], []}
|
{:link, [ref: h.(activity.data["context"]), rel: 'ostatus:conversation'], []}
|
||||||
] ++
|
] ++
|
||||||
summary ++
|
summary ++
|
||||||
|
@ -162,7 +163,8 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do
|
||||||
# For notes, federate the object id.
|
# For notes, federate the object id.
|
||||||
{:id, h.(activity.data["object"])}
|
{:id, h.(activity.data["object"])}
|
||||||
]},
|
]},
|
||||||
{:"ostatus:conversation", [ref: h.(activity.data["context"])], h.(activity.data["context"])},
|
{:"ostatus:conversation", [ref: h.(activity.data["context"])],
|
||||||
|
h.(activity.data["context"])},
|
||||||
{:link, [ref: h.(activity.data["context"]), rel: 'ostatus:conversation'], []},
|
{:link, [ref: h.(activity.data["context"]), rel: 'ostatus:conversation'], []},
|
||||||
{:link, [rel: 'self', type: ['application/atom+xml'], href: h.(activity.data["id"])], []},
|
{:link, [rel: 'self', type: ['application/atom+xml'], href: h.(activity.data["id"])], []},
|
||||||
{:"thr:in-reply-to", [ref: to_charlist(activity.data["object"])], []}
|
{:"thr:in-reply-to", [ref: to_charlist(activity.data["object"])], []}
|
||||||
|
@ -193,7 +195,8 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenter do
|
||||||
{:content, [type: 'html'], ['RT #{retweeted_activity.data["object"]["content"]}']},
|
{:content, [type: 'html'], ['RT #{retweeted_activity.data["object"]["content"]}']},
|
||||||
{:published, h.(inserted_at)},
|
{:published, h.(inserted_at)},
|
||||||
{:updated, h.(updated_at)},
|
{:updated, h.(updated_at)},
|
||||||
{:"ostatus:conversation", [ref: h.(activity.data["context"])], h.(activity.data["context"])},
|
{:"ostatus:conversation", [ref: h.(activity.data["context"])],
|
||||||
|
h.(activity.data["context"])},
|
||||||
{:link, [ref: h.(activity.data["context"]), rel: 'ostatus:conversation'], []},
|
{:link, [ref: h.(activity.data["context"]), rel: 'ostatus:conversation'], []},
|
||||||
{:link, [rel: 'self', type: ['application/atom+xml'], href: h.(activity.data["id"])], []},
|
{:link, [rel: 'self', type: ['application/atom+xml'], href: h.(activity.data["id"])], []},
|
||||||
{:"activity:object", retweeted_xml}
|
{:"activity:object", retweeted_xml}
|
||||||
|
|
|
@ -138,7 +138,6 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
|
||||||
do: note |> Map.put("inReplyTo", inReplyTo),
|
do: note |> Map.put("inReplyTo", inReplyTo),
|
||||||
else: note
|
else: note
|
||||||
) do
|
) do
|
||||||
res =
|
|
||||||
ActivityPub.create(%{
|
ActivityPub.create(%{
|
||||||
to: to,
|
to: to,
|
||||||
actor: actor,
|
actor: actor,
|
||||||
|
@ -148,9 +147,6 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
|
||||||
local: false,
|
local: false,
|
||||||
additional: %{"cc" => cc}
|
additional: %{"cc" => cc}
|
||||||
})
|
})
|
||||||
|
|
||||||
User.increase_note_count(actor)
|
|
||||||
res
|
|
||||||
else
|
else
|
||||||
%Activity{} = activity -> {:ok, activity}
|
%Activity{} = activity -> {:ok, activity}
|
||||||
e -> {:error, e}
|
e -> {:error, e}
|
||||||
|
|
|
@ -81,7 +81,10 @@ defmodule Pleroma.Web.WebFinger do
|
||||||
"href" => user.ap_id
|
"href" => user.ap_id
|
||||||
},
|
},
|
||||||
%{"rel" => "salmon", "href" => OStatus.salmon_path(user)},
|
%{"rel" => "salmon", "href" => OStatus.salmon_path(user)},
|
||||||
%{"rel" => "magic-public-key", "href" => "data:application/magic-public-key,#{magic_key}"},
|
%{
|
||||||
|
"rel" => "magic-public-key",
|
||||||
|
"href" => "data:application/magic-public-key,#{magic_key}"
|
||||||
|
},
|
||||||
%{"rel" => "self", "type" => "application/activity+json", "href" => user.ap_id},
|
%{"rel" => "self", "type" => "application/activity+json", "href" => user.ap_id},
|
||||||
%{
|
%{
|
||||||
"rel" => "http://ostatus.org/schema/1.0/subscribe",
|
"rel" => "http://ostatus.org/schema/1.0/subscribe",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>Pleroma</title><link rel=stylesheet href=/static/font/css/fontello.css><link rel=stylesheet href=/static/font/css/animation.css><link href=/static/css/app.6c8da1b0ace79ad8881a0e5e716ec818.css rel=stylesheet></head><body style="display: none"><div id=app></div><script type=text/javascript src=/static/js/manifest.f80ee14f782f05d77e39.js></script><script type=text/javascript src=/static/js/vendor.ef2aee0b2db579c3a86a.js></script><script type=text/javascript src=/static/js/app.64c4246ae54f6439cb69.js></script></body></html>
|
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>Pleroma</title><link rel=stylesheet href=/static/font/css/fontello.css><link rel=stylesheet href=/static/font/css/animation.css><link href=/static/css/app.6c8da1b0ace79ad8881a0e5e716ec818.css rel=stylesheet></head><body style="display: none"><div id=app></div><script type=text/javascript src=/static/js/manifest.cdeff2a56af285544b89.js></script><script type=text/javascript src=/static/js/vendor.ef2aee0b2db579c3a86a.js></script><script type=text/javascript src=/static/js/app.408cea515c3032097a51.js></script></body></html>
|
|
@ -1,4 +1,5 @@
|
||||||
<div style="margin-left:12px; margin-right:12px">
|
<div style="margin-left:12px; margin-right:12px">
|
||||||
<p>This is a <a href="https://pleroma.social" target="_blank">Pleroma</a> instance.</p>
|
<p>Welcome to <a href="https://pleroma.social" target="_blank">Pleroma!</a></p>
|
||||||
|
<p><a href="/main/all">Pleroma FE</a> | <a href="/web">Mastodon FE</a></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
7
priv/static/static/js/app.408cea515c3032097a51.js
Normal file
7
priv/static/static/js/app.408cea515c3032097a51.js
Normal file
File diff suppressed because one or more lines are too long
1
priv/static/static/js/app.408cea515c3032097a51.js.map
Normal file
1
priv/static/static/js/app.408cea515c3032097a51.js.map
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,2 +1,2 @@
|
||||||
!function(e){function t(a){if(r[a])return r[a].exports;var n=r[a]={exports:{},id:a,loaded:!1};return e[a].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var a=window.webpackJsonp;window.webpackJsonp=function(c,o){for(var p,l,s=0,i=[];s<c.length;s++)l=c[s],n[l]&&i.push.apply(i,n[l]),n[l]=0;for(p in o)Object.prototype.hasOwnProperty.call(o,p)&&(e[p]=o[p]);for(a&&a(c,o);i.length;)i.shift().call(null,t);if(o[0])return r[0]=0,t(0)};var r={},n={0:0};t.e=function(e,a){if(0===n[e])return a.call(null,t);if(void 0!==n[e])n[e].push(a);else{n[e]=[a];var r=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.src=t.p+"static/js/"+e+"."+{1:"ef2aee0b2db579c3a86a",2:"64c4246ae54f6439cb69"}[e]+".js",r.appendChild(c)}},t.m=e,t.c=r,t.p="/"}([]);
|
!function(e){function t(a){if(r[a])return r[a].exports;var n=r[a]={exports:{},id:a,loaded:!1};return e[a].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var a=window.webpackJsonp;window.webpackJsonp=function(c,o){for(var p,l,s=0,i=[];s<c.length;s++)l=c[s],n[l]&&i.push.apply(i,n[l]),n[l]=0;for(p in o)Object.prototype.hasOwnProperty.call(o,p)&&(e[p]=o[p]);for(a&&a(c,o);i.length;)i.shift().call(null,t);if(o[0])return r[0]=0,t(0)};var r={},n={0:0};t.e=function(e,a){if(0===n[e])return a.call(null,t);if(void 0!==n[e])n[e].push(a);else{n[e]=[a];var r=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.src=t.p+"static/js/"+e+"."+{1:"ef2aee0b2db579c3a86a",2:"408cea515c3032097a51"}[e]+".js",r.appendChild(c)}},t.m=e,t.c=r,t.p="/"}([]);
|
||||||
//# sourceMappingURL=manifest.f80ee14f782f05d77e39.js.map
|
//# sourceMappingURL=manifest.cdeff2a56af285544b89.js.map
|
File diff suppressed because one or more lines are too long
|
@ -23,21 +23,21 @@ defmodule Pleroma.FormatterTest do
|
||||||
text = "Hey, check out https://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla."
|
text = "Hey, check out https://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla."
|
||||||
|
|
||||||
expected =
|
expected =
|
||||||
"Hey, check out <a href='https://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla'>https://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla</a>."
|
"Hey, check out <a href=\"https://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla\">https://www.youtube.com/watch?v=8Zg1-TufF%20zY?x=1&y=2#blabla</a>."
|
||||||
|
|
||||||
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
||||||
|
|
||||||
text = "https://mastodon.social/@lambadalambda"
|
text = "https://mastodon.social/@lambadalambda"
|
||||||
|
|
||||||
expected =
|
expected =
|
||||||
"<a href='https://mastodon.social/@lambadalambda'>https://mastodon.social/@lambadalambda</a>"
|
"<a href=\"https://mastodon.social/@lambadalambda\">https://mastodon.social/@lambadalambda</a>"
|
||||||
|
|
||||||
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
||||||
|
|
||||||
text = "https://mastodon.social:4000/@lambadalambda"
|
text = "https://mastodon.social:4000/@lambadalambda"
|
||||||
|
|
||||||
expected =
|
expected =
|
||||||
"<a href='https://mastodon.social:4000/@lambadalambda'>https://mastodon.social:4000/@lambadalambda</a>"
|
"<a href=\"https://mastodon.social:4000/@lambadalambda\">https://mastodon.social:4000/@lambadalambda</a>"
|
||||||
|
|
||||||
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
||||||
|
|
||||||
|
@ -47,28 +47,35 @@ defmodule Pleroma.FormatterTest do
|
||||||
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
||||||
|
|
||||||
text = "http://www.cs.vu.nl/~ast/intel/"
|
text = "http://www.cs.vu.nl/~ast/intel/"
|
||||||
expected = "<a href='http://www.cs.vu.nl/~ast/intel/'>http://www.cs.vu.nl/~ast/intel/</a>"
|
expected = "<a href=\"http://www.cs.vu.nl/~ast/intel/\">http://www.cs.vu.nl/~ast/intel/</a>"
|
||||||
|
|
||||||
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
||||||
|
|
||||||
text = "https://forum.zdoom.org/viewtopic.php?f=44&t=57087"
|
text = "https://forum.zdoom.org/viewtopic.php?f=44&t=57087"
|
||||||
|
|
||||||
expected =
|
expected =
|
||||||
"<a href='https://forum.zdoom.org/viewtopic.php?f=44&t=57087'>https://forum.zdoom.org/viewtopic.php?f=44&t=57087</a>"
|
"<a href=\"https://forum.zdoom.org/viewtopic.php?f=44&t=57087\">https://forum.zdoom.org/viewtopic.php?f=44&t=57087</a>"
|
||||||
|
|
||||||
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
||||||
|
|
||||||
text = "https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul"
|
text = "https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul"
|
||||||
|
|
||||||
expected =
|
expected =
|
||||||
"<a href='https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul'>https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul</a>"
|
"<a href=\"https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul\">https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul</a>"
|
||||||
|
|
||||||
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
||||||
|
|
||||||
text = "https://www.google.co.jp/search?q=Nasim+Aghdam"
|
text = "https://www.google.co.jp/search?q=Nasim+Aghdam"
|
||||||
|
|
||||||
expected =
|
expected =
|
||||||
"<a href='https://www.google.co.jp/search?q=Nasim+Aghdam'>https://www.google.co.jp/search?q=Nasim+Aghdam</a>"
|
"<a href=\"https://www.google.co.jp/search?q=Nasim+Aghdam\">https://www.google.co.jp/search?q=Nasim+Aghdam</a>"
|
||||||
|
|
||||||
|
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
||||||
|
|
||||||
|
text = "https://en.wikipedia.org/wiki/Duff's_device"
|
||||||
|
|
||||||
|
expected =
|
||||||
|
"<a href=\"https://en.wikipedia.org/wiki/Duff's_device\">https://en.wikipedia.org/wiki/Duff's_device</a>"
|
||||||
|
|
||||||
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
assert Formatter.add_links({[], text}) |> Formatter.finalize() == expected
|
||||||
end
|
end
|
||||||
|
|
|
@ -296,6 +296,25 @@ defmodule Pleroma.UserTest do
|
||||||
assert user.info["note_count"] == 2
|
assert user.info["note_count"] == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it decreases the info->note_count property" do
|
||||||
|
note = insert(:note)
|
||||||
|
user = User.get_by_ap_id(note.data["actor"])
|
||||||
|
|
||||||
|
assert user.info["note_count"] == nil
|
||||||
|
|
||||||
|
{:ok, user} = User.increase_note_count(user)
|
||||||
|
|
||||||
|
assert user.info["note_count"] == 1
|
||||||
|
|
||||||
|
{:ok, user} = User.decrease_note_count(user)
|
||||||
|
|
||||||
|
assert user.info["note_count"] == 0
|
||||||
|
|
||||||
|
{:ok, user} = User.decrease_note_count(user)
|
||||||
|
|
||||||
|
assert user.info["note_count"] == 0
|
||||||
|
end
|
||||||
|
|
||||||
test "it sets the info->follower_count property" do
|
test "it sets the info->follower_count property" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
|
|
|
@ -83,16 +83,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
||||||
|
|
||||||
describe "create activities" do
|
describe "create activities" do
|
||||||
test "removes doubled 'to' recipients" do
|
test "removes doubled 'to' recipients" do
|
||||||
|
user = insert(:user)
|
||||||
|
|
||||||
{:ok, activity} =
|
{:ok, activity} =
|
||||||
ActivityPub.create(%{
|
ActivityPub.create(%{
|
||||||
to: ["user1", "user1", "user2"],
|
to: ["user1", "user1", "user2"],
|
||||||
actor: %User{ap_id: "1"},
|
actor: user,
|
||||||
context: "",
|
context: "",
|
||||||
object: %{}
|
object: %{}
|
||||||
})
|
})
|
||||||
|
|
||||||
assert activity.data["to"] == ["user1", "user2"]
|
assert activity.data["to"] == ["user1", "user2"]
|
||||||
assert activity.actor == "1"
|
assert activity.actor == user.ap_id
|
||||||
assert activity.recipients == ["user1", "user2"]
|
assert activity.recipients == ["user1", "user2"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -89,6 +89,10 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
"tag:mastodon.example.org,2018-02-12:objectId=20:objectType=Conversation"
|
"tag:mastodon.example.org,2018-02-12:objectId=20:objectType=Conversation"
|
||||||
|
|
||||||
assert object["sensitive"] == true
|
assert object["sensitive"] == true
|
||||||
|
|
||||||
|
user = User.get_by_ap_id(object["actor"])
|
||||||
|
|
||||||
|
assert user.info["note_count"] == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it works for incoming notices with hashtags" do
|
test "it works for incoming notices with hashtags" do
|
||||||
|
@ -102,7 +106,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
data =
|
data =
|
||||||
File.read!("test/fixtures/mastodon-follow-activity.json") |> Poison.decode!()
|
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||||
|
|> Poison.decode!()
|
||||||
|> Map.put("object", user.ap_id)
|
|> Map.put("object", user.ap_id)
|
||||||
|
|
||||||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||||
|
@ -118,7 +123,8 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
||||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
{:ok, activity} = CommonAPI.post(user, %{"status" => "hello"})
|
||||||
|
|
||||||
data =
|
data =
|
||||||
File.read!("test/fixtures/mastodon-like.json") |> Poison.decode!()
|
File.read!("test/fixtures/mastodon-like.json")
|
||||||
|
|> Poison.decode!()
|
||||||
|> Map.put("object", activity.data["object"]["id"])
|
|> Map.put("object", activity.data["object"]["id"])
|
||||||
|
|
||||||
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||||
|
|
Loading…
Reference in a new issue