aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2018-02-24 17:36:02 +0100
committerlain <lain@soykaf.club>2018-02-24 17:36:02 +0100
commite5fcc51a067dd420d37c68f9eabe0b7df2e048d5 (patch)
tree2f4a09497230cc242142c911d956bf8aa09bfc05 /lib
parentfa3aa59248fb3a4d7202f55209ace86e6ebcef66 (diff)
downloadpleroma-e5fcc51a067dd420d37c68f9eabe0b7df2e048d5.tar.gz
Remove unneccesary subscriptions on update.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/activity_pub/transmogrifier.ex11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex
index b64b69565..2e5ca70fd 100644
--- a/lib/pleroma/web/activity_pub/transmogrifier.ex
+++ b/lib/pleroma/web/activity_pub/transmogrifier.ex
@@ -204,6 +204,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
update: [set: [following: fragment("array_replace(?,?,?)", u.following, ^old_follower_address, ^user.follower_address)]]
Repo.update_all(q, [])
+ maybe_retire_websub(user.ap_id)
+
# Only do this for recent activties, don't go through the whole db.
since = (Repo.aggregate(Activity, :max, :id) || 0) - 100_000
q = from a in Activity,
@@ -236,4 +238,13 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
e -> e
end
end
+
+ def maybe_retire_websub(ap_id) do
+ # some sanity checks
+ if is_binary(ap_id) && (String.length(ap_id) > 8) do
+ q = from ws in Pleroma.Web.Websub.WebsubClientSubscription,
+ where: fragment("? like ?", ws.topic, ^"#{ap_id}%")
+ Repo.delete_all(q)
+ end
+ end
end