don't expire pinned posts
authorAlexander Strizhakov <alex.strizhakov@gmail.com>
Wed, 12 Aug 2020 12:15:17 +0000 (15:15 +0300)
committerAlexander Strizhakov <alex.strizhakov@gmail.com>
Wed, 12 Aug 2020 12:15:17 +0000 (15:15 +0300)
lib/mix/tasks/pleroma/database.ex

index 7d8f00b089b50f6d2dc686a6865a8eec72a38ff1..0142071a86c74e265b575a9a3cdc9bf07939c4b5 100644 (file)
@@ -150,8 +150,12 @@ defmodule Mix.Tasks.Pleroma.Database do
     |> Pleroma.RepoStreamer.chunk_stream(100)
     |> Stream.each(fn activities ->
       Enum.each(activities, fn activity ->
-        expires_at = Timex.shift(activity.inserted_at, days: days)
-        Pleroma.ActivityExpiration.create(activity, expires_at, false)
+        user = User.get_cached_by_ap_id(activity.actor)
+
+        if activity.id not in user.pinned_activities do
+          expires_at = Timex.shift(activity.inserted_at, days: days)
+          Pleroma.ActivityExpiration.create(activity, expires_at, false)
+        end
       end)
     end)
     |> Stream.run()