Compare commits
No commits in common. "938e9e0b37e33eb87010d6cc28fb5aca022662be" and "00c8a658790843d961903b5f4e17c0a7e9367a8c" have entirely different histories.
938e9e0b37
...
00c8a65879
9 changed files with 11 additions and 65 deletions
|
@ -1,22 +1,18 @@
|
||||||
## This file is for testing only, as I don't recommend using Docker Compose
|
# This file is for testing only, as I don't recommend using Docker Compose in a production environment
|
||||||
## in a production environment
|
|
||||||
version: "3.7"
|
version: "3.7"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:14-alpine
|
image: postgres:14-alpine
|
||||||
## Use the following image instead if you want to use PGroonga
|
# image: groonga/pgroonga:3.1.1-alpine-14 # Use this one if you want to use PGroonga
|
||||||
# image: groonga/pgroonga:3.1.1-alpine-14
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_DB: akkoma
|
POSTGRES_DB: akkoma
|
||||||
POSTGRES_USER: akkoma
|
POSTGRES_USER: akkoma
|
||||||
POSTGRES_PASSWORD: akkoma
|
POSTGRES_PASSWORD: akkoma
|
||||||
|
# Comment out the volume below if you encounter any permission errors
|
||||||
volumes:
|
volumes:
|
||||||
- ./docker-db/:/var/lib/postgresql/data/:Z
|
- ./docker-db/:/var/lib/postgresql/data/:Z
|
||||||
## Use the following volume instead if you are running Docker in
|
|
||||||
## emulated environments and getting permission errors
|
|
||||||
# - docker-db:/var/lib/postgresql/data/:Z
|
|
||||||
|
|
||||||
akkoma:
|
akkoma:
|
||||||
image: akkoma:latest
|
image: akkoma:latest
|
||||||
|
@ -34,22 +30,3 @@ services:
|
||||||
- ./static/:/var/lib/akkoma/static/:Z
|
- ./static/:/var/lib/akkoma/static/:Z
|
||||||
- ./uploads/:/var/lib/akkoma/uploads/:Z
|
- ./uploads/:/var/lib/akkoma/uploads/:Z
|
||||||
- ./etc/:/etc/akkoma/:Z
|
- ./etc/:/etc/akkoma/:Z
|
||||||
|
|
||||||
## Comment out the following container if you want to use Meilisearch
|
|
||||||
# meili:
|
|
||||||
# image: getmeili/meilisearch:v1.3
|
|
||||||
# restart: unless-stopped
|
|
||||||
# environment:
|
|
||||||
# MEILI_NO_ANALYTICS: true
|
|
||||||
|
|
||||||
## Comment out the following container if you want to use Elasticsearch
|
|
||||||
# elastic:
|
|
||||||
# image: elasticsearch:7.17.13
|
|
||||||
# environment:
|
|
||||||
# discovery.type: single-node
|
|
||||||
# xpack.security.enabled: false
|
|
||||||
|
|
||||||
## Enable the following volume if you are running Docker in emulated
|
|
||||||
## environments and getting permission errors
|
|
||||||
# volumes:
|
|
||||||
# docker-db:
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ config :pleroma, :mrf_user_allowlist, %{
|
||||||
#### :mrf_hashtag
|
#### :mrf_hashtag
|
||||||
|
|
||||||
* `sensitive`: List of hashtags to mark activities as sensitive (default: `nsfw`)
|
* `sensitive`: List of hashtags to mark activities as sensitive (default: `nsfw`)
|
||||||
* `federated_timeline_removal`: List of hashtags to remove activities from the federated timeline (aka TWKN)
|
* `federated_timeline_removal`: List of hashtags to remove activities from the federated timeline (aka TWNK)
|
||||||
* `reject`: List of hashtags to reject activities from
|
* `reject`: List of hashtags to reject activities from
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
|
@ -26,7 +26,6 @@ def search(user, search_query, options \\ []) do
|
||||||
limit = Enum.min([Keyword.get(options, :limit), 40])
|
limit = Enum.min([Keyword.get(options, :limit), 40])
|
||||||
offset = Keyword.get(options, :offset, 0)
|
offset = Keyword.get(options, :offset, 0)
|
||||||
author = Keyword.get(options, :author)
|
author = Keyword.get(options, :author)
|
||||||
only_media = Keyword.get(options, :only_media, false)
|
|
||||||
|
|
||||||
search_function =
|
search_function =
|
||||||
if :persistent_term.get({Pleroma.Repo, :postgres_version}) >= 11 do
|
if :persistent_term.get({Pleroma.Repo, :postgres_version}) >= 11 do
|
||||||
|
@ -44,7 +43,6 @@ def search(user, search_query, options \\ []) do
|
||||||
|> maybe_restrict_local(user)
|
|> maybe_restrict_local(user)
|
||||||
|> maybe_restrict_author(author)
|
|> maybe_restrict_author(author)
|
||||||
|> maybe_restrict_blocked(user)
|
|> maybe_restrict_blocked(user)
|
||||||
|> maybe_only_media(only_media)
|
|
||||||
|> Pagination.fetch_paginated(
|
|> Pagination.fetch_paginated(
|
||||||
%{"offset" => offset, "limit" => limit, "skip_order" => index_type == :rum},
|
%{"offset" => offset, "limit" => limit, "skip_order" => index_type == :rum},
|
||||||
:offset
|
:offset
|
||||||
|
@ -175,12 +173,4 @@ def maybe_fetch(activities, user, search_query) do
|
||||||
_ -> activities
|
_ -> activities
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def maybe_only_media(q, true) do
|
|
||||||
from([a, o] in q,
|
|
||||||
where: fragment("not (?)->'attachment' = (?)", o.data, ^[])
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
def maybe_only_media(q, _), do: q
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,7 +43,6 @@ defp maybe_fetch(:activity, search_query) do
|
||||||
def search(user, query, options) do
|
def search(user, query, options) do
|
||||||
limit = Enum.min([Keyword.get(options, :limit), 40])
|
limit = Enum.min([Keyword.get(options, :limit), 40])
|
||||||
offset = Keyword.get(options, :offset, 0)
|
offset = Keyword.get(options, :offset, 0)
|
||||||
only_media = Keyword.get(options, :only_media, false)
|
|
||||||
|
|
||||||
parsed_query =
|
parsed_query =
|
||||||
query
|
query
|
||||||
|
@ -63,10 +62,7 @@ def search(user, query, options) do
|
||||||
|> Pleroma.Search.Elasticsearch.Store.search(q)
|
|> Pleroma.Search.Elasticsearch.Store.search(q)
|
||||||
|> Enum.filter(fn x ->
|
|> Enum.filter(fn x ->
|
||||||
x.data["type"] == "Create" && x.object.data["type"] == "Note" &&
|
x.data["type"] == "Create" && x.object.data["type"] == "Note" &&
|
||||||
Visibility.visible_for_user?(x, user) &&
|
Visibility.visible_for_user?(x, user)
|
||||||
# i'm not going to implement this very seriously because the support for
|
|
||||||
# elasticsearch is already kinda broken
|
|
||||||
if only_media, do: length(x.object.data["attachment"]) > 0, else: true
|
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ def search(:raw, index, q) do
|
||||||
{:ok, results}
|
{:ok, results}
|
||||||
else
|
else
|
||||||
{:error, e} ->
|
{:error, e} ->
|
||||||
Logger.error("Unable to search with Elasiticsearch: #{inspect(e)}")
|
Logger.error(e)
|
||||||
{:error, e}
|
{:error, e}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -44,7 +44,7 @@ def search(:activities, q) do
|
||||||
|> Pleroma.Activity.all_by_ids_with_object()
|
|> Pleroma.Activity.all_by_ids_with_object()
|
||||||
else
|
else
|
||||||
e ->
|
e ->
|
||||||
Logger.error("Unable to search with Elasiticsearch: #{inspect(e)}")
|
Logger.error(e)
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -79,7 +79,6 @@ def search(user, query, options \\ []) do
|
||||||
limit = Enum.min([Keyword.get(options, :limit), 40])
|
limit = Enum.min([Keyword.get(options, :limit), 40])
|
||||||
offset = Keyword.get(options, :offset, 0)
|
offset = Keyword.get(options, :offset, 0)
|
||||||
author = Keyword.get(options, :author)
|
author = Keyword.get(options, :author)
|
||||||
only_media = Keyword.get(options, :only_media, false)
|
|
||||||
|
|
||||||
res =
|
res =
|
||||||
meili_post(
|
meili_post(
|
||||||
|
@ -94,11 +93,11 @@ def search(user, query, options \\ []) do
|
||||||
hits
|
hits
|
||||||
|> Activity.create_by_object_ap_id()
|
|> Activity.create_by_object_ap_id()
|
||||||
|> Activity.with_preloaded_object()
|
|> Activity.with_preloaded_object()
|
||||||
|
|> Activity.with_preloaded_object()
|
||||||
|> Activity.restrict_deactivated_users()
|
|> Activity.restrict_deactivated_users()
|
||||||
|> maybe_restrict_local(user)
|
|> maybe_restrict_local(user)
|
||||||
|> maybe_restrict_author(author)
|
|> maybe_restrict_author(author)
|
||||||
|> maybe_restrict_blocked(user)
|
|> maybe_restrict_blocked(user)
|
||||||
|> maybe_only_media(only_media)
|
|
||||||
|> maybe_fetch(user, query)
|
|> maybe_fetch(user, query)
|
||||||
|> order_by([object: obj], desc: obj.data["published"])
|
|> order_by([object: obj], desc: obj.data["published"])
|
||||||
|> Pleroma.Repo.all()
|
|> Pleroma.Repo.all()
|
||||||
|
|
|
@ -75,7 +75,7 @@ def search2_operation do
|
||||||
Operation.parameter(
|
Operation.parameter(
|
||||||
:type,
|
:type,
|
||||||
:query,
|
:query,
|
||||||
%Schema{type: :string, enum: ["accounts", "hashtags", "statuses", "media"]},
|
%Schema{type: :string, enum: ["accounts", "hashtags", "statuses"]},
|
||||||
"Search type"
|
"Search type"
|
||||||
),
|
),
|
||||||
Operation.parameter(:q, :query, %Schema{type: :string}, "What to search for",
|
Operation.parameter(:q, :query, %Schema{type: :string}, "What to search for",
|
||||||
|
|
|
@ -47,7 +47,7 @@ defp do_search(version, %{assigns: %{user: user}} = conn, %{q: query} = params)
|
||||||
query = String.trim(query)
|
query = String.trim(query)
|
||||||
options = search_options(params, user)
|
options = search_options(params, user)
|
||||||
timeout = Keyword.get(Repo.config(), :timeout, 15_000)
|
timeout = Keyword.get(Repo.config(), :timeout, 15_000)
|
||||||
default_values = %{"statuses" => [], "media" => [], "accounts" => [], "hashtags" => []}
|
default_values = %{"statuses" => [], "accounts" => [], "hashtags" => []}
|
||||||
|
|
||||||
result =
|
result =
|
||||||
default_values
|
default_values
|
||||||
|
@ -107,22 +107,6 @@ defp resource_search(_, "statuses", query, options) do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp resource_search(_, "media", query, options) do
|
|
||||||
statuses =
|
|
||||||
with_fallback(fn ->
|
|
||||||
Pleroma.Search.search(
|
|
||||||
query,
|
|
||||||
Keyword.put(options, :only_media, true)
|
|
||||||
)
|
|
||||||
end)
|
|
||||||
|
|
||||||
StatusView.render("index.json",
|
|
||||||
activities: statuses,
|
|
||||||
for: options[:for_user],
|
|
||||||
as: :activity
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp resource_search(:v2, "hashtags", query, options) do
|
defp resource_search(:v2, "hashtags", query, options) do
|
||||||
tags_path = Endpoint.url() <> "/tag/"
|
tags_path = Endpoint.url() <> "/tag/"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue