Skip to content

Commit

Permalink
(#125) ntrada update
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintAngeLs committed May 16, 2024
1 parent 1195d28 commit a9f3df2
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 11 deletions.
32 changes: 27 additions & 5 deletions MiniSpace.APIGateway/src/MiniSpace.APIGateway/ntrada.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,41 @@ modules:
method: POST
use: downstream
downstream: notifications-service/notifications
auth: true
auth: true

- upstream: /{userId}
method: GET
use: downstream
downstream: notifications-service/notifications/{userId}
auth: true
auth: true

- upstream: /{notificationId}
method: GET
use: downstream
downstream: notifications-service/notifications/{notificationId}
auth: true

- upstream: /{notificationId}
method: DELETE
use: downstream
downstream: notifications-service/notifications/{notificationId}
# afterDispatch: (cmd, ctx) => ctx.Response.NoContent()
auth: true

- upstream: /{notificationId}/status
method: PUT
use: downstream
downstream: notifications-service/notifications/{notificationId}/status
auth: true

services:
notifications-service:
localUrl: localhost:5006
url: notifications-service
url: notifications-service







Expand Down Expand Up @@ -657,5 +680,4 @@ modules:
organizations-service:
localUrl: localhost:5015
url: organizations-service



Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniSpace.Services.Events.Application", "MiniSpace.Services.Events.Application.csproj", "{77BD0055-5CC1-48B3-AC90-39D226577330}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{77BD0055-5CC1-48B3-AC90-39D226577330}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77BD0055-5CC1-48B3-AC90-39D226577330}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77BD0055-5CC1-48B3-AC90-39D226577330}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77BD0055-5CC1-48B3-AC90-39D226577330}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B7D3307B-9123-41EE-AF15-A4883F0038BB}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniSpace.Services.Events.Infrastructure", "MiniSpace.Services.Events.Infrastructure.csproj", "{86A0DEA7-85B9-4D80-B43C-B41C8D985D54}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{86A0DEA7-85B9-4D80-B43C-B41C8D985D54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{86A0DEA7-85B9-4D80-B43C-B41C8D985D54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{86A0DEA7-85B9-4D80-B43C-B41C8D985D54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{86A0DEA7-85B9-4D80-B43C-B41C8D985D54}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {69270B46-EAB0-4ABB-9203-6207ED340CD3}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ public static IApplicationBuilder UseInfrastructure(this IApplicationBuilder app
.SubscribeCommand<InviteFriend>()
.SubscribeCommand<PendingFriendAccept>()
.SubscribeCommand<PendingFriendDecline>()
.SubscribeEvent<FriendRequestCreated>()
.SubscribeEvent<FriendRequestSent>()
.SubscribeEvent<Application.Events.FriendAdded>()
.SubscribeEvent<Application.Events.FriendRemoved>()
.SubscribeEvent<PendingFriendAccepted>()
.SubscribeEvent<PendingFriendDeclined>()
.SubscribeEvent<FriendRequestCreated>()
.SubscribeEvent<FriendRequestSent>()
.SubscribeEvent<UserStatusUpdated>();

return app;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using MiniSpace.Services.Notifications.Core.Entities;

namespace MiniSpace.Services.Notifications.Application.Dto
{
public class FriendRequestDto
{
public Guid Id { get; set; }
public Guid InviterId { get; set; }
public Guid InviteeId { get; set; }
public DateTime RequestedAt { get; set; }
public FriendState State { get; set; }
public Guid StudentId { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace MiniSpace.Services.Notifications.Application.Events.External
{
[Message("notifications")]
[Message("friends")]
public class FriendRequestCreated : IEvent
{
public Guid RequesterId { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace MiniSpace.Services.Notifications.Application.Services.Clients
{
public interface IFriendsServiceClient
{
Task<IEnumerable<FriendDto>> GetAsync(Guid studentId);
Task<IEnumerable<FriendDto>> GetFriendsAsync(Guid studentId);
Task<IEnumerable<FriendRequestDto>> GetRequestsAsync(Guid studentId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace MiniSpace.Services.Notifications.Core.Entities
{
public enum FriendState
{
Unknown,
Requested,
Accepted,
Declined,
Blocked,
Cancelled,
Confirmed
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
using MiniSpace.Services.Notifications.Infrastructure.Mongo.Repositories;
using MiniSpace.Services.Notifications.Infrastructure.Services;
using MiniSpace.Services.Notifications.Infrastructure;
using MiniSpace.Services.Notifications.Application.Services.Clients;
using MiniSpace.Services.Notifications.Infrastructure.Services.Clients;

namespace MiniSpace.Services.Notifications.Infrastructure
{
Expand All @@ -53,6 +55,7 @@ public static IConveyBuilder AddInfrastructure(this IConveyBuilder builder)
builder.Services.AddSingleton<IEventMapper, EventMapper>();
builder.Services.AddTransient<IMessageBroker, MessageBroker>();
builder.Services.AddTransient<IAppContextFactory, AppContextFactory>();
builder.Services.AddTransient<IFriendsServiceClient, FriendsServiceClient>();
builder.Services.AddTransient(ctx => ctx.GetRequiredService<IAppContextFactory>().Create());
builder.Services.TryDecorate(typeof(ICommandHandler<>), typeof(OutboxCommandHandlerDecorator<>));
builder.Services.TryDecorate(typeof(IEventHandler<>), typeof(OutboxEventHandlerDecorator<>));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public FriendsServiceClient(IHttpClient httpClient, HttpClientOptions options)

public Task<IEnumerable<FriendDto>> GetAsync(Guid studentId)
=> _httpClient.GetAsync<IEnumerable<FriendDto>>($"{_url}/friends/{studentId}");
public Task<IEnumerable<FriendDto>> GetFriendsAsync(Guid studentId)
=> _httpClient.GetAsync<IEnumerable<FriendDto>>($"{_url}/friends/{studentId}");
public Task<IEnumerable<FriendRequestDto>> GetRequestsAsync(Guid studentId)
=> _httpClient.GetAsync<IEnumerable<FriendRequestDto>>($"{_url}/friends/requests/{studentId}");

// public Task<IEnumerable<FriendRequestDto>> GetSentFriendRequestsAsync(Guid studentId)
// => _httpClient.GetAsync<IEnumerable<FriendRequestDto>>($"{_url}/friends/requests/sent/{studentId}");
}
}

0 comments on commit a9f3df2

Please sign in to comment.