aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-01-09 05:25:39 +0300
committerGravatar Vitaly Takmazov2023-01-09 05:25:39 +0300
commit68832dc5c36d970e297a84cb8f205cfcb7a01ce2 (patch)
treecbd906f1f1f2289261593f67a049b23bfef93817 /src/main
parent8908d48713b627eaa5af9727841ca676f9ddbd98 (diff)
Mastodon API: include message author data into statuses
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/juick/www/api/Mastodon.java11
1 files changed, 8 insertions, 3 deletions
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),