Skip to content

Commit

Permalink
Merge pull request #341 from SaintAngeLs/organizations_service
Browse files Browse the repository at this point in the history
#330 udpate orgnisation servcie, layout refactoring to mudblazor
  • Loading branch information
SaintAngeLs authored Aug 2, 2024
2 parents 7a21111 + f2884bb commit b9098b6
Show file tree
Hide file tree
Showing 239 changed files with 7,090 additions and 3,822 deletions.
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github: @SaintAngeLs
patreon: patreon.com/SaintAngeLs
github: SaintAngeLs
patreon: SaintAngeLs
9 changes: 3 additions & 6 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repository:
name: distributed_minispace

# A short description of the repository that will show up on GitHub
description: "Microservices-based social network built with .NET8 and ASP .NET Core Blazor Server, employing DDD principles."
description: "Microservices-based social network built with .NET8 and ASP .NET Core Blazor Server, employing DDD principles. Offers a scalable and efficient technical solution for social media applications enginine, leveraging CQRS, MongoDB, SignalR, .NET ML, Elasticsearch and event-driven architecture to ensure high performance and reliability."

# A URL with more information about the repository
homepage: https://minispace.itsharppro.com
Expand Down Expand Up @@ -113,11 +113,8 @@ milestones:
state: open

# Collaborators: give specific users access to this repository.
collaborators:
- username: eggwhat
permission: push
- username: an2508374
permission: push
# collaborators:


# Note: `permission` is only valid on organization-owned repositories.
# The permission to grant the collaborator. Can be one of:
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/build_microservices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ jobs:
include:
- project: 'MiniSpace.APIGateway/src/MiniSpace.APIGateway'
- project: 'MiniSpace.Services.Identity/src/MiniSpace.Services.Identity.Api'
test_dir: 'MiniSpace.Services.Identity/tests'
- project: 'MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Api'
test_dir: 'MiniSpace.Services.Posts/tests'
# test_dir: 'MiniSpace.Services.Identity/tests'
- project: 'MiniSpace.Services.Comments/src/MiniSpace.Services.Comments.Api'
test_dir: 'MiniSpace.Services.Comments/tests'
# - project: 'MiniSpace.Services.Organizations/src/MiniSpace.Services.Organizations.Api'
# test_dir: 'MiniSpace.Services.Organizations/tests'
# test_dir: 'MiniSpace.Services.Comments/tests'
- project: 'MiniSpace.Services.Organizations/src/MiniSpace.Services.Organizations.Api'
# test_dir: 'MiniSpace.Services.Organizations/tests'
- project: 'MiniSpace.Services.Posts/src/MiniSpace.Services.Posts.Api'
test_dir: 'MiniSpace.Services.Posts/tests'
# test_dir: 'MiniSpace.Services.Posts/tests'
- project: 'MiniSpace.Services.Email/src/MiniSpace.Services.Email.Api'
- project: 'MiniSpace.Services.Notifications/src/MiniSpace.Services.Notifications.Api'
- project: 'MiniSpace.Services.Reactions/src/MiniSpace.Services.Reactions.Api'
test_dir: 'MiniSpace.Services.Reactions/tests'
# test_dir: 'MiniSpace.Services.Reactions/tests'
- project: 'MiniSpace.Services.Events/src/MiniSpace.Services.Events.Api'
test_dir: 'MiniSpace.Services.Events/tests'
# test_dir: 'MiniSpace.Services.Events/tests'
- project: 'MiniSpace.Services.Students/src/MiniSpace.Services.Students.Api'
test_dir: 'MiniSpace.Services.Students/tests'
# test_dir: 'MiniSpace.Services.Students/tests'
- project: 'MiniSpace.Web/src/MiniSpace.Web'
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion MiniSpace.APIGateway/scripts/start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
export ASPNETCORE_ENVIRONMENT=local
cd src/MiniSpace.APIGateway
cd ../src/MiniSpace.APIGateway
dotnet run
121 changes: 93 additions & 28 deletions MiniSpace.APIGateway/src/MiniSpace.APIGateway/ntrada.yml
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,14 @@ modules:
downstream: students-service/students/{studentId}/notifications
auth: true

- upstream: /{studentId}/languages-and-interests
method: PUT
use: downstream
downstream: students-service/students/{studentId}/languages-and-interests
bind:
- studentId:{studentId}
auth: true

