mirror of
https://github.com/flarum/core.git
synced 2025-10-14 08:24:28 +02:00
The activity system we were using was built around a separate table. Whenever the user posted something, or deleted a post, we would sync the table. The advantage of this was that we could aggregate activity of all different types very efficiently. It turns out that it came with a huge disadvantage: there was no efficient way to enforce permissions on activity. If a user posted something in a private tag, everyone could still see it on their activity feed. My stopgap solution was to only sync activity for posts that are viewable by guests, but that was way too limited. It also turns out that aggregating activity of different types is really not that useful, especially considering most of it is the user making posts. So I've gotten rid of that whole overly-complicated system, and just made the user profile display separate lists of posts and discussions, retrieved from those respective APIs. The discussions page is an actual discussion list too, which is pretty cool. It's still technically possible to aggregate different activity types (basically just aggregate API responses together), but we can do that later if there's a need for it. This is probably my favourite commit of the day :)
67 lines
1.2 KiB
JavaScript
67 lines
1.2 KiB
JavaScript
import Component from 'flarum/Component';
|
|
import humanTime from 'flarum/helpers/humanTime';
|
|
import avatar from 'flarum/helpers/avatar';
|
|
|
|
/**
|
|
* The `Activity` component represents a piece of activity of a user's activity
|
|
* feed. Subclasses should implement the `description` and `content` methods.
|
|
*
|
|
* ### Props
|
|
*
|
|
* - `activity`
|
|
*
|
|
* @abstract
|
|
*/
|
|
export default class Activity extends Component {
|
|
view() {
|
|
const activity = this.props.activity;
|
|
|
|
return (
|
|
<div className="Activity">
|
|
{avatar(this.user(), {className: 'Activity-avatar'})}
|
|
|
|
<div className="Activity-header">
|
|
<strong className="Activity-description">{this.description()}</strong>
|
|
{humanTime(this.time())}
|
|
</div>
|
|
|
|
{this.content()}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get the user whose avatar should be displayed.
|
|
*
|
|
* @return {User}
|
|
* @abstract
|
|
*/
|
|
user() {
|
|
}
|
|
|
|
/**
|
|
* Get the time of the activity.
|
|
*
|
|
* @return {Date}
|
|
* @abstract
|
|
*/
|
|
time() {
|
|
}
|
|
|
|
/**
|
|
* Get the description of the activity.
|
|
*
|
|
* @return {VirtualElement}
|
|
*/
|
|
description() {
|
|
}
|
|
|
|
/**
|
|
* Get the content to show below the activity description.
|
|
*
|
|
* @return {VirtualElement}
|
|
*/
|
|
content() {
|
|
}
|
|
}
|