Skip to content

Commit

Permalink
Refactor user interaction interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
urumo committed Oct 27, 2024
1 parent 32a1ce6 commit 4049e9f
Showing 1 changed file with 132 additions and 43 deletions.
175 changes: 132 additions & 43 deletions src/Argon.Contracts/IUserInteraction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,154 @@ namespace Argon.Contracts;

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

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

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

[DataContract, MemoryPackable(GenerateType.VersionTolerant), MessagePackObject]
[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
[property: DataMember(Order = 0)]
[property: MemoryPackOrder(0)]
[property: Key(0)]
Guid Id,
[property: DataMember(Order = 1)]
[property: MemoryPackOrder(1)]
[property: Key(1)]
string Username,
[property: DataMember(Order = 2)]
[property: MemoryPackOrder(2)]
[property: Key(2)]
string AvatarUrl,
[property: DataMember(Order = 3)]
[property: MemoryPackOrder(3)]
[property: Key(3)]
DateTime CreatedAt,
[property: DataMember(Order = 4)]
[property: MemoryPackOrder(4)]
[property: Key(4)]
DateTime UpdatedAt
);

[DataContract, MemoryPackable(GenerateType.VersionTolerant), MessagePackObject]
[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
);
[property: DataMember(Order = 0)]
[property: MemoryPackOrder(0)]
[property: Key(0)]
string Name,
[property: DataMember(Order = 1)]
[property: MemoryPackOrder(1)]
[property: Key(1)]
string Description,
[property: DataMember(Order = 2)]
[property: MemoryPackOrder(2)]
[property: Key(2)]
string AvatarUrl
);

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

[DataContract, MemoryPackable(GenerateType.VersionTolerant), MessagePackObject]
[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
[property: DataMember(Order = 0)]
[property: MemoryPackOrder(0)]
[property: Key(0)]
Guid Id,
[property: DataMember(Order = 1)]
[property: MemoryPackOrder(1)]
[property: Key(1)]
string Name,
[property: DataMember(Order = 2)]
[property: MemoryPackOrder(2)]
[property: Key(2)]
string Description,
[property: DataMember(Order = 3)]
[property: MemoryPackOrder(3)]
[property: Key(3)]
string CreatedBy,
[property: DataMember(Order = 4)]
[property: MemoryPackOrder(4)]
[property: Key(4)]
string ChannelType,
[property: DataMember(Order = 5)]
[property: MemoryPackOrder(5)]
[property: Key(5)]
string AccessLevel,
[property: DataMember(Order = 6)]
[property: MemoryPackOrder(6)]
[property: Key(6)]
DateTime CreatedAt,
[property: DataMember(Order = 7)]
[property: MemoryPackOrder(7)]
[property: Key(7)]
DateTime UpdatedAt
// TODO: all users currently connected to this channel
);
);

[DataContract, MemoryPackable(GenerateType.VersionTolerant), MessagePackObject]
[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
);
[property: DataMember(Order = 0)]
[property: MemoryPackOrder(0)]
[property: Key(0)]
Guid ServerId,
[property: DataMember(Order = 1)]
[property: MemoryPackOrder(1)]
[property: Key(1)]
Guid ChannelId
);

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

[property: DataMember(Order = 0)]
[property: MemoryPackOrder(0)]
[property: Key(0)]
string Token
);

0 comments on commit 4049e9f

Please sign in to comment.