Skip to content
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

follower Autocreate Hotfix #81

Merged
merged 4 commits into from
Jul 20, 2023
Merged

follower Autocreate Hotfix #81

merged 4 commits into from
Jul 20, 2023

Conversation

samuellvo
Copy link
Collaborator

No description provided.

…s collection, or an existing Followers collection
…s collection, or an existing Followers collection
@@ -34,7 +37,8 @@ public Mono<String> followerHandler(String id, JsonNode inboxNode, String reques
String follower = inboxNode.get("actor").asText();
if (requestType.equals("Follow")) {
// find id, grab arraylist, append
return followersRepository.findItemById(id).flatMap(followedUser -> {
return followersRepository.findItemById(id).switchIfEmpty(Mono.just(new Followers(id, new ArrayList<>())))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this could backfire on us. if we get non-existent ids, it will create followers for them. perhaps we should write a CLI command to run that will go through the tables and make sure they are in sync.

for the contact account, we can create it on the fly since it is set by the admin, but these are random requests coming in from the internet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've been thinking about this more. perhaps it is just a matter of checking to see if the id exists in accounts in the switchIfEmpty before returning the empty array. if it doesn't exist we could return a Mono.error()

… make random collections for nonexistent accounts
// check id
if (accountRepository.findItemByAcct(id)==null) {
return Mono.error(new RuntimeException("Error: Account to follow doesn't exist."));
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be on the same line as the else. did you reformat the code before your committed?

@samuellvo samuellvo merged commit 0100a87 into main Jul 20, 2023
1 check passed
@samuellvo samuellvo deleted the followerAutocreateHotfix branch July 20, 2023 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants