mirror of
https://github.com/flarum/core.git
synced 2025-07-23 09:41:26 +02:00
New user activity feed API.
Originally the user activity feed was implemented using UNIONs. I was looking at make an API to add activity “sources”, or extra UNION queries (select from posts, mentions, etc.) but quickly realised that this is too slow and there’s no way to make it scale. So I’ve implemented an API which is very similar to how notifications work (see previous commit). The `activity` table is an aggregation of stuff that happens, and it’s kept in sync by an ActivitySyncer which is used whenever a post it created/edited/deleted, a user is mentioned/unmentioned, etc. Again, the API is very simple (see Core\Activity\PostedActivity + Core\Handlers\Events\UserActivitySyncer)
This commit is contained in:
27
framework/core/src/Extend/ActivityType.php
Normal file
27
framework/core/src/Extend/ActivityType.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php namespace Flarum\Extend;
|
||||
|
||||
use Illuminate\Foundation\Application;
|
||||
use Flarum\Core\Models\Activity;
|
||||
use Flarum\Api\Serializers\ActivitySerializer;
|
||||
|
||||
class ActivityType implements ExtenderInterface
|
||||
{
|
||||
protected $class;
|
||||
|
||||
protected $serializer;
|
||||
|
||||
public function __construct($class, $serializer)
|
||||
{
|
||||
$this->class = $class;
|
||||
$this->serializer = $serializer;
|
||||
}
|
||||
|
||||
public function extend(Application $app)
|
||||
{
|
||||
$class = $this->class;
|
||||
|
||||
Activity::registerType($class);
|
||||
|
||||
ActivitySerializer::$subjects[$class::getType()] = $this->serializer;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user