-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from argon-chat/feature/servers
Server related grains
- Loading branch information
Showing
25 changed files
with
532 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Argon.Api.Attributes; | ||
|
||
[AttributeUsage(AttributeTargets.Method)] | ||
public class InjectUsernameAttribute : Attribute | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,30 @@ | ||
namespace Argon.Sfu; | ||
|
||
using LiveKit.Proto; | ||
using MemoryPack; | ||
|
||
public record struct EphemeralChannelInfo(ArgonChannelId channelId, string sid, Room room); | ||
|
||
public record struct RealtimeToken(string value); | ||
[Serializable] | ||
[GenerateSerializer] | ||
[MemoryPackable] | ||
[Alias(nameof(RealtimeToken))] | ||
public partial record struct RealtimeToken(string value); | ||
|
||
public record struct ArgonUserId(Guid id) | ||
{ | ||
public string ToRawIdentity() => id.ToString("N"); | ||
public string ToRawIdentity() | ||
{ | ||
return id.ToString("N"); | ||
} | ||
} | ||
|
||
public record struct ArgonServerId(Guid id); | ||
|
||
public record struct ArgonChannelId(ArgonServerId serverId, Guid channelId) | ||
{ | ||
public string ToRawRoomId() => $"{serverId.id:N}:{channelId:N}"; | ||
public string ToRawRoomId() | ||
{ | ||
return $"{serverId.id:N}:{channelId:N}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Argon.Api.Filters; | ||
|
||
using Microsoft.AspNetCore.Mvc.Filters; | ||
|
||
public class InjectUsernameFilter : IActionFilter | ||
{ | ||
public void OnActionExecuting(ActionExecutingContext context) | ||
{ | ||
var username = context.HttpContext.User.Claims.FirstOrDefault(cl => cl.Type == "username")?.Value; | ||
if (!string.IsNullOrWhiteSpace(username)) | ||
context.ActionArguments["username"] = username; | ||
} | ||
|
||
public void OnActionExecuted(ActionExecutedContext context) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Argon.Api.Grains.Interfaces; | ||
|
||
using Persistence.States; | ||
using Sfu; | ||
|
||
public interface IChannelManager : IGrainWithGuidKey | ||
{ | ||
[Alias("CreateChannel")] | ||
Task<ChannelStorage> CreateChannel(ChannelStorage channel); | ||
|
||
[Alias("GetChannel")] | ||
Task<ChannelStorage> GetChannel(); | ||
|
||
[Alias("JoinLink")] | ||
Task<RealtimeToken> JoinLink(Guid userId, Guid serverId); | ||
|
||
[Alias("UpdateChannel")] | ||
Task<ChannelStorage> UpdateChannel(ChannelStorage channel); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace Argon.Api.Grains.Interfaces; | ||
|
||
using Persistence.States; | ||
using Sfu; | ||
|
||
public interface IServerManager : IGrainWithGuidKey | ||
{ | ||
[Alias("CreateServer")] | ||
Task<ServerStorage> CreateServer(string name, string description, Guid userId); | ||
|
||
[Alias("CreateJoinLink")] | ||
Task<string> CreateJoinLink(); | ||
|
||
[Alias("AddUser")] | ||
Task AddUser(UserToServerRelation Relation); | ||
|
||
[Alias("GetChannels")] | ||
Task<IEnumerable<ChannelStorage>> GetChannels(); | ||
|
||
[Alias("AddChannel")] | ||
Task<ChannelStorage> AddChannel(ChannelStorage channel); | ||
|
||
[Alias("GetChannel")] | ||
Task<ChannelStorage> GetChannel(Guid channelId); | ||
|
||
[Alias("GetServer")] | ||
Task<ServerStorage> GetServer(); | ||
|
||
[Alias("JoinChannel")] | ||
Task<RealtimeToken> JoinChannel(Guid userId, Guid channelId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace Argon.Api.Grains.Persistence.States; | ||
|
||
using MemoryPack; | ||
|
||
[GenerateSerializer] | ||
[Serializable] | ||
[MemoryPackable] | ||
[Alias(nameof(ChannelStorage))] | ||
public sealed partial record ChannelStorage | ||
{ | ||
[Id(0)] public Guid Id { get; set; } = Guid.Empty; | ||
[Id(1)] public string Name { get; set; } = string.Empty; | ||
[Id(2)] public string Description { get; set; } = string.Empty; | ||
[Id(3)] public Guid CreatedBy { get; set; } = Guid.Empty; | ||
[Id(4)] public ChannelType ChannelType { get; set; } = ChannelType.Text; | ||
[Id(5)] public ServerRole AccessLevel { get; set; } = ServerRole.User; | ||
[Id(6)] public DateTime CreatedAt { get; } = DateTime.UtcNow; | ||
[Id(7)] public DateTime UpdatedAt { get; set; } = DateTime.UtcNow; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Argon.Api.Grains.Persistence.States; | ||
|
||
[GenerateSerializer] | ||
[Serializable] | ||
[Alias(nameof(ChannelType))] | ||
public enum ChannelType | ||
{ | ||
Text, | ||
Voice, | ||
Announcement | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/Argon.Api/Grains.Persistence.States/ServerChannelsStore.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Argon.Api.Grains.Persistence.States; | ||
|
||
using MemoryPack; | ||
|
||
[GenerateSerializer] | ||
[Serializable] | ||
[MemoryPackable] | ||
[Alias(nameof(ServerChannelsStore))] | ||
public sealed partial record ServerChannelsStore | ||
{ | ||
[Id(0)] public List<Guid> Channels { get; private set; } = []; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Argon.Api.Grains.Persistence.States; | ||
|
||
[GenerateSerializer] | ||
[Serializable] | ||
[Alias(nameof(ServerRole))] | ||
public enum ServerRole : ushort // TODO: sort out roles and how we actually want to handle them | ||
{ | ||
User, | ||
Admin, | ||
Owner | ||
} |
Oops, something went wrong.