Esempio n. 1
0
 def notify(self, id):
     loggedInUser = helper.getLoggedInUser()
     userId = loggedInUser["_id"]
     if shift.canRead(id, userId):
         if (not shift.commentStream(id) in user.readById(userId)["notify"]):
             user.addNotification(userId, shift.commentStream(id))
             return ack
         else:
             return error("You are already getting notification from this stream", AlreadyBeingNotifiedError)
     else:
         return error("Operation not permitted. You don't have permission to be notified of events on this stream.", PermissionError)
Esempio n. 2
0
 def comment(self, id):
     loggedInUser = helper.getLoggedInUser()
     jsonData = helper.getRequestBody()
     if jsonData != "":
         theData = json.loads(jsonData)
         if shift.canComment(id, loggedInUser["_id"]):
             theUser = user.readById(loggedInUser["_id"])
             theShift = shift.read(id)
             event.create({
                     "meta": "comment",
                     "objectRef": "shift:%s" % id,
                     "streamId": shift.commentStream(id),
                     "displayString": "%s just commented on your %s on %s" % (theUser["userName"], theShift["space"]["name"], theShift["href"]),
                     "createdBy": loggedInUser["_id"],
                     "content": {
                         "href": theShift["href"],
                         "domain": theShift["domain"],
                         "text": theData["text"]
                         }
                     })
             return ack
         else:
             return error("Operation not permitted. You don't have permission to comment on this shift.", PermissionError)
     else:
         return error("No data for comment.", NoDataError)
Esempio n. 3
0
 def unnotify(self, id):
     loggedInUser = helper.getLoggedInUser()
     userId = loggedInUser["_id"]
     if shift.commentStream(id) in user.readById(userId)["notify"]:
         user.removeNotification(userId, id)
         return ack
     else:
         return error("You are not getting notification from this stream.", NotBeingNotifiedError)
Esempio n. 4
0
 def comments(self, id):
     loggedInUser = helper.getLoggedInUser()
     if shift.isPublic(id) or (shift.canRead(id, loggedInUser["_id"])):
         return data(event.eventsForStream(shift.commentStream(id)))
     else:
         return error("Operation not permitted. You don't have permission to view comments on this shift.", PermissionError)