[backend/akko-client] Allow setting the 'Automatically approve requests from already followed users' setting in akko-fe
This commit is contained in:
parent
ccf93a06aa
commit
b82f0b64b5
4 changed files with 25 additions and 7 deletions
|
@ -45,7 +45,7 @@ public class AccountController(
|
||||||
public async Task<AccountEntity> VerifyUserCredentials()
|
public async Task<AccountEntity> VerifyUserCredentials()
|
||||||
{
|
{
|
||||||
var user = HttpContext.GetUserOrFail();
|
var user = HttpContext.GetUserOrFail();
|
||||||
return await userRenderer.RenderAsync(user, user.UserProfile, user, source: true);
|
return await userRenderer.RenderAsync(user, user.UserProfile, user, source: true, isPleroma: HttpContext.GetOauthToken()!.IsPleroma);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPatch("update_credentials")]
|
[HttpPatch("update_credentials")]
|
||||||
|
@ -82,6 +82,8 @@ public class AccountController(
|
||||||
user.UserSettings.DefaultNoteVisibility = StatusEntity.DecodeVisibility(request.Source.Privacy);
|
user.UserSettings.DefaultNoteVisibility = StatusEntity.DecodeVisibility(request.Source.Privacy);
|
||||||
if (request.Source?.Sensitive.HasValue ?? false)
|
if (request.Source?.Sensitive.HasValue ?? false)
|
||||||
user.UserSettings.AlwaysMarkSensitive = request.Source.Sensitive.Value;
|
user.UserSettings.AlwaysMarkSensitive = request.Source.Sensitive.Value;
|
||||||
|
if (request.PermitFollowback.HasValue)
|
||||||
|
user.UserSettings.AutoAcceptFollowed = request.PermitFollowback.Value;
|
||||||
|
|
||||||
if (request.Fields?.Where(p => p is { Name: not null, Value: not null }).ToList() is { Count: > 0 } fields)
|
if (request.Fields?.Where(p => p is { Name: not null, Value: not null }).ToList() is { Count: > 0 } fields)
|
||||||
{
|
{
|
||||||
|
@ -125,7 +127,7 @@ public class AccountController(
|
||||||
}
|
}
|
||||||
|
|
||||||
user = await userSvc.UpdateLocalUserAsync(user, prevAvatarId, prevBannerId);
|
user = await userSvc.UpdateLocalUserAsync(user, prevAvatarId, prevBannerId);
|
||||||
return await userRenderer.RenderAsync(user, user.UserProfile, user, source: true);
|
return await userRenderer.RenderAsync(user, user.UserProfile, user, source: true, isPleroma: HttpContext.GetOauthToken()!.IsPleroma);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("/api/v1/profile/avatar")]
|
[HttpDelete("/api/v1/profile/avatar")]
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
using System.Configuration;
|
||||||
|
using Iceshrimp.Backend.Controllers.Mastodon.Schemas;
|
||||||
using Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities;
|
using Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities;
|
||||||
using Iceshrimp.Backend.Core.Configuration;
|
using Iceshrimp.Backend.Core.Configuration;
|
||||||
using Iceshrimp.Backend.Core.Database;
|
using Iceshrimp.Backend.Core.Database;
|
||||||
|
@ -18,11 +20,11 @@ public class UserRenderer(
|
||||||
{
|
{
|
||||||
private readonly string _transparent = $"https://{config.Value.WebDomain}/assets/transparent.png";
|
private readonly string _transparent = $"https://{config.Value.WebDomain}/assets/transparent.png";
|
||||||
|
|
||||||
public Task<AccountEntity> RenderAsync(User user, UserProfile? profile, User? localUser, bool source = false)
|
public Task<AccountEntity> RenderAsync(User user, UserProfile? profile, User? localUser, bool source = false, bool isPleroma = false)
|
||||||
=> RenderAsync(user, profile, localUser, null, source);
|
=> RenderAsync(user, profile, localUser, null, source, isPleroma);
|
||||||
|
|
||||||
private async Task<AccountEntity> RenderAsync(
|
private async Task<AccountEntity> RenderAsync(
|
||||||
User user, UserProfile? profile, User? localUser, UserRendererDto? data = null, bool source = false
|
User user, UserProfile? profile, User? localUser, UserRendererDto? data = null, bool source = false, bool isPleroma = false
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
var acct = user.Username;
|
var acct = user.Username;
|
||||||
|
@ -77,7 +79,11 @@ public class UserRenderer(
|
||||||
IsBot = user.IsBot,
|
IsBot = user.IsBot,
|
||||||
IsDiscoverable = user.IsExplorable,
|
IsDiscoverable = user.IsExplorable,
|
||||||
Fields = fields?.ToList() ?? [],
|
Fields = fields?.ToList() ?? [],
|
||||||
Emoji = profileEmoji
|
Emoji = profileEmoji,
|
||||||
|
Akkoma = isPleroma
|
||||||
|
? new AkkomaInfo()
|
||||||
|
{ PermitFollowback = user.UserSettings?.AutoAcceptFollowed }
|
||||||
|
: null
|
||||||
};
|
};
|
||||||
|
|
||||||
if (localUser is null && security.Value.PublicPreview == Enums.PublicPreview.RestrictedNoMedia) //TODO
|
if (localUser is null && security.Value.PublicPreview == Enums.PublicPreview.RestrictedNoMedia) //TODO
|
||||||
|
|
|
@ -41,6 +41,10 @@ public abstract class AccountSchemas
|
||||||
[B(Name = "fields_attributes")]
|
[B(Name = "fields_attributes")]
|
||||||
public List<AccountUpdateField>? Fields { get; set; }
|
public List<AccountUpdateField>? Fields { get; set; }
|
||||||
|
|
||||||
|
[J("permit_followback")]
|
||||||
|
[B(Name = "permit_followback")]
|
||||||
|
public bool? PermitFollowback { get; set; }
|
||||||
|
|
||||||
[J("source")] [B(Name = "source")] public AccountUpdateSource? Source { get; set; }
|
[J("source")] [B(Name = "source")] public AccountUpdateSource? Source { get; set; }
|
||||||
|
|
||||||
[B(Name = "avatar")] public IFormFile? Avatar { get; set; }
|
[B(Name = "avatar")] public IFormFile? Avatar { get; set; }
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class AccountEntity : IIdentifiable
|
||||||
[J("emojis")] public required List<EmojiEntity> Emoji { get; set; }
|
[J("emojis")] public required List<EmojiEntity> Emoji { get; set; }
|
||||||
[J("id")] public required string Id { get; set; }
|
[J("id")] public required string Id { get; set; }
|
||||||
[J("last_status_at")] public string? LastStatusAt { get; set; }
|
[J("last_status_at")] public string? LastStatusAt { get; set; }
|
||||||
|
[J("akkoma")] public AkkomaInfo? Akkoma { get; set; }
|
||||||
|
|
||||||
[J("avatar_description")] public required string AvatarDescription { get; set; }
|
[J("avatar_description")] public required string AvatarDescription { get; set; }
|
||||||
[J("header_description")] public required string HeaderDescription { get; set; }
|
[J("header_description")] public required string HeaderDescription { get; set; }
|
||||||
|
@ -50,3 +51,8 @@ public class AccountSource
|
||||||
[J("fields")] public required List<Field> Fields { get; set; }
|
[J("fields")] public required List<Field> Fields { get; set; }
|
||||||
[J("follow_requests_count")] public required int FollowRequestCount { get; set; }
|
[J("follow_requests_count")] public required int FollowRequestCount { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class AkkomaInfo
|
||||||
|
{
|
||||||
|
[J("permit_followback")] public required bool? PermitFollowback { get; set; }
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue