-
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
follower Autocreate Hotfix #81
Conversation
…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<>()))) |
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.
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.
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.
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.")); | ||
} |
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.
this should be on the same line as the else. did you reformat the code before your committed?
No description provided.