Loading app/Config/Events.php +11 −21 Original line number Diff line number Diff line Loading @@ -122,23 +122,9 @@ Events::on('on_undo_follow', function ($actor, $targetActor): void { * @param Post $post */ Events::on('on_post_add', function ($post): void { $isReply = $post->in_reply_to_id !== null; if ($isReply) { $post = $post->reply_to_post; } if ($post->episode_id !== null) { if ($isReply) { model(EpisodeModel::class, false)->builder() ->where('id', $post->episode_id) ->increment('comments_count'); } else { model(EpisodeModel::class, false)->builder() ->where('id', $post->episode_id) ->increment('posts_count'); } } if ($post->actor->is_podcast) { // Removing all of the podcast pages is a bit overkill, but works to avoid caching bugs Loading @@ -154,10 +140,6 @@ Events::on('on_post_add', function ($post): void { * @param Post $post */ Events::on('on_post_remove', function ($post): void { if ($post->in_reply_to_id !== null) { Events::trigger('on_post_remove', $post->reply_to_post); } if ($episodeId = $post->episode_id) { model(EpisodeModel::class, false)->builder() ->where('id', $episodeId) Loading Loading @@ -237,6 +219,10 @@ Events::on('on_post_undo_reblog', function ($reblogPost): void { Events::on('on_post_reply', function ($reply): void { $post = $reply->reply_to_post; model(EpisodeModel::class, false)->builder() ->where('id', $post->episode_id) ->increment('comments_count'); if ($post->actor->is_podcast) { cache() ->deleteMatching("podcast#{$post->actor->podcast->id}*"); Loading @@ -254,6 +240,10 @@ Events::on('on_post_reply', function ($reply): void { Events::on('on_reply_remove', function ($reply): void { $post = $reply->reply_to_post; model(EpisodeModel::class, false)->builder() ->where('id', $post->episode_id) ->decrement('comments_count'); if ($post->actor->is_podcast) { cache() ->deleteMatching("page_podcast#{$post->actor->podcast->id}*"); Loading app/Controllers/PostController.php +5 −1 Original line number Diff line number Diff line Loading @@ -74,6 +74,10 @@ class PostController extends FediversePostController $this->registerPodcastWebpageHit($this->podcast->id); } if ($this->post === null) { throw PageNotFoundException::forPageNotFound(); } $cacheName = implode( '_', array_filter([ Loading Loading @@ -177,7 +181,7 @@ class PostController extends FediversePostController 'created_by' => user_id(), ]); if ($this->post->in_reply_to_id === null && $this->post->episode_id !== null) { if ($this->post->episode_id !== null) { $newPost->episode_id = $this->post->episode_id; } Loading app/Models/PostModel.php +0 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,6 @@ class PostModel extends FediversePostModel ->join(config('Fediverse')->tablesPrefix . 'posts as p2', 'p1.id = p2.in_reply_to_id') ->select('p2.id, p1.episode_id') ->where([ 'p1.in_reply_to_id' => null, 'p2.in_reply_to_id IS NOT' => null, 'p2.episode_id' => null, 'p1.episode_id IS NOT' => null, Loading modules/Admin/Controllers/EpisodeController.php +2 −0 Original line number Diff line number Diff line Loading @@ -714,6 +714,8 @@ class EpisodeController extends BaseController $allPostsLinkedToEpisode = (new PostModel()) ->where([ 'episode_id' => $this->episode->id, 'in_reply_to_id' => null, 'reblog_of_id' => null, ]) ->findAll(); foreach ($allPostsLinkedToEpisode as $post) { Loading modules/Fediverse/Models/PostModel.php +22 −22 Original line number Diff line number Diff line Loading @@ -277,10 +277,12 @@ class PostModel extends BaseUuidModel } if ($post->in_reply_to_id === null) { // increment posts_count only if not reply // post is not a reply model('ActorModel', false) ->where('id', $post->actor_id) ->increment('posts_count'); Events::trigger('on_post_add', $post); } if ($registerActivity) { Loading Loading @@ -314,8 +316,6 @@ class PostModel extends BaseUuidModel ]); } Events::trigger('on_post_add', $post); $this->clearCache($post); $this->db->transComplete(); Loading Loading @@ -365,26 +365,13 @@ class PostModel extends BaseUuidModel { $this->db->transStart(); model('ActorModel', false) ->where('id', $post->actor_id) ->decrement('posts_count'); if ($post->in_reply_to_id !== null) { // Post to remove is a reply model('PostModel', false) ->where('id', $this->uuid->fromString($post->in_reply_to_id) ->getBytes()) ->decrement('replies_count'); Events::trigger('on_reply_remove', $post); } // remove all post reblogs foreach ($post->reblogs as $reblog) { // FIXME: issue when actor is not local, can't get actor information $this->removePost($reblog); $this->undoReblog($reblog); } // remove all post replies // remove all replies foreach ($post->replies as $reply) { $this->removePost($reply); } Loading Loading @@ -427,10 +414,23 @@ class PostModel extends BaseUuidModel ]); } $result = model('PostModel', false) ->delete($post->id); if ($post->in_reply_to_id === null && $post->reblog_of_id === null) { model('ActorModel', false) ->where('id', $post->actor_id) ->decrement('posts_count'); Events::trigger('on_post_remove', $post); } elseif ($post->in_reply_to_id !== null) { // Post to remove is a reply model('PostModel', false) ->where('id', $this->uuid->fromString($post->in_reply_to_id) ->getBytes()) ->decrement('replies_count'); Events::trigger('on_reply_remove', $post); } $result = model('PostModel', false) ->delete($post->id); $this->clearCache($post); Loading Loading @@ -574,11 +574,11 @@ class PostModel extends BaseUuidModel ]); } Events::trigger('on_post_undo_reblog', $reblogPost); $result = model('PostModel', false) ->delete($reblogPost->id); Events::trigger('on_post_undo_reblog', $reblogPost); $this->clearCache($reblogPost); $this->db->transComplete(); Loading Loading
app/Config/Events.php +11 −21 Original line number Diff line number Diff line Loading @@ -122,23 +122,9 @@ Events::on('on_undo_follow', function ($actor, $targetActor): void { * @param Post $post */ Events::on('on_post_add', function ($post): void { $isReply = $post->in_reply_to_id !== null; if ($isReply) { $post = $post->reply_to_post; } if ($post->episode_id !== null) { if ($isReply) { model(EpisodeModel::class, false)->builder() ->where('id', $post->episode_id) ->increment('comments_count'); } else { model(EpisodeModel::class, false)->builder() ->where('id', $post->episode_id) ->increment('posts_count'); } } if ($post->actor->is_podcast) { // Removing all of the podcast pages is a bit overkill, but works to avoid caching bugs Loading @@ -154,10 +140,6 @@ Events::on('on_post_add', function ($post): void { * @param Post $post */ Events::on('on_post_remove', function ($post): void { if ($post->in_reply_to_id !== null) { Events::trigger('on_post_remove', $post->reply_to_post); } if ($episodeId = $post->episode_id) { model(EpisodeModel::class, false)->builder() ->where('id', $episodeId) Loading Loading @@ -237,6 +219,10 @@ Events::on('on_post_undo_reblog', function ($reblogPost): void { Events::on('on_post_reply', function ($reply): void { $post = $reply->reply_to_post; model(EpisodeModel::class, false)->builder() ->where('id', $post->episode_id) ->increment('comments_count'); if ($post->actor->is_podcast) { cache() ->deleteMatching("podcast#{$post->actor->podcast->id}*"); Loading @@ -254,6 +240,10 @@ Events::on('on_post_reply', function ($reply): void { Events::on('on_reply_remove', function ($reply): void { $post = $reply->reply_to_post; model(EpisodeModel::class, false)->builder() ->where('id', $post->episode_id) ->decrement('comments_count'); if ($post->actor->is_podcast) { cache() ->deleteMatching("page_podcast#{$post->actor->podcast->id}*"); Loading
app/Controllers/PostController.php +5 −1 Original line number Diff line number Diff line Loading @@ -74,6 +74,10 @@ class PostController extends FediversePostController $this->registerPodcastWebpageHit($this->podcast->id); } if ($this->post === null) { throw PageNotFoundException::forPageNotFound(); } $cacheName = implode( '_', array_filter([ Loading Loading @@ -177,7 +181,7 @@ class PostController extends FediversePostController 'created_by' => user_id(), ]); if ($this->post->in_reply_to_id === null && $this->post->episode_id !== null) { if ($this->post->episode_id !== null) { $newPost->episode_id = $this->post->episode_id; } Loading
app/Models/PostModel.php +0 −1 Original line number Diff line number Diff line Loading @@ -62,7 +62,6 @@ class PostModel extends FediversePostModel ->join(config('Fediverse')->tablesPrefix . 'posts as p2', 'p1.id = p2.in_reply_to_id') ->select('p2.id, p1.episode_id') ->where([ 'p1.in_reply_to_id' => null, 'p2.in_reply_to_id IS NOT' => null, 'p2.episode_id' => null, 'p1.episode_id IS NOT' => null, Loading
modules/Admin/Controllers/EpisodeController.php +2 −0 Original line number Diff line number Diff line Loading @@ -714,6 +714,8 @@ class EpisodeController extends BaseController $allPostsLinkedToEpisode = (new PostModel()) ->where([ 'episode_id' => $this->episode->id, 'in_reply_to_id' => null, 'reblog_of_id' => null, ]) ->findAll(); foreach ($allPostsLinkedToEpisode as $post) { Loading
modules/Fediverse/Models/PostModel.php +22 −22 Original line number Diff line number Diff line Loading @@ -277,10 +277,12 @@ class PostModel extends BaseUuidModel } if ($post->in_reply_to_id === null) { // increment posts_count only if not reply // post is not a reply model('ActorModel', false) ->where('id', $post->actor_id) ->increment('posts_count'); Events::trigger('on_post_add', $post); } if ($registerActivity) { Loading Loading @@ -314,8 +316,6 @@ class PostModel extends BaseUuidModel ]); } Events::trigger('on_post_add', $post); $this->clearCache($post); $this->db->transComplete(); Loading Loading @@ -365,26 +365,13 @@ class PostModel extends BaseUuidModel { $this->db->transStart(); model('ActorModel', false) ->where('id', $post->actor_id) ->decrement('posts_count'); if ($post->in_reply_to_id !== null) { // Post to remove is a reply model('PostModel', false) ->where('id', $this->uuid->fromString($post->in_reply_to_id) ->getBytes()) ->decrement('replies_count'); Events::trigger('on_reply_remove', $post); } // remove all post reblogs foreach ($post->reblogs as $reblog) { // FIXME: issue when actor is not local, can't get actor information $this->removePost($reblog); $this->undoReblog($reblog); } // remove all post replies // remove all replies foreach ($post->replies as $reply) { $this->removePost($reply); } Loading Loading @@ -427,10 +414,23 @@ class PostModel extends BaseUuidModel ]); } $result = model('PostModel', false) ->delete($post->id); if ($post->in_reply_to_id === null && $post->reblog_of_id === null) { model('ActorModel', false) ->where('id', $post->actor_id) ->decrement('posts_count'); Events::trigger('on_post_remove', $post); } elseif ($post->in_reply_to_id !== null) { // Post to remove is a reply model('PostModel', false) ->where('id', $this->uuid->fromString($post->in_reply_to_id) ->getBytes()) ->decrement('replies_count'); Events::trigger('on_reply_remove', $post); } $result = model('PostModel', false) ->delete($post->id); $this->clearCache($post); Loading Loading @@ -574,11 +574,11 @@ class PostModel extends BaseUuidModel ]); } Events::trigger('on_post_undo_reblog', $reblogPost); $result = model('PostModel', false) ->delete($reblogPost->id); Events::trigger('on_post_undo_reblog', $reblogPost); $this->clearCache($reblogPost); $this->db->transComplete(); Loading