Skip to content

Instantly share code, notes, and snippets.

@slorber
Last active June 9, 2016 10:49
Show Gist options
  • Save slorber/6dcacce7dc659d61cc17219b6c6a1c3f to your computer and use it in GitHub Desktop.
Save slorber/6dcacce7dc659d61cc17219b6c6a1c3f to your computer and use it in GitHub Desktop.
/**
* Return the users that should receive a push after a Stample gets moved from one place to the other
* @param movedStample the Stample that just got moved
* @param movedBy the user that performed the move operation
* @param from the former library/folder in which the folder was
* @return the list of users to send a push message to
*/
private def getUsersReceivingStampleMovePush(movedStample: Stample,movedBy: User,from: FolderLike): List[User] = {
val formerLibrary = libraryService.getLibrary(from)
val newLibrary = libraryService.getLibrary(movedStample)
// If the stample is moved inside same library, we don't send any push
if ( formerLibrary == newLibrary ) {
Nil
}
else {
libraryService.getLibraryMembers(library)
.filterNot(_ == movedBy) // never send a push to the user performing the operation
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment