mirror of
https://github.com/humhub/humhub.git
synced 2025-01-29 20:38:26 +01:00
Merge pull request #4451 from humhub/enh/addUserFollowsToLive
Enh/add user follows to live #3994
This commit is contained in:
commit
635974f9da
@ -39,5 +39,7 @@ HumHub Changelog
|
||||
- Enh #4401: Allow to use less variable name in value of another less variable
|
||||
- Fix #4434: Fix title quoting for space icons in widget “Member in these spaces”
|
||||
- Fix #4428: Replace db Expression time now with func date('Y-m-d G:i:s')
|
||||
- Enh #3994: Live event legitimation array include followed users
|
||||
- Enh #3994: Live event legitimation consider `cached` argument in processing data
|
||||
- Fix #4452: `humhub.ui.filter.getActiveFilterCount` returns wrong value with exclude array option
|
||||
- Fix #4452: Ignore `scope` profile filter in stream filter count and hasActiveFilters
|
||||
|
@ -50,7 +50,7 @@ class Module extends \humhub\components\Module
|
||||
{
|
||||
$legitimation = Yii::$app->cache->get(self::$legitimateCachePrefix . $user->id);
|
||||
|
||||
if ($legitimation === false) {
|
||||
if (!$cached || $legitimation === false) {
|
||||
$legitimation = [
|
||||
Content::VISIBILITY_PUBLIC => [],
|
||||
Content::VISIBILITY_PRIVATE => [],
|
||||
@ -84,6 +84,11 @@ class Module extends \humhub\components\Module
|
||||
$legitimation[Content::VISIBILITY_PUBLIC][] = $space->contentContainerRecord->id;
|
||||
}
|
||||
|
||||
// Collect users which the user follows
|
||||
foreach (Follow::getFollowedUserQuery($user)->all() as $followedUser) {
|
||||
$legitimation[Content::VISIBILITY_PUBLIC][] = $followedUser->contentContainerRecord->id;
|
||||
}
|
||||
|
||||
Yii::$app->cache->set(self::$legitimateCachePrefix . $user->id, $legitimation);
|
||||
Yii::$app->live->driver->onContentContainerLegitimationChanged($user, $legitimation);
|
||||
};
|
||||
|
@ -174,6 +174,26 @@ class Follow extends \yii\db\ActiveRecord
|
||||
return Space::find()->where(['exists', $subQuery]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \humhub\modules\user\models\User $user
|
||||
* @param null $withNotifications
|
||||
* @return ActiveQueryUser
|
||||
*/
|
||||
public static function getFollowedUserQuery(User $user, $withNotifications = null)
|
||||
{
|
||||
$subQuery = self::find()
|
||||
->where(['user_follow.user_id' => $user->id, 'user_follow.object_model' => User::class])
|
||||
->andWhere('user_follow.object_id=user.id');
|
||||
|
||||
if ($withNotifications === true) {
|
||||
$subQuery->andWhere(['user_follow.send_notifications' => 1]);
|
||||
} elseif ($withNotifications === false) {
|
||||
$subQuery->andWhere(['user_follow.send_notifications' => 0]);
|
||||
}
|
||||
|
||||
return User::find()->where(['exists', $subQuery]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all active users following the given $target record.
|
||||
* If $withNotifications is set only follower with the given send_notifications setting are returned.
|
||||
|
Loading…
x
Reference in New Issue
Block a user