Skip to content

Commit

Permalink
(#394) communication: register chat service
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintAngeLs committed Aug 29, 2024
1 parent b966789 commit a8baaaf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public static IConveyBuilder AddInfrastructure(this IConveyBuilder builder)

builder.Services.AddTransient<IOrganizationChatsRepository, OrganizationChatsRepository>();
builder.Services.AddTransient<IUserChatsRepository, UserChatsRepository>();
builder.Services.AddTransient<ICommunicationService, CommunicationService>();

builder.Services.AddSingleton<IDateTimeProvider, DateTimeProvider>();
builder.Services.AddTransient<IMessageBroker, MessageBroker>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,16 @@ public async Task DeleteChatAsync(Guid userId, Guid chatId)
userChats.Chats.Remove(chat);
await UpdateAsync(userChats);
}

public async Task<List<Guid>> GetParticipantIdsByChatIdAsync(Guid chatId)
{
var document = await _repository.Collection
.Find(x => x.Chats.Any(c => c.Id == chatId))
.FirstOrDefaultAsync();

var chatDocument = document?.Chats.FirstOrDefault(c => c.Id == chatId);
return chatDocument?.ParticipantIds ?? new List<Guid>();
}

}
}

0 comments on commit a8baaaf

Please sign in to comment.