🐛 Fix missing file permission creation

This commit is contained in:
2026-01-12 19:32:50 +08:00
parent 7085f43e54
commit c11bf579c4
12 changed files with 158 additions and 3 deletions

View File

@@ -122,12 +122,16 @@ public class AccountCurrentController(
{
var file = await files.GetFileAsync(new GetFileRequest { Id = request.PictureId });
profile.Picture = SnCloudFileReferenceObject.FromProtoValue(file);
await files.SetFilePublicAsync(new SetFilePublicRequest { FileId = request.PictureId });
}
if (request.BackgroundId is not null)
{
var file = await files.GetFileAsync(new GetFileRequest { Id = request.BackgroundId });
profile.Background = SnCloudFileReferenceObject.FromProtoValue(file);
await files.SetFilePublicAsync(new SetFilePublicRequest { FileId = request.BackgroundId });
}
db.Update(profile);

View File

@@ -229,12 +229,16 @@ public class AccountService(
{
var file = await files.GetFileAsync(new GetFileRequest { Id = pictureId });
account.Profile.Picture = SnCloudFileReferenceObject.FromProtoValue(file);
await files.SetFilePublicAsync(new SetFilePublicRequest { FileId = pictureId });
}
if (!string.IsNullOrEmpty(backgroundId))
{
var file = await files.GetFileAsync(new GetFileRequest { Id = backgroundId });
account.Profile.Background = SnCloudFileReferenceObject.FromProtoValue(file);
await files.SetFilePublicAsync(new SetFilePublicRequest { FileId = backgroundId });
}
db.Accounts.Add(account);

View File

@@ -53,12 +53,16 @@ public class BotAccountReceiverGrpc(
{
var file = await files.GetFileAsync(new GetFileRequest { Id = request.PictureId });
account.Profile.Picture = SnCloudFileReferenceObject.FromProtoValue(file);
await files.SetFilePublicAsync(new SetFilePublicRequest { FileId = request.PictureId });
}
if (request.BackgroundId is not null)
{
var file = await files.GetFileAsync(new GetFileRequest { Id = request.BackgroundId });
account.Profile.Background = SnCloudFileReferenceObject.FromProtoValue(file);
await files.SetFilePublicAsync(new SetFilePublicRequest { FileId = request.BackgroundId });
}
db.Accounts.Update(account);

View File

@@ -388,6 +388,9 @@ public class RealmController(
var pictureResult = await files.GetFileAsync(new GetFileRequest { Id = request.PictureId });
if (pictureResult is null) return BadRequest("Invalid picture id, unable to find the file on cloud.");
realm.Picture = SnCloudFileReferenceObject.FromProtoValue(pictureResult);
if (realm.IsPublic)
await files.SetFilePublicAsync(new SetFilePublicRequest { FileId = request.PictureId });
}
if (request.BackgroundId is not null)
@@ -395,6 +398,9 @@ public class RealmController(
var backgroundResult = await files.GetFileAsync(new GetFileRequest { Id = request.BackgroundId });
if (backgroundResult is null) return BadRequest("Invalid background id, unable to find the file on cloud.");
realm.Background = SnCloudFileReferenceObject.FromProtoValue(backgroundResult);
if (realm.IsPublic)
await files.SetFilePublicAsync(new SetFilePublicRequest { FileId = request.BackgroundId });
}
db.Realms.Add(realm);
@@ -456,6 +462,9 @@ public class RealmController(
if (pictureResult is null) return BadRequest("Invalid picture id, unable to find the file on cloud.");
realm.Picture = SnCloudFileReferenceObject.FromProtoValue(pictureResult);
if (realm.IsPublic)
await files.SetFilePublicAsync(new SetFilePublicRequest { FileId = request.PictureId });
}
if (request.BackgroundId is not null)
@@ -464,10 +473,14 @@ public class RealmController(
if (backgroundResult is null) return BadRequest("Invalid background id, unable to find the file on cloud.");
realm.Background = SnCloudFileReferenceObject.FromProtoValue(backgroundResult);
if (realm.IsPublic)
await files.SetFilePublicAsync(new SetFilePublicRequest { FileId = request.BackgroundId });
}
db.Realms.Update(realm);
await db.SaveChangesAsync();
await db.SaveChangesAsync();
als.CreateActionLogFromRequest(
"realms.update",