[backend/akko-client] Handle remote custom emojis
This commit is contained in:
parent
9bd46e6a61
commit
f39c6bb80d
1 changed files with 9 additions and 7 deletions
|
@ -83,7 +83,7 @@ public class StatusController(
|
||||||
[Authenticate("read:statuses")]
|
[Authenticate("read:statuses")]
|
||||||
[ProducesResults(HttpStatusCode.OK)]
|
[ProducesResults(HttpStatusCode.OK)]
|
||||||
[ProducesErrors(HttpStatusCode.Forbidden, HttpStatusCode.NotFound)]
|
[ProducesErrors(HttpStatusCode.Forbidden, HttpStatusCode.NotFound)]
|
||||||
public async Task<List<ReactionEntity>> GetSpecificNoteReaction(string id, string reaction)
|
public async Task<IEnumerable<ReactionEntity>> GetSpecificNoteReaction(string id, string reaction)
|
||||||
{
|
{
|
||||||
var user = HttpContext.GetUser();
|
var user = HttpContext.GetUser();
|
||||||
if (security.Value.PublicPreview == Enums.PublicPreview.Lockdown && user == null)
|
if (security.Value.PublicPreview == Enums.PublicPreview.Lockdown && user == null)
|
||||||
|
@ -98,15 +98,17 @@ public class StatusController(
|
||||||
if (security.Value.PublicPreview <= Enums.PublicPreview.Restricted && note.UserHost != null && user == null)
|
if (security.Value.PublicPreview <= Enums.PublicPreview.Restricted && note.UserHost != null && user == null)
|
||||||
throw GracefulException.Forbidden("Public preview is disabled on this instance");
|
throw GracefulException.Forbidden("Public preview is disabled on this instance");
|
||||||
|
|
||||||
var res = (await noteRenderer.GetReactions([note], user)).First(r => r.Name == Regex.Unescape(reaction));
|
var res = (await noteRenderer.GetReactions([note], user)).Where(r => r.Name.Split("@").First() == Regex.Unescape(reaction));
|
||||||
|
|
||||||
if (res.AccountIds != null)
|
foreach (var item in res)
|
||||||
{
|
{
|
||||||
var accounts = await db.Users.Where(u => res.AccountIds.Contains(u.Id)).ToArrayAsync();
|
if (item.AccountIds == null) continue;
|
||||||
res.Accounts = (await userRenderer.RenderManyAsync(accounts, user)).ToList();
|
|
||||||
|
var accounts = await db.Users.Where(u => item.AccountIds.Contains(u.Id)).ToArrayAsync();
|
||||||
|
item.Accounts = (await userRenderer.RenderManyAsync(accounts, user)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return [res];
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("{id}/reactions/{reaction}")]
|
[HttpPut("{id}/reactions/{reaction}")]
|
||||||
|
@ -150,4 +152,4 @@ public class StatusController(
|
||||||
|
|
||||||
return await GetNote(id);
|
return await GetNote(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue