-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added 3 endpoints for external public mentions to work #139
Merged
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
32c59b9
added 3 endpoints for external public mentions to work
seannian d0d7d7d
removed print lines, need to move to different controller
seannian 5fc6269
moved endpoints to moth controller
seannian c70f559
Merge branch 'main' into public-external-status-fix
seannian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,12 +8,14 @@ | |
import edu.sjsu.moth.generated.Actor; | ||
import edu.sjsu.moth.generated.Attachment; | ||
import edu.sjsu.moth.generated.CustomEmoji; | ||
import edu.sjsu.moth.generated.Icon; | ||
import edu.sjsu.moth.server.db.Account; | ||
import edu.sjsu.moth.server.db.AccountField; | ||
import edu.sjsu.moth.server.db.ExternalStatus; | ||
import edu.sjsu.moth.server.service.AccountService; | ||
import edu.sjsu.moth.server.service.ActorService; | ||
import edu.sjsu.moth.server.service.StatusService; | ||
import edu.sjsu.moth.server.util.MothConfiguration; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.ResponseEntity; | ||
|
@@ -31,6 +33,8 @@ | |
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static edu.sjsu.moth.server.util.Util.printJsonNode; | ||
|
||
@RestController | ||
public class InboxController { | ||
@Autowired | ||
|
@@ -110,7 +114,6 @@ public static Mono<Account> convertToAccount(Actor actor) { | |
|
||
@PostMapping("/inbox") | ||
public Mono<ResponseEntity<Object>> inbox(@RequestBody JsonNode inboxNode) { | ||
//handle here | ||
String requestType = inboxNode.get("type").asText(); | ||
if (requestType.equals("Delete")) { | ||
return Mono.empty(); | ||
|
@@ -185,6 +188,57 @@ public Mono<UsersFollowResponse> usersFollowers(@PathVariable String id, | |
return accountService.usersFollow(id, page, limit, "followers"); | ||
} | ||
|
||
@GetMapping("/manifest.json") | ||
public Mono<ManifestJSON> manifest() { | ||
String name = MothConfiguration.mothConfiguration.getServerName(); | ||
String short_name = MothConfiguration.mothConfiguration.getServerName(); | ||
|
||
List<Icon> icons = new ArrayList<>(); | ||
Icon x32 = new Icon("image/png", null, null, "moth/icons/cyber-moth-32.png", "32x32", "any maskable"); | ||
Icon x48 = new Icon("image/png", null, null, "moth/icons/cyber-moth-48.png", "48x48", "any maskable"); | ||
Icon x144 = new Icon("image/png", null, null, "moth/icons/cyber-moth-144.png", "144x144", "any maskable"); | ||
Icon x256 = new Icon("image/png", null, null, "moth/icons/cyber-moth-256.png", "256x256", "any maskable"); | ||
Icon x512 = new Icon("image/png", null, null, "moth/icons/cyber-moth-512x512.png", "512x512", "any maskable"); | ||
icons.add(x32); | ||
icons.add(x48); | ||
icons.add(x144); | ||
icons.add(x256); | ||
icons.add(x512); | ||
|
||
String theme_color = "#FFFFFF"; | ||
String background_color = "#FFFFFF"; | ||
String display = "standalone"; | ||
String start_url = "/home"; | ||
String scope = "/"; | ||
|
||
// unsure | ||
ShareTarget share_target = new ShareTarget("share?title={title}&text={text}&url={url}", "share", "GET", | ||
"application/x-www-form-urlencoded", | ||
new Params("title", "text", "url")); | ||
|
||
List<Shortcut> shortcuts = new ArrayList<>(); //may need to change to null | ||
shortcuts.add(new Shortcut("name", "url")); | ||
|
||
return Mono.just( | ||
new ManifestJSON(name, short_name, icons, theme_color, background_color, display, start_url, scope, | ||
share_target, shortcuts)); | ||
} | ||
|
||
//TODO: add data in Usage | ||
@GetMapping("/nodeinfo/2.0") | ||
public Mono<NodeInfo2> nodeInfo2Mono() { | ||
return Mono.just(new NodeInfo2("2.0", new Software("mastodon", "4.2.8"), List.of("activitypub"), | ||
new Services(List.of(""), List.of("")), new Usage(new Users(0, 0, 0), 0), true, | ||
new Metadata())); | ||
} | ||
|
||
@GetMapping("/.well-known/nodeinfo") | ||
public Mono<NodeInfo> nodeInfoMono() { | ||
return Mono.just(new NodeInfo( | ||
List.of(new Link("http://nodeinfo.diaspora.software/ns/schema/2.0", "https://mas.to/nodeinfo/2.0")))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mas.to -> server name |
||
// added placeholders, hardcoded | ||
} | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonPropertyOrder({ "@context", "id", "type", "totalItems", "first", "next", "partOf", "orderedItems" }) | ||
public record UsersFollowResponse(String id, String type, int totalItems, String first, String next, String partOf, | ||
|
@@ -194,4 +248,40 @@ public String getContext() { | |
return "https://www.w3.org/ns/activitystreams"; | ||
} | ||
} | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonPropertyOrder({ "name", "short_name", "icons", "theme_color", "background_color", "display", "start_url", | ||
"scope", "share_target", "shortcuts" }) | ||
public record ManifestJSON(String name, String short_name, List<Icon> icons, String theme_color, | ||
String background_color, String display, String start_url, String scope, | ||
ShareTarget share_target, List<Shortcut> shortcuts) {} | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonPropertyOrder({ "links" }) | ||
public record NodeInfo(List<Link> links) {} | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@JsonPropertyOrder({ "version", "software", "protocols", "services", "usage", "openRegistrations", "metadata" }) | ||
public record NodeInfo2(String version, Software software, List<String> protocols, Services services, Usage usage, | ||
boolean openRegistrations, Metadata metadata) {} | ||
|
||
public record Software(String name, String version) {} | ||
|
||
// Unsure if it is List of Strings. | ||
public record Services(List<String> outbound, List<String> inbound) {} | ||
|
||
public record Usage(Users user, int localPosts) {} | ||
|
||
public record Users(int total, int activeMonth, int activeHalfyear) {} | ||
|
||
public record Metadata() {} | ||
|
||
public record Shortcut(String name, String url) {} | ||
|
||
public record Params(String title, String text, String url) {} | ||
|
||
public record ShareTarget(String url_template, String action, String method, String enctype, Params params) {} | ||
|
||
public record Link(String rel, String href) {} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should add a // TODO: to grab from account DB