[backend/masto-client] Add icon to InstanceInfoV2Response
This commit is contained in:
parent
48a8b9f14a
commit
054fb66a00
2 changed files with 17 additions and 3 deletions
|
@ -61,14 +61,20 @@ public class InstanceController(
|
||||||
&& !Constants.SystemUsers.Contains(p.UsernameLower)
|
&& !Constants.SystemUsers.Contains(p.UsernameLower)
|
||||||
&& p.LastActiveDate > cutoff);
|
&& p.LastActiveDate > cutoff);
|
||||||
|
|
||||||
var (instanceName, instanceDescription, adminContact) =
|
var (instanceName, instanceDescription, adminContact, iconId) =
|
||||||
await meta.GetManyAsync(MetaEntity.InstanceName, MetaEntity.InstanceDescription,
|
await meta.GetManyAsync(MetaEntity.InstanceName, MetaEntity.InstanceDescription,
|
||||||
MetaEntity.AdminContactEmail);
|
MetaEntity.AdminContactEmail, MetaEntity.IconFileId);
|
||||||
|
|
||||||
|
var favicon = await db.DriveFiles.Where(p => p.Id == iconId)
|
||||||
|
.Select(p => new InstanceIcon(p.PublicUrl ?? p.RawAccessUrl, p.Properties.Width ?? 128,
|
||||||
|
p.Properties.Height ?? 128))
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
return new InstanceInfoV2Response(config.Value, instanceName, instanceDescription, adminContact)
|
return new InstanceInfoV2Response(config.Value, instanceName, instanceDescription, adminContact)
|
||||||
{
|
{
|
||||||
Usage = new InstanceUsage { Users = new InstanceUsersUsage { ActiveMonth = activeMonth } },
|
Usage = new InstanceUsage { Users = new InstanceUsersUsage { ActiveMonth = activeMonth } },
|
||||||
Rules = await GetRules()
|
Rules = await GetRules(),
|
||||||
|
Icons = favicon != null ? [favicon] : []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ public class InstanceInfoV2Response(
|
||||||
|
|
||||||
[J("rules")] public required List<RuleEntity> Rules { get; set; }
|
[J("rules")] public required List<RuleEntity> Rules { get; set; }
|
||||||
|
|
||||||
|
[J("icon")] public required List<InstanceIcon> Icons { get; set; }
|
||||||
|
|
||||||
//TODO: add the rest
|
//TODO: add the rest
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,3 +79,9 @@ public class InstanceExtendedDescription(string? description)
|
||||||
[J("content")]
|
[J("content")]
|
||||||
public string Content => description ?? "This Iceshrimp.NET instance does not appear to have a description";
|
public string Content => description ?? "This Iceshrimp.NET instance does not appear to have a description";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class InstanceIcon(string src, int width, int height)
|
||||||
|
{
|
||||||
|
[J("src")] public string Url => src;
|
||||||
|
[J("size")] public string Size => $"{width}x{height}";
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue