Save remote user bio and update if we see new data.
[akkoma] / lib / pleroma / web / websub / websub.ex
index 5468758fd36e41326d1b51db8db86d8a918d45e4..a683f6da40de022e443630f8adb279471f019431 100644 (file)
@@ -39,6 +39,7 @@ defmodule Pleroma.Web.Websub do
   end
 
   def publish(topic, user, activity) do
+    # TODO: Only send to still valid subscriptions.
     query = from sub in WebsubServerSubscription,
     where: sub.topic == ^topic and sub.state == "active"
     subscriptions = Repo.all(query)
@@ -155,6 +156,7 @@ defmodule Pleroma.Web.Websub do
       preferredUsername = XML.string_from_xpath("/feed/author[1]/poco:preferredUsername", doc)
       displayName = XML.string_from_xpath("/feed/author[1]/poco:displayName", doc)
       avatar = OStatus.make_avatar_object(doc)
+      bio = XML.string_from_xpath("/feed/author[1]/summary", doc)
 
       {:ok, %{
         "uri" => uri,
@@ -162,7 +164,8 @@ defmodule Pleroma.Web.Websub do
         "nickname" => preferredUsername || name,
         "name" => displayName || name,
         "host" => URI.parse(uri).host,
-        "avatar" => avatar
+        "avatar" => avatar,
+        "bio" => bio
       }}
     else e ->
       {:error, e}
@@ -211,7 +214,7 @@ defmodule Pleroma.Web.Websub do
     cut_off = NaiveDateTime.add(NaiveDateTime.utc_now, delta)
 
     query = from sub in WebsubClientSubscription,
-      where: sub.valid_until < ^cut_off and sub.state == "active"
+      where: sub.valid_until < ^cut_off and sub.state == "accepted"
 
     subs = Repo.all(query)