added media class

This commit is contained in:
2026-03-28 23:14:51 -04:00
parent 3a5dde9ee3
commit b8d01b567c
6 changed files with 47 additions and 17 deletions
+1
View File
@@ -12,5 +12,6 @@ service AobaRpc {
rpc ListMedia(PageFilter) returns (ListResponse);
rpc GetUser(Id) returns (UserResponse);
rpc GetShareXDestination(google.protobuf.Empty) returns (ShareXResponse);
rpc SetMediaClass(SetMediaClassRequest) returns(google.protobuf.Empty);
}
+11 -1
View File
@@ -9,7 +9,10 @@ message Credentials{
string password = 2;
}
message SetMediaClassRequest{
Id id = 1;
MediaClass class = 2;
}
message Jwt{
@@ -81,6 +84,7 @@ message MediaModel {
Id owner = 6;
string thumbUrl = 7;
string mediaUrl = 8;
MediaClass class = 9;
}
enum MediaType {
@@ -92,6 +96,12 @@ enum MediaType {
Raw = 5;
}
enum MediaClass {
Standard = 0;
NSFW = 1;
Secret = 2;
}
message ShareXResponse {
oneof dstResult {
string destination = 1;
+8 -8
View File
@@ -9,10 +9,7 @@ using Google.Protobuf.WellKnownTypes;
using Grpc.Core;
using MongoDB.Bson.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace AobaServer.Services;
@@ -20,7 +17,7 @@ public class AobaRpcService(AobaService aobaService, AccountsService accountsSer
{
public override async Task<MediaResponse> GetMedia(Id request, ServerCallContext context)
{
var media = await aobaService.GetMediaFromLegacyIdAsync(request.ToObjectId());
var media = await aobaService.GetMediaFromLegacyIdAsync(request.ToObjectId(), context.CancellationToken);
return media.ToResponse();
}
@@ -31,6 +28,12 @@ public class AobaRpcService(AobaService aobaService, AccountsService accountsSer
return result.ToResponse();
}
public override async Task<Empty> SetMediaClass(SetMediaClassRequest request, ServerCallContext context)
{
await aobaService.SetMediaClassAsync(request.Id.ToObjectId(), (AobaCore.Models.MediaClass)request.Class, context.CancellationToken);
return new Empty();
}
public override async Task<ShareXResponse> GetShareXDestination(Empty request, ServerCallContext context)
{
var userId = context.GetHttpContext().User.GetId();
@@ -50,10 +53,7 @@ public class AobaRpcService(AobaService aobaService, AccountsService accountsSer
};
return new ShareXResponse
{
Destination = JsonSerializer.Serialize(dest, new JsonSerializerOptions
{
WriteIndented = true
})
Destination = JsonSerializer.Serialize(dest)
};
}
+2 -1
View File
@@ -56,7 +56,8 @@ public static class ProtoExtensions
Owner = media.Owner.ToId(),
ViewCount = media.ViewCount,
ThumbUrl = thumbUrl,
MediaUrl = media.GetMediaUrl()
MediaUrl = media.GetMediaUrl(),
Class = (Aoba.RPC.MediaClass)media.Class,
};
}