services:
students-service:
localUrl: localhost:5007
Expand Down Expand Up @@ -792,6 +800,10 @@ modules:
use: downstream
downstream: mediafiles-service/media-files
auth: true
requestSizeLimit: 50_000_000 # Example: Limit to 50 MB
formLimits:
multipartBodyLengthLimit: 50_000_000 # Optional: Same as above to ensure large files are allowed


- upstream: /{mediaFileId}
method: GET
Expand Down Expand Up @@ -825,6 +837,47 @@ modules:
downstream: organizations-service/organizations
auth: true

- upstream: /{organizationId}
method: GET
use: downstream
downstream: organizations-service/organizations/{organizationId}

- upstream: /{organizationId}/details
method: GET
use: downstream
downstream: organizations-service/organizations/{organizationId}/details

- upstream: /root
method: GET
use: downstream
downstream: organizations-service/organizations/root

- upstream: /{organizationId}/children
method: GET
use: downstream
downstream: organizations-service/organizations/{organizationId}/children

- upstream: /{organizationId}/children/all
method: GET
use: downstream
downstream: organizations-service/organizations/{organizationId}/children/all

- upstream: /users/{userId}/organizations
method: GET
use: downstream
downstream: organizations-service/users/{userId}/organizations
auth: true
bind:
- userId: {userId}

- upstream: /{organizationId}/details/gallery-users
method: GET
use: downstream
downstream: organizations-service/organizations/{organizationId}/details/gallery-users
bind:
- organizationId: {organizationId}


- upstream: /{organizationId}
method: DELETE
use: downstream
Expand All @@ -836,52 +889,64 @@ modules:
use: downstream
downstream: organizations-service/organizations/{organizationId}/children
auth: true
- upstream: /{organizationId}/organizer

- upstream: /{organizationId}/roles
method: POST
use: downstream
downstream: organizations-service/organizations/{organizationId}/organizer
downstream: organizations-service/organizations/{organizationId}/roles
auth: true
- upstream: /{organizationId}/organizer/{organizerId}
method: DELETE

- upstream: /{organizationId}/roles/{roleId}/permissions
method: PUT
use: downstream
downstream: organizations-service/organizations/{organizationId}/organizer/{organizerId}
downstream: organizations-service/organizations/{organizationId}/roles/{roleId}/permissions
auth: true
- upstream: /{organizationId}
method: GET

- upstream: /{organizationId}/invite
method: POST
use: downstream
downstream: organizations-service/organizations/{organizationId}

- upstream: /{organizationId}/details
method: GET
downstream: organizations-service/organizations/{organizationId}/invite
auth: true

- upstream: /{organizationId}/roles/{memberId}
method: POST
use: downstream
downstream: organizations-service/organizations/{organizationId}/details
downstream: organizations-service/organizations/{organizationId}/roles/{memberId}
auth: true

- upstream: /root
method: GET
- upstream: /{organizationId}/privacy
method: POST
use: downstream
downstream: organizations-service/organizations/root

- upstream: /{organizationId}/children
method: GET
downstream: organizations-service/organizations/{organizationId}/privacy
auth: true

- upstream: /{organizationId}/settings
method: PUT
use: downstream
downstream: organizations-service/organizations/{organizationId}/children
downstream: organizations-service/organizations/{organizationId}/settings
auth: true

- upstream: /{organizationId}/children/all
method: GET
- upstream: /{organizationId}/visibility
method: PUT
use: downstream
downstream: organizations-service/organizations/{organizationId}/children/all
downstream: organizations-service/organizations/{organizationId}/visibility
auth: true

- upstream: /organizer/{organizerId}
method: GET
- upstream: /{organizationId}/feed
method: PUT
use: downstream
downstream: organizations-service/organizations/{organizationId}/feed
auth: true

- upstream: /{organizationId}
method: PUT
use: downstream
downstream: organizations-service/organizations/organizer/{organizerId}
downstream: organizations-service/organizations/{organizationId}
auth: true

services:
organizations-service:
localUrl: localhost:5015
url: organizations-service


Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using MiniSpace.Services.MediaFiles.Infrastructure;
using DotNetEnv;
using Convey.CQRS.Commands;
using System.Text;

