House rules: primary constructors, a cancellation token on every async call, and the rules fail the build
Build / Build (push) Successful in 30s

- Services, controllers and jobs take their dependencies through primary
  constructors and use them directly; where a method already named a local
  after a dependency, the dependency takes its type's name.
- Every async method takes a CancellationToken last and passes it down to
  MongoDB, HTTP and the job queue. The setup claim is still given back when
  a request is cancelled.
- The federation and media options are read through IOptionsMonitor.
- The Mastodon entities keep sending "" for empty strings, and every model
  field where null means something says so.
- The inbox's 503 with Retry-After, which other servers retry, is the one
  server error left, and says why.
- Arasaka.HouseRules.Analyzers checks all of this in every build, here and in
  PrivaPub.ClientModels as decePubClient builds it.

Checked against GoToSocial in the pasture: 64 passed, 0 failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
This commit is contained in:
thepraandClaude Opus 5.5 committed 2026-11-10 01:24:43 +01:00
1 parent f0a14c737f
commit 0f73f69239
176 files changed
+2789 -3974

No files matched your search

+80 -98
View File
@@ -30,42 +30,24 @@ namespace PrivaPub.Services
Task<WebResult> GetInvitation(string invitationCode, string invitationPassword, CancellationToken token);
}
public class GroupUsersService : IGroupUsersService
public class GroupUsersService(
DbEntities dbEntities,
IPasswordHasher passwordHasher,
ILocalActorService localActors,
IDeliveryService delivery,
IStringLocalizer<GenericRes> localizer,
ILogger<GroupUsersService> logger,
Domain.Media.IMediaProxy mediaProxy) : IGroupUsersService
{
readonly DbEntities _dbEntities;
readonly IPasswordHasher _passwordHasher;
readonly ILocalActorService _localActors;
readonly IDeliveryService _delivery;
readonly Domain.Media.IMediaProxy _proxy;
readonly IStringLocalizer<GenericRes> _localizer;
readonly ILogger<GroupUsersService> _logger;
public GroupUsersService(DbEntities dbEntities,
IPasswordHasher passwordHasher,
ILocalActorService localActors,
IDeliveryService delivery,
IStringLocalizer<GenericRes> localizer,
ILogger<GroupUsersService> logger,
Domain.Media.IMediaProxy proxy)
{
_proxy = proxy;
_dbEntities = dbEntities;
_passwordHasher = passwordHasher;
_localActors = localActors;
_delivery = delivery;
_localizer = localizer;
_logger = logger;
}
public async Task<WebResult> GetGroups(string rootUserId, string avatarId, CancellationToken token)
{
var result = new WebResult();
try
{
if (!await OwnsAvatar(rootUserId, avatarId, token))
return result.Invalidate(_localizer["Avatar not found."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound);
var groups = await _dbEntities.Groups
var groups = await dbEntities.Groups
.Match(g => !g.DeletionAt.HasValue && g.Members.Any(m => !m.IsForeign && m.AvatarId == avatarId))
.ExecuteAsync(token);
result.Data = groups.Select(g => ToView(g, avatarId)).ToList();
@@ -73,8 +55,8 @@ namespace PrivaPub.Services
}
catch (Exception ex)
{
_logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(GetGroups)}");
return result.Invalidate(_localizer["Something went wrong."], exception: ex);
logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(GetGroups)}");
return result.Invalidate(localizer["Something went wrong."], exception: ex);
}
}
@@ -84,11 +66,11 @@ namespace PrivaPub.Services
try
{
if (!await OwnsAvatar(rootUserId, form.AvatarId, token))
return result.Invalidate(_localizer["Avatar not found."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound);
var userName = form.UserName.ToLowerInvariant();
if (await _localActors.IsUserNameTaken(userName, token))
return result.Invalidate(_localizer["The username '{0}' is already taken.", userName]);
if (await localActors.IsUserNameTaken(userName, token))
return result.Invalidate(localizer["The username '{0}' is already taken.", userName]);
var (privateKey, publicKey) = Keys.NewKeyPair();
var group = new GroupEntity
@@ -96,7 +78,7 @@ namespace PrivaPub.Services
UserName = userName,
Name = form.Name,
Description = form.Description,
Domain = _localActors.BaseAddress,
Domain = localActors.BaseAddress,
PrivateKey = privateKey,
PublicKey = publicKey,
Kind = form.IsCommunity ? GroupKind.Community : GroupKind.Circle,
@@ -105,13 +87,13 @@ namespace PrivaPub.Services
ManuallyApprovesMembers = form.ManuallyApprovesMembers,
OwnerAvatarId = form.AvatarId,
InvitationCode = NewInvitationCode(),
HashedInvitationPassword = string.IsNullOrEmpty(form.InvitationPassword) ? default : _passwordHasher.Hash(form.InvitationPassword),
HashedInvitationPassword = string.IsNullOrEmpty(form.InvitationPassword) ? default : passwordHasher.Hash(form.InvitationPassword),
Members = new() { new GroupMember { AvatarId = form.AvatarId, Role = GroupRole.Owner } }
};
group.ID = (string)group.GenerateNewID();
if (!await _localActors.TryReserveUserName(userName, LocalActorKind.Group, group.ID, token))
return result.Invalidate(_localizer["The username '{0}' is already taken.", userName]);
var actor = _localActors.FromGroup(group);
if (!await localActors.TryReserveUserName(userName, LocalActorKind.Group, group.ID, token))
return result.Invalidate(localizer["The username '{0}' is already taken.", userName]);
var actor = localActors.FromGroup(group);
group.Url = actor.Uri;
group.InboxURL = actor.Inbox;
group.OutboxURL = actor.Outbox;
@@ -122,8 +104,8 @@ namespace PrivaPub.Services
}
catch (Exception ex)
{
_logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(InsertGroup)}");
return result.Invalidate(_localizer["Something went wrong."], exception: ex);
logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(InsertGroup)}");
return result.Invalidate(localizer["Something went wrong."], exception: ex);
}
}
@@ -134,7 +116,7 @@ namespace PrivaPub.Services
{
var group = await ManagedGroup(rootUserId, form.AvatarId, form.GroupId, token);
if (group == default)
return result.Invalidate(_localizer["Group not found."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Group not found."], StatusCodes.Status404NotFound);
if (form.Name != default)
group.Name = form.Name;
@@ -149,7 +131,7 @@ namespace PrivaPub.Services
if (form.RemoveInvitationPassword)
group.HashedInvitationPassword = default;
else if (!string.IsNullOrEmpty(form.InvitationPassword))
group.HashedInvitationPassword = _passwordHasher.Hash(form.InvitationPassword);
group.HashedInvitationPassword = passwordHasher.Hash(form.InvitationPassword);
if (form.RegenerateInvitationCode)
group.InvitationCode = NewInvitationCode();
group.UpdatedAt = DateTime.UtcNow;
@@ -160,8 +142,8 @@ namespace PrivaPub.Services
}
catch (Exception ex)
{
_logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(UpdateGroup)}");
return result.Invalidate(_localizer["Something went wrong."], exception: ex);
logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(UpdateGroup)}");
return result.Invalidate(localizer["Something went wrong."], exception: ex);
}
}
@@ -171,21 +153,21 @@ namespace PrivaPub.Services
try
{
if (!await OwnsAvatar(rootUserId, form.AvatarId, token))
return result.Invalidate(_localizer["Avatar not found."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound);
var group = await _dbEntities.Groups
var group = await dbEntities.Groups
.Match(g => g.InvitationCode == form.InvitationCode && !g.DeletionAt.HasValue)
.ExecuteFirstAsync(token);
if (group == default)
return result.Invalidate(_localizer["Invalid invitation."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Invalid invitation."], StatusCodes.Status404NotFound);
if (!string.IsNullOrEmpty(group.HashedInvitationPassword))
{
var (verified, _) = string.IsNullOrEmpty(form.InvitationPassword)
? (false, false)
: _passwordHasher.Check(group.HashedInvitationPassword, form.InvitationPassword);
: passwordHasher.Check(group.HashedInvitationPassword, form.InvitationPassword);
if (!verified)
return result.Invalidate(_localizer["Invalid password."], StatusCodes.Status406NotAcceptable);
return result.Invalidate(localizer["Invalid password."], StatusCodes.Status406NotAcceptable);
}
if (!group.Members.Any(m => !m.IsForeign && m.AvatarId == form.AvatarId))
@@ -201,8 +183,8 @@ namespace PrivaPub.Services
}
catch (Exception ex)
{
_logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(JoinGroup)}");
return result.Invalidate(_localizer["Something went wrong."], exception: ex);
logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(JoinGroup)}");
return result.Invalidate(localizer["Something went wrong."], exception: ex);
}
}
@@ -210,8 +192,8 @@ namespace PrivaPub.Services
// followers (so /groupies and /flock agree) and gets its posts in the home timeline.
async Task FollowAsMember(GroupEntity group, string avatarId, CancellationToken token)
{
var persona = await _localActors.FindById(LocalActorKind.Person, avatarId, token);
var target = _localActors.FromGroup(group);
var persona = await localActors.FindById(LocalActorKind.Person, avatarId, token);
var target = localActors.FromGroup(group);
if (persona == default)
return;
await DB.Default.Update<Follower>()
@@ -239,20 +221,20 @@ namespace PrivaPub.Services
try
{
if (!await OwnsAvatar(rootUserId, form.AvatarId, token))
return result.Invalidate(_localizer["Avatar not found."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound);
var group = await _dbEntities.Groups.MatchID(form.GroupId).ExecuteFirstAsync(token);
var group = await dbEntities.Groups.MatchID(form.GroupId).ExecuteFirstAsync(token);
if (group == default)
return result.Invalidate(_localizer["Group not found."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Group not found."], StatusCodes.Status404NotFound);
if (group.OwnerAvatarId == form.AvatarId)
return result.Invalidate(_localizer["The owner cannot leave the group."]);
return result.Invalidate(localizer["The owner cannot leave the group."]);
group.Members.RemoveAll(m => !m.IsForeign && m.AvatarId == form.AvatarId);
group.UpdatedAt = DateTime.UtcNow;
await DB.Default.SaveAsync(group, token);
// leaving is unfollowing, as joining was following
var groupUri = _localActors.FromGroup(group).Uri;
var personaUri = (await _localActors.FindById(LocalActorKind.Person, form.AvatarId, token))?.Uri;
var groupUri = localActors.FromGroup(group).Uri;
var personaUri = (await localActors.FindById(LocalActorKind.Person, form.AvatarId, token))?.Uri;
await DB.Default.DeleteAsync<Models.Social.Following>(f => f.AvatarId == form.AvatarId && f.TargetActorURI == groupUri);
if (personaUri != default)
await DB.Default.DeleteAsync<Follower>(f => f.LocalActorId == group.ID && f.LocalActorKind == LocalActorKind.Group && f.ActorURI == personaUri);
@@ -260,8 +242,8 @@ namespace PrivaPub.Services
}
catch (Exception ex)
{
_logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(LeaveGroup)}");
return result.Invalidate(_localizer["Something went wrong."], exception: ex);
logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(LeaveGroup)}");
return result.Invalidate(localizer["Something went wrong."], exception: ex);
}
}
@@ -272,13 +254,13 @@ namespace PrivaPub.Services
{
var group = await ManagedGroup(rootUserId, form.AvatarId, form.GroupId, token);
if (group == default)
return result.Invalidate(_localizer["Group not found."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Group not found."], StatusCodes.Status404NotFound);
var follower = await _dbEntities.Followers
var follower = await dbEntities.Followers
.Match(f => f.LocalActorId == group.ID && f.LocalActorKind == LocalActorKind.Group && f.ActorURI == form.MemberActorURI)
.ExecuteFirstAsync(token);
if (follower == default)
return result.Invalidate(_localizer["Request not found."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Request not found."], StatusCodes.Status404NotFound);
follower.IsAccepted = true;
await DB.Default.SaveAsync(follower, token);
@@ -288,7 +270,7 @@ namespace PrivaPub.Services
await DB.Default.SaveAsync(group, token);
}
var actor = _localActors.FromGroup(group);
var actor = localActors.FromGroup(group);
var follow = new System.Text.Json.Nodes.JsonObject
{
["id"] = follower.FollowActivityURI,
@@ -297,13 +279,13 @@ namespace PrivaPub.Services
["object"] = actor.Uri
};
var accept = ActivityPubRenderer.Accept(actor, follow, $"accept-{follower.ID}-{DateTime.UtcNow.Ticks}");
await _delivery.Enqueue(actor, new[] { follower.InboxURL }, accept, token);
await delivery.Enqueue(actor, new[] { follower.InboxURL }, accept, token: token);
return result;
}
catch (Exception ex)
{
_logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(ApproveMember)}");
return result.Invalidate(_localizer["Something went wrong."], exception: ex);
logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(ApproveMember)}");
return result.Invalidate(localizer["Something went wrong."], exception: ex);
}
}
@@ -312,12 +294,12 @@ namespace PrivaPub.Services
var result = new WebResult();
var group = string.IsNullOrEmpty(invitationCode)
? default
: await _dbEntities.Groups.Match(g => g.InvitationCode == invitationCode && !g.DeletionAt.HasValue).ExecuteFirstAsync(token);
: await dbEntities.Groups.Match(g => g.InvitationCode == invitationCode && !g.DeletionAt.HasValue).ExecuteFirstAsync(token);
if (group == default)
return result.Invalidate(_localizer["Invalid invitation."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Invalid invitation."], StatusCodes.Status404NotFound);
if (!string.IsNullOrEmpty(group.HashedInvitationPassword)
&& (string.IsNullOrEmpty(invitationPassword) || !_passwordHasher.Check(group.HashedInvitationPassword, invitationPassword).verified))
return result.Invalidate(_localizer["Invalid password."], StatusCodes.Status406NotAcceptable);
&& (string.IsNullOrEmpty(invitationPassword) || !passwordHasher.Check(group.HashedInvitationPassword, invitationPassword).verified))
return result.Invalidate(localizer["Invalid password."], StatusCodes.Status406NotAcceptable);
result.Data = group;
return result;
}
@@ -331,31 +313,31 @@ namespace PrivaPub.Services
{
var group = await ManagedGroup(rootUserId, avatarId, groupId, token);
if (group == default)
return result.Invalidate(_localizer["Group not found."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Group not found."], StatusCodes.Status404NotFound);
var members = new List<ViewGroupMember>();
foreach (var member in group.Members)
{
if (member.IsForeign)
{
var foreign = await _dbEntities.ForeignAvatars.Match(a => a.ActorURI == member.AvatarId).ExecuteFirstAsync(token);
var foreign = await dbEntities.ForeignAvatars.Match(a => a.ActorURI == member.AvatarId).ExecuteFirstAsync(token);
members.Add(Remote(member.AvatarId, foreign, member.Role, member.JoinedAt, pending: false));
continue;
}
if (await _localActors.FindById(LocalActorKind.Person, member.AvatarId, token) is { } local)
if (await localActors.FindById(LocalActorKind.Person, member.AvatarId, token) is { } local)
members.Add(new ViewGroupMember
{
ActorUri = local.Uri, Handle = local.Handle, Name = local.Name ?? local.UserName, PictureUrl = local.PictureURL,
IsLocal = true, Role = member.Role.ToString().ToLowerInvariant(), Since = member.JoinedAt
});
}
var asking = await _dbEntities.Followers
var asking = await dbEntities.Followers
.Match(f => f.LocalActorId == group.ID && f.LocalActorKind == LocalActorKind.Group && !f.IsAccepted)
.Sort(f => f.CreationDate, Order.Ascending)
.ExecuteAsync(token);
foreach (var request in asking.Where(r => members.All(m => m.ActorUri != r.ActorURI)))
{
var foreign = await _dbEntities.ForeignAvatars.Match(a => a.ActorURI == request.ActorURI).ExecuteFirstAsync(token);
var foreign = await dbEntities.ForeignAvatars.Match(a => a.ActorURI == request.ActorURI).ExecuteFirstAsync(token);
members.Add(Remote(request.ActorURI, foreign, GroupRole.Member, request.CreationDate, pending: true));
}
result.Data = members;
@@ -363,8 +345,8 @@ namespace PrivaPub.Services
}
catch (Exception ex)
{
_logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(GetMembers)}");
return result.Invalidate(_localizer["Something went wrong."], exception: ex);
logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(GetMembers)}");
return result.Invalidate(localizer["Something went wrong."], exception: ex);
}
}
@@ -374,7 +356,7 @@ namespace PrivaPub.Services
ActorUri = actorUri,
Handle = foreign == default ? actorUri : $"{foreign.UserName}@{foreign.Domain}",
Name = foreign?.Name ?? foreign?.UserName,
PictureUrl = _proxy.Wrap(foreign?.PictureURL),
PictureUrl = mediaProxy.Wrap(foreign?.PictureURL),
IsPending = pending,
Role = role.ToString().ToLowerInvariant(),
Since = since
@@ -388,20 +370,20 @@ namespace PrivaPub.Services
{
var group = await ManagedGroup(rootUserId, form.AvatarId, form.GroupId, token);
if (group == default)
return result.Invalidate(_localizer["Group not found."], StatusCodes.Status404NotFound);
var request = await _dbEntities.Followers
return result.Invalidate(localizer["Group not found."], StatusCodes.Status404NotFound);
var request = await dbEntities.Followers
.Match(f => f.LocalActorId == group.ID && f.LocalActorKind == LocalActorKind.Group && f.ActorURI == form.MemberActorURI && !f.IsAccepted)
.ExecuteFirstAsync(token);
if (request == default)
return result.Invalidate(_localizer["Request not found."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Request not found."], StatusCodes.Status404NotFound);
await DB.Default.DeleteAsync<Follower>(request.ID);
await RejectFollow(group, request, token);
return result;
}
catch (Exception ex)
{
_logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(RejectMember)}");
return result.Invalidate(_localizer["Something went wrong."], exception: ex);
logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(RejectMember)}");
return result.Invalidate(localizer["Something went wrong."], exception: ex);
}
}
@@ -414,27 +396,27 @@ namespace PrivaPub.Services
{
var group = await ManagedGroup(rootUserId, form.AvatarId, form.GroupId, token);
if (group == default)
return result.Invalidate(_localizer["Group not found."], StatusCodes.Status404NotFound);
var localMember = await _localActors.FindByUri(form.MemberActorURI, token);
return result.Invalidate(localizer["Group not found."], StatusCodes.Status404NotFound);
var localMember = await localActors.FindByUri(form.MemberActorURI, token);
var member = group.Members.FirstOrDefault(m => localMember is { Kind: LocalActorKind.Person }
? !m.IsForeign && m.AvatarId == localMember.Id
: m.IsForeign && m.AvatarId == form.MemberActorURI);
if (member == default)
return result.Invalidate(_localizer["Member not found."], StatusCodes.Status404NotFound);
return result.Invalidate(localizer["Member not found."], StatusCodes.Status404NotFound);
if (member.Role == GroupRole.Owner)
return result.Invalidate(_localizer["The owner cannot leave the group."]);
return result.Invalidate(localizer["The owner cannot leave the group."]);
group.Members.Remove(member);
group.UpdatedAt = DateTime.UtcNow;
await DB.Default.SaveAsync(group, token);
var follower = await _dbEntities.Followers
var follower = await dbEntities.Followers
.Match(f => f.LocalActorId == group.ID && f.LocalActorKind == LocalActorKind.Group && f.ActorURI == form.MemberActorURI)
.ExecuteFirstAsync(token);
if (follower != default)
await DB.Default.DeleteAsync<Follower>(follower.ID);
if (localMember is { Kind: LocalActorKind.Person })
{
var groupUri = _localActors.FromGroup(group).Uri;
var groupUri = localActors.FromGroup(group).Uri;
await DB.Default.DeleteAsync<Models.Social.Following>(f => f.AvatarId == localMember.Id && f.TargetActorURI == groupUri);
}
else if (follower != default)
@@ -443,8 +425,8 @@ namespace PrivaPub.Services
}
catch (Exception ex)
{
_logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(RemoveMember)}");
return result.Invalidate(_localizer["Something went wrong."], exception: ex);
logger.LogError(ex, $"{nameof(GroupUsersService)}.{nameof(RemoveMember)}");
return result.Invalidate(localizer["Something went wrong."], exception: ex);
}
}
@@ -452,7 +434,7 @@ namespace PrivaPub.Services
{
if (string.IsNullOrEmpty(follower.InboxURL))
return;
var actor = _localActors.FromGroup(group);
var actor = localActors.FromGroup(group);
var follow = new System.Text.Json.Nodes.JsonObject
{
["id"] = follower.FollowActivityURI,
@@ -462,14 +444,14 @@ namespace PrivaPub.Services
};
var reject = ActivityPubRenderer.Accept(actor, follow, $"reject-{follower.ID}-{DateTime.UtcNow.Ticks}");
reject["type"] = "Reject";
await _delivery.Enqueue(actor, new[] { follower.InboxURL }, reject, token);
await delivery.Enqueue(actor, new[] { follower.InboxURL }, reject, token: token);
}
async Task<GroupEntity> ManagedGroup(string rootUserId, string avatarId, string groupId, CancellationToken token)
{
if (!await OwnsAvatar(rootUserId, avatarId, token))
return default;
var group = await _dbEntities.Groups.MatchID(groupId).ExecuteFirstAsync(token);
var group = await dbEntities.Groups.MatchID(groupId).ExecuteFirstAsync(token);
if (group == default || group.DeletionAt.HasValue)
return default;
var role = group.Members.FirstOrDefault(m => !m.IsForeign && m.AvatarId == avatarId)?.Role;
@@ -479,7 +461,7 @@ namespace PrivaPub.Services
// a suspended persona does nothing in its groups (R6)
async Task<bool> OwnsAvatar(string rootUserId, string avatarId, CancellationToken token) =>
!string.IsNullOrEmpty(rootUserId) && !string.IsNullOrEmpty(avatarId) && !Domain.Moderation.Restrictions.IsSuspended(avatarId)
&& await _dbEntities.RootToAvatars.Match(ra => ra.RootId == rootUserId && ra.AvatarId == avatarId).ExecuteAnyAsync(token);
&& await dbEntities.RootToAvatars.Match(ra => ra.RootId == rootUserId && ra.AvatarId == avatarId).ExecuteAnyAsync(token);
static PostingPolicy? Policy(string value) => value?.ToLowerInvariant() switch
{
@@ -493,7 +475,7 @@ namespace PrivaPub.Services
ViewGroup ToView(GroupEntity group, string avatarId)
{
var actor = _localActors.FromGroup(group);
var actor = localActors.FromGroup(group);
var isManager = group.Members.Any(m => !m.IsForeign && m.AvatarId == avatarId && m.Role is GroupRole.Owner or GroupRole.Moderator);
return new ViewGroup
{