[backend/akko-client] Put Pleroma quirks behind a feature flag
This commit is contained in:
parent
e3a41c6190
commit
26ec42bc62
8 changed files with 6107 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
using Iceshrimp.Backend.Controllers.Mastodon.Schemas;
|
||||
using Iceshrimp.Backend.Core.Database;
|
||||
using Iceshrimp.Backend.Core.Middleware;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
@ -45,7 +46,11 @@ public class LinkPaginationAttribute(int defaultLimit, int maxLimit, bool offset
|
|||
|
||||
var mpq = query as MastodonPaginationQuery;
|
||||
var offsetPg = offset || mpq is { Offset: not null, MaxId: null, MinId: null, SinceId: null };
|
||||
if (ids.Count >= limit)
|
||||
|
||||
var token = context.HttpContext.GetOauthToken();
|
||||
var alwaysNext = token?.IsPleroma ?? false;
|
||||
|
||||
if (alwaysNext || ids.Count >= limit)
|
||||
{
|
||||
var next = offsetPg
|
||||
? new QueryBuilder { { "offset", ((mpq?.Offset ?? 0) + limit).ToString() } }
|
||||
|
|
|
@ -827,6 +827,9 @@ public class DatabaseContext(DbContextOptions<DatabaseContext> options)
|
|||
entity.Property(e => e.AutoDetectQuotes)
|
||||
.HasComment("Whether the backend should automatically detect quote posts coming from this client")
|
||||
.HasDefaultValue(true);
|
||||
entity.Property(e => e.IsPleroma)
|
||||
.HasComment("Whether Pleroma or Akkoma specific behavior should be enabled for this client")
|
||||
.HasDefaultValue(false);
|
||||
|
||||
entity.HasOne(d => d.App)
|
||||
.WithMany(p => p.OauthTokens)
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
|
|||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.7")
|
||||
.HasAnnotation("ProductVersion", "8.0.8")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "antenna_src_enum", new[] { "home", "all", "users", "list", "group", "instances" });
|
||||
|
@ -3126,6 +3126,13 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
|
|||
.HasColumnName("createdAt")
|
||||
.HasComment("The created date of the OAuth token");
|
||||
|
||||
b.Property<bool>("IsPleroma")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("boolean")
|
||||
.HasDefaultValue(false)
|
||||
.HasColumnName("isPleroma")
|
||||
.HasComment("Whether Pleroma or Akkoma specific behavior should be enabled for this client");
|
||||
|
||||
b.Property<DateTime?>("LastActiveDate")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("lastActiveDate");
|
||||
|
|
6052
Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta3/20240831215254_TokenPleroma.Designer.cs
generated
Normal file
6052
Iceshrimp.Backend/Core/Database/Migrations/v2024.1-beta3/20240831215254_TokenPleroma.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,30 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Iceshrimp.Backend.Core.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class TokenPleroma : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "isPleroma",
|
||||
table: "oauth_token",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false,
|
||||
comment: "Whether Pleroma or Akkoma specific behavior should be enabled for this client");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "isPleroma",
|
||||
table: "oauth_token");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -70,6 +70,7 @@ public class OauthToken
|
|||
|
||||
[Column("supportsHtmlFormatting")] public bool SupportsHtmlFormatting { get; set; }
|
||||
[Column("autoDetectQuotes")] public bool AutoDetectQuotes { get; set; }
|
||||
[Column("isPleroma")] public bool IsPleroma { get; set; }
|
||||
|
||||
[Column("lastActiveDate")] public DateTime? LastActiveDate { get; set; }
|
||||
}
|
|
@ -29,6 +29,10 @@
|
|||
<input type="checkbox" name="autoDetectQuotes" id="autoDetectQuotes" value="1"/>
|
||||
<label for="autoDetectQuotes">Automatically detect quotes</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="checkbox" name="isPleroma" id="isPleroma" value="1"/>
|
||||
<label for="isPleroma">This app is intended for Pleroma or Akkoma</label>
|
||||
</div>
|
||||
@if (Model.AuthenticatedUsers.Count > 0)
|
||||
{
|
||||
<div class="margin-top-5px">
|
||||
|
|
|
@ -54,7 +54,7 @@ public class AuthorizeModel(DatabaseContext db) : PageModel
|
|||
|
||||
public async Task OnPost(
|
||||
[FromForm] string? username, [FromForm] string? password, [FromForm] string? userId,
|
||||
[FromForm] bool supportsHtmlFormatting, [FromForm] bool autoDetectQuotes
|
||||
[FromForm] bool supportsHtmlFormatting, [FromForm] bool autoDetectQuotes, [FromForm] bool isPleroma
|
||||
)
|
||||
{
|
||||
// Validate query parameters & populate model first
|
||||
|
@ -90,7 +90,8 @@ public class AuthorizeModel(DatabaseContext db) : PageModel
|
|||
Scopes = Scopes,
|
||||
RedirectUri = RedirectUri,
|
||||
AutoDetectQuotes = autoDetectQuotes,
|
||||
SupportsHtmlFormatting = supportsHtmlFormatting
|
||||
SupportsHtmlFormatting = supportsHtmlFormatting,
|
||||
IsPleroma = isPleroma,
|
||||
};
|
||||
|
||||
await db.AddAsync(token);
|
||||
|
|
Loading…
Add table
Reference in a new issue