SHARE
TWEET

Untitled

a guest Sep 7th, 2019 116 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. override def vote(user: Tid, evidence: Tid, action: String, attribute: Option[String] = None): Future[Boolean] = {
  2.     allTrueSequentially(
  3.       evidenceRepo.isEvidenceExist(evidence),
  4.       isSharedInternal(user, evidence, action) || isSharedExternal(user, evidence, action)
  5.     )
  6.   }
  7.  
  8.   private[this] def hasRequiredPermission(user: Tid, evidence: Tid, action: String): Future[Boolean] = {
  9.     for {
  10.       isCEW <- evidenceRepo.isCEW(evidence)
  11.       requiredPerms = requiredPermission(isCEW, action)
  12.       granted <- hasPermissions(requiredPerms.toSeq: _*)(user)
  13.     } yield granted
  14.   }
  15.  
  16.   private[this] def isSharedInternal(user: Tid, evidence: Tid, action: String): Future[Boolean] = {
  17.     lazy val isShared = isSharedWithOpcodes(user, evidence, action, isInternal = true) ||
  18.                                       isRoleBasedSharedWithUser(user, evidence, action)
  19.  
  20.     userRepo.isNotLiteTier(user) && isShared
  21.  
  22.   }
  23.  
  24.   private[this] def isSharedExternal(user: Tid, evidence: Tid, action: String): Future[Boolean] = {
  25.     isSharedWithOpcodes(user, evidence, action, isInternal = false) ||
  26.     isRoleBasedSharedWithUser(user, evidence, action)
  27.   }
  28.  
  29.   private[this] def isRoleBasedSharedWithUser(user: Tid, evidence: Tid, action: String): Future[Boolean] = {
  30.     evidenceRepo.isRoleBasedSharedWithUser(user = user, evidence = evidence) &&
  31.     hasRequiredPermission(user, evidence, action)
  32.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top