From 68832dc5c36d970e297a84cb8f205cfcb7a01ce2 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 9 Jan 2023 05:25:39 +0300 Subject: Mastodon API: include message author data into statuses --- src/main/java/com/juick/www/api/Mastodon.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/main/java/com/juick/www/api') diff --git a/src/main/java/com/juick/www/api/Mastodon.java b/src/main/java/com/juick/www/api/Mastodon.java index 7591ec92..414c291a 100644 --- a/src/main/java/com/juick/www/api/Mastodon.java +++ b/src/main/java/com/juick/www/api/Mastodon.java @@ -83,12 +83,15 @@ public class Mastodon { String clientSecret) { } + public record AccountSource(String privacy) {} + @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) public record CredentialAccount(String id, String username, String acct, String displayName, Integer followersCount, Integer followingCount, - String avatar) { + String avatar, + AccountSource source) { } @@ -215,7 +218,7 @@ public class Mastodon { } @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) - public record Status(String id, Instant createdAt, String inReplyToId, String inReplyToAccountId, + public record Status(String id, Instant createdAt, CredentialAccount account, String inReplyToId, String inReplyToAccountId, Boolean sensitive, String spoilerText, String visibility, String content) { } @@ -236,13 +239,14 @@ public class Mastodon { user.getFullName(), userService.getUserReaders(user.getUid()).size(), userService.getUserFriends(user.getUid()).size(), - webApp.getAvatarUrl(user)); + webApp.getAvatarUrl(user), new AccountSource("public")); } public Status mapLastMessage(Chat chat) { return new Status( String.valueOf(chat.getLastMessageTimestamp().toEpochMilli()), chat.getLastMessageTimestamp(), + toAccount(chat), null, null, false, @@ -271,6 +275,7 @@ public class Mastodon { return new Status( String.valueOf(message.getMid()), message.getCreated(), + toAccount(message.getUser()), null, null, MessageUtils.isSensitive(message), -- cgit v1.2.3