Skip to content

Commit

Permalink
Add IUserInteraction interface and related data contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
urumo committed Oct 27, 2024
1 parent 684548f commit 32a1ce6
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions src/Argon.Contracts/IUserInteraction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
namespace Argon.Contracts;

using System.Runtime.Serialization;
using ActualLab.Rpc;
using MemoryPack;
using MessagePack;

public interface IUserInteraction : IRpcService
{
Task<UserResponse> GetMe(string username);
Task<ServerResponse> CreateServer(string username, CreateServerRequest request);
Task<List<ServerResponse>> GetServers(string username);

Task<List<ServerDetailsResponse>> GetServerDetails(string username);

// Task CreateChannel(string username);
Task<ChannelJoinResponse> JoinChannel(string username, ChannelJoinRequest request);
}

[DataContract, MemoryPackable(GenerateType.VersionTolerant), MessagePackObject]
public sealed partial record UserResponse(
[property: DataMember(Order = 0), MemoryPackOrder(0), Key(0)] Guid Id,
[property: DataMember(Order = 1), MemoryPackOrder(1), Key(1)] string Username,
[property: DataMember(Order = 2), MemoryPackOrder(2), Key(2)] string AvatarUrl,
[property: DataMember(Order = 3), MemoryPackOrder(3), Key(3)] DateTime CreatedAt,
[property: DataMember(Order = 4), MemoryPackOrder(4), Key(4)] DateTime UpdatedAt
);

[DataContract, MemoryPackable(GenerateType.VersionTolerant), MessagePackObject]
public sealed partial record CreateServerRequest(
[property: DataMember(Order = 0), MemoryPackOrder(0), Key(0)] string Name,
[property: DataMember(Order = 1), MemoryPackOrder(1), Key(1)] string Description,
[property: DataMember(Order = 2), MemoryPackOrder(2), Key(2)] string AvatarUrl
);

[DataContract, MemoryPackable(GenerateType.VersionTolerant), MessagePackObject]
public sealed partial record ServerResponse(
[property: DataMember(Order = 0), MemoryPackOrder(0), Key(0)] Guid Id,
[property: DataMember(Order = 1), MemoryPackOrder(1), Key(1)] string Name,
[property: DataMember(Order = 2), MemoryPackOrder(2), Key(2)] string Description,
[property: DataMember(Order = 3), MemoryPackOrder(3), Key(3)] string AvatarUrl,
[property: DataMember(Order = 4), MemoryPackOrder(4), Key(4)] List<Guid> Channels,
[property: DataMember(Order = 5), MemoryPackOrder(5), Key(5)] DateTime CreatedAt,
[property: DataMember(Order = 6), MemoryPackOrder(6), Key(6)] DateTime UpdatedAt
// TODO: all users of the server with their statuses(online/offline/in channel)
);

[DataContract, MemoryPackable(GenerateType.VersionTolerant), MessagePackObject]
public sealed partial record ServerDetailsResponse(
[property: DataMember(Order = 0), MemoryPackOrder(0), Key(0)] Guid Id,
[property: DataMember(Order = 1), MemoryPackOrder(1), Key(1)] string Name,
[property: DataMember(Order = 2), MemoryPackOrder(2), Key(2)] string Description,
[property: DataMember(Order = 3), MemoryPackOrder(3), Key(3)] string CreatedBy,
[property: DataMember(Order = 4), MemoryPackOrder(4), Key(4)] string ChannelType,
[property: DataMember(Order = 5), MemoryPackOrder(5), Key(5)] string AccessLevel,
[property: DataMember(Order = 6), MemoryPackOrder(6), Key(6)] DateTime CreatedAt,
[property: DataMember(Order = 7), MemoryPackOrder(7), Key(7)] DateTime UpdatedAt
// TODO: all users currently connected to this channel
);

[DataContract, MemoryPackable(GenerateType.VersionTolerant), MessagePackObject]
public sealed partial record ChannelJoinRequest(
[property: DataMember(Order = 0), MemoryPackOrder(0), Key(0)] Guid ServerId,
[property: DataMember(Order = 1), MemoryPackOrder(1), Key(1)] Guid ChannelId
);

[DataContract, MemoryPackable(GenerateType.VersionTolerant), MessagePackObject]
public sealed partial record ChannelJoinResponse(
[property: DataMember(Order = 0), MemoryPackOrder(0), Key(0)] string Token
);

0 comments on commit 32a1ce6

Please sign in to comment.