projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'feld-Logger' into 'develop'
[akkoma]
/
lib
/
pleroma
/
web
/
websub
/
websub.ex
diff --git
a/lib/pleroma/web/websub/websub.ex
b/lib/pleroma/web/websub/websub.ex
index db1577a9373a71044263266a0b9443254dad2d94..5caa8198c10efe87d3a6c5531cf6c1df5f56c544 100644
(file)
--- a/
lib/pleroma/web/websub/websub.ex
+++ b/
lib/pleroma/web/websub/websub.ex
@@
-38,10
+38,19
@@
defmodule Pleroma.Web.Websub do
end
end
end
end
- def publish(topic, user, activity) do
+ @supported_activities [
+ "Create",
+ "Follow",
+ "Like",
+ "Announce",
+ "Undo",
+ "Delete"
+ ]
+ def publish(topic, user, %{data: %{"type" => type}} = activity) when type in @supported_activities do
# TODO: Only send to still valid subscriptions.
query = from sub in WebsubServerSubscription,
# TODO: Only send to still valid subscriptions.
query = from sub in WebsubServerSubscription,
- where: sub.topic == ^topic and sub.state == "active"
+ where: sub.topic == ^topic and sub.state == "active",
+ where: fragment("? > NOW()", sub.valid_until)
subscriptions = Repo.all(query)
Enum.each(subscriptions, fn(sub) ->
response = user
subscriptions = Repo.all(query)
Enum.each(subscriptions, fn(sub) ->
response = user
@@
-58,6
+67,7
@@
defmodule Pleroma.Web.Websub do
Pleroma.Web.Federator.enqueue(:publish_single_websub, data)
end)
end
Pleroma.Web.Federator.enqueue(:publish_single_websub, data)
end)
end
+ def publish(_,_,_), do: ""
def sign(secret, doc) do
:crypto.hmac(:sha, secret, to_string(doc)) |> Base.encode16 |> String.downcase
def sign(secret, doc) do
:crypto.hmac(:sha, secret, to_string(doc)) |> Base.encode16 |> String.downcase
@@
-88,7
+98,7
@@
defmodule Pleroma.Web.Websub do
{:ok, websub}
else {:error, reason} ->
{:ok, websub}
else {:error, reason} ->
- Logger.debug("Couldn't create subscription
.
")
+ Logger.debug("Couldn't create subscription")
Logger.debug(inspect(reason))
{:error, reason}
Logger.debug(inspect(reason))
{:error, reason}