[backend/core] Disallow following of system users

This commit is contained in:
Laura Hausmann 2024-09-28 00:37:36 +02:00
parent df26db0585
commit 4cfd4de389
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 4 additions and 2 deletions

View file

@ -124,7 +124,7 @@ public class User : IEntity
[Column("isBot")] [Column("isBot")]
public bool IsBot { get; set; } public bool IsBot { get; set; }
[Column("isSystem")] public bool IsSystem { get; set; } [Column("isSystem")] public bool IsSystemUser { get; set; }
[Column("isRelayActor")] public bool IsRelayActor { get; set; } [Column("isRelayActor")] public bool IsRelayActor { get; set; }

View file

@ -80,7 +80,7 @@ public class SystemUserService(ILogger<SystemUserService> logger, DatabaseContex
IsLocked = true, IsLocked = true,
IsExplorable = false, IsExplorable = false,
IsBot = true, IsBot = true,
IsSystem = true IsSystemUser = true
}; };
var userKeypair = new UserKeypair var userKeypair = new UserKeypair

View file

@ -660,6 +660,8 @@ public class UserService(
throw GracefulException.UnprocessableEntity("You cannot follow yourself"); throw GracefulException.UnprocessableEntity("You cannot follow yourself");
if (follower.IsRemoteUser && followee.IsRemoteUser) if (follower.IsRemoteUser && followee.IsRemoteUser)
throw GracefulException.UnprocessableEntity("Cannot process follow between two remote users"); throw GracefulException.UnprocessableEntity("Cannot process follow between two remote users");
if (follower.IsSystemUser || followee.IsSystemUser)
throw GracefulException.UnprocessableEntity("System users cannot have follow relationships");
Guid? relationshipId = null; Guid? relationshipId = null;