namespace MiniSpace.Services.MediaFiles.Api
{
Expand All @@ -35,6 +36,7 @@ await WebHost.CreateDefaultBuilder(args)
.AddInfrastructure()
.Build())
.Configure(app => app
// .UseMiddleware<RequestLoggingMiddleware>()
.UseInfrastructure()
.UseEndpoints(endpoints => endpoints
.Post<UploadMediaFile>("media-files", async (cmd, ctx) =>
Expand All @@ -54,4 +56,35 @@ await WebHost.CreateDefaultBuilder(args)
.RunAsync();
}
}



// public class RequestLoggingMiddleware
// {
// private readonly RequestDelegate _next;

// public RequestLoggingMiddleware(RequestDelegate next)
// {
// _next = next;
// }

// public async Task Invoke(HttpContext context)
// {
// // Enable buffering so we can read the request body multiple times
// context.Request.EnableBuffering();

// // Read the request body as a string
// var requestBody = await new StreamReader(context.Request.Body, Encoding.UTF8, leaveOpen: true).ReadToEndAsync();

// // Log the request body
// Console.WriteLine("Request Body:");
// Console.WriteLine(requestBody);

// // Reset the request body stream position so the next middleware can read it
// context.Request.Body.Position = 0;

// // Continue processing the request
// await _next(context);
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ public async Task HandleAsync(DeleteMediaFile command, CancellationToken cancell
await _s3Service.DeleteFileAsync(fileSourceInfo.OriginalFileUrl);
await _s3Service.DeleteFileAsync(fileSourceInfo.FileUrl);
await _fileSourceInfoRepository.DeleteAsync(decodedUrl);
await _messageBroker.PublishAsync(new MediaFileDeleted(decodedUrl,
fileSourceInfo.SourceId, fileSourceInfo.SourceType.ToString()));
await _messageBroker.PublishAsync(new MediaFileDeleted(
decodedUrl,
fileSourceInfo.SourceId,
fileSourceInfo.SourceType.ToString(),
fileSourceInfo.UploaderId));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Convey.CQRS.Commands;
using Microsoft.AspNetCore.Http;
using System;

namespace MiniSpace.Services.MediaFiles.Application.Commands
{
Expand All @@ -11,18 +11,18 @@ public class UploadMediaFile : ICommand
public Guid UploaderId { get; set; }
public string FileName { get; set; }
public string FileContentType { get; set; }
public string Base64Content { get; set; }
public byte[] FileData { get; set; }

public UploadMediaFile(Guid mediaFileId, Guid sourceId, string sourceType, Guid uploaderId,
string fileName, string fileContentType, string base64Content)
string fileName, string fileContentType, byte[] fileData)
{
MediaFileId = mediaFileId == Guid.Empty ? Guid.NewGuid() : mediaFileId;
SourceId = sourceId;
SourceType = sourceType;
UploaderId = uploaderId;
FileName = fileName;
FileContentType = fileContentType;
Base64Content = base64Content;
FileData = fileData;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ public class MediaFileDeleted : IEvent
public string MediaFileUrl { get; }
public Guid SourceId { get; }
public string Source { get; }
public Guid UploaderId { get; }

public MediaFileDeleted(string mediaFileUrl, Guid sourceId, string source)
public MediaFileDeleted(string mediaFileUrl, Guid sourceId, string source, Guid uploaderId)
{
MediaFileUrl = mediaFileUrl;
SourceId = sourceId;
Source = source;
UploaderId = uploaderId;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Convey.CQRS.Events;
using System;

namespace MiniSpace.Services.MediaFiles.Application.Events
{
public class OrganizationImageUploaded : IEvent
{
public Guid OrganizationId { get; }
public string ImageUrl { get; }
public string ImageType { get; }
public DateTime UploadDate { get; }

public OrganizationImageUploaded(Guid organizationId, string imageUrl, string imageType, DateTime uploadDate)
{
OrganizationId = organizationId;
ImageUrl = imageUrl;
ImageType = imageType;
UploadDate = uploadDate;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Convey.CQRS.Events;
using System;

namespace MiniSpace.Services.MediaFiles.Application.Events.External
namespace MiniSpace.Services.MediaFiles.Application.Events
{
public class StudentImageUploaded : IEvent
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
public class InvalidFileSizeException : AppException
{
public override string Code { get; } = "invalid_file_size";
public int FileSize { get; }
public int MaxFileSize { get; }
public long FileSize { get; }
public long MaxFileSize { get; }

public InvalidFileSizeException(int fileSize, int maxFileSize)
public InvalidFileSizeException(long fileSize, long maxFileSize)
: base($"Invalid file size: {fileSize}. Maximum valid file size: {maxFileSize}.")
{
FileSize = fileSize;
Expand Down
Loading

0 comments on commit b9098b6

Please sign in to comment.