forked from mirrors/akkoma
bites you
This commit is contained in:
parent
828158ef49
commit
e3c0c5e5ce
|
@ -1,4 +1,6 @@
|
||||||
## akkoma
|
## snaccoma: akkoma with bites
|
||||||
|
|
||||||
|
this is a silly little fork which can receive [Bite](https://ns.mia.jetzt/as/) activities
|
||||||
|
|
||||||
*a smallish microblogging platform, aka the cooler pleroma*
|
*a smallish microblogging platform, aka the cooler pleroma*
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,7 @@ def unread_notifications_count(%User{id: user_id}) do
|
||||||
pleroma:report
|
pleroma:report
|
||||||
reblog
|
reblog
|
||||||
poll
|
poll
|
||||||
|
bite
|
||||||
}
|
}
|
||||||
|
|
||||||
def changeset(%Notification{} = notification, attrs) do
|
def changeset(%Notification{} = notification, attrs) do
|
||||||
|
@ -402,7 +403,7 @@ def create_notifications(%Activity{data: %{"to" => _, "type" => "Create"}} = act
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_notifications(%Activity{data: %{"type" => type}} = activity, options)
|
def create_notifications(%Activity{data: %{"type" => type}} = activity, options)
|
||||||
when type in ["Follow", "Like", "Announce", "Move", "EmojiReact", "Flag", "Update"] do
|
when type in ["Follow", "Like", "Announce", "Move", "EmojiReact", "Flag", "Update", "Bite"] do
|
||||||
do_create_notifications(activity, options)
|
do_create_notifications(activity, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -459,6 +460,9 @@ defp type_from_activity(%{data: %{"type" => type}} = activity) do
|
||||||
"Update" ->
|
"Update" ->
|
||||||
"update"
|
"update"
|
||||||
|
|
||||||
|
"Bite" ->
|
||||||
|
"bite"
|
||||||
|
|
||||||
t ->
|
t ->
|
||||||
raise "No notification type for activity type #{t}"
|
raise "No notification type for activity type #{t}"
|
||||||
end
|
end
|
||||||
|
@ -532,7 +536,8 @@ def get_notified_from_activity(%Activity{data: %{"type" => type}} = activity, lo
|
||||||
"Move",
|
"Move",
|
||||||
"EmojiReact",
|
"EmojiReact",
|
||||||
"Flag",
|
"Flag",
|
||||||
"Update"
|
"Update",
|
||||||
|
"Bite"
|
||||||
] do
|
] do
|
||||||
potential_receiver_ap_ids = get_potential_receiver_ap_ids(activity)
|
potential_receiver_ap_ids = get_potential_receiver_ap_ids(activity)
|
||||||
|
|
||||||
|
|
|
@ -186,6 +186,13 @@ def handle(%{data: %{"type" => "Like"}} = object, meta) do
|
||||||
{:ok, object, meta}
|
{:ok, object, meta}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Tasks this handles
|
||||||
|
# - Set up bite notification
|
||||||
|
def handle(%{data: %{"type" => "Bite"}} = object, meta) do
|
||||||
|
Notification.create_notifications(object)
|
||||||
|
{:ok, object, meta}
|
||||||
|
end
|
||||||
|
|
||||||
# Tasks this handles
|
# Tasks this handles
|
||||||
# - Actually create object
|
# - Actually create object
|
||||||
# - Rollback if we couldn't create it
|
# - Rollback if we couldn't create it
|
||||||
|
|
|
@ -533,7 +533,7 @@ defp handle_incoming_normalised(
|
||||||
%{"type" => type} = data,
|
%{"type" => type} = data,
|
||||||
_options
|
_options
|
||||||
)
|
)
|
||||||
when type in ~w{Update Block Follow Accept Reject} do
|
when type in ~w{Update Block Follow Accept Reject Bite} do
|
||||||
with {:ok, %User{}} <- ObjectValidator.fetch_actor(data),
|
with {:ok, %User{}} <- ObjectValidator.fetch_actor(data),
|
||||||
{:ok, activity, _} <-
|
{:ok, activity, _} <-
|
||||||
Pipeline.common_pipeline(data, local: false) do
|
Pipeline.common_pipeline(data, local: false) do
|
||||||
|
|
|
@ -118,7 +118,7 @@ def perform(:incoming_ap_doc, params) do
|
||||||
|
|
||||||
e ->
|
e ->
|
||||||
# Just drop those for now
|
# Just drop those for now
|
||||||
Logger.debug(fn -> "Unhandled activity\n" <> Jason.encode!(params, pretty: true) end)
|
Logger.debug(fn -> "Unhandled activity (error: #{inspect(e)})\n" <> Jason.encode!(params, pretty: true) end)
|
||||||
{:error, e}
|
{:error, e}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -128,7 +128,7 @@ def render(
|
||||||
"pleroma:report" ->
|
"pleroma:report" ->
|
||||||
put_report(response, activity)
|
put_report(response, activity)
|
||||||
|
|
||||||
type when type in ["follow", "follow_request"] ->
|
type when type in ["follow", "follow_request", "bite"] ->
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.AddBiteToNotificationsEnum do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
@disable_ddl_transaction true
|
||||||
|
|
||||||
|
def up do
|
||||||
|
"""
|
||||||
|
alter type notification_type add value if not exists 'bite'
|
||||||
|
"""
|
||||||
|
|> execute()
|
||||||
|
end
|
||||||
|
|
||||||
|
def down do
|
||||||
|
# Leave value in place
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue