def execute(self):
     super().string.size(self.instance.notification_id, 3, 50, True)
     super().validate()
     super().custom.register(self.instance.notification_id, NotificationIdNotExists(), True)
     super().validate()
     if not Notification.receiver_exists(self.instance.notification_id, auth.user_id):
         super().custom.manual(ErrorCodes.USER_IS_NOT_OWNER)
     super().validate()
Exemplo n.º 2
0
 def execute(self):
     for receiver_id in self.receiver_ids:
         notification = Notification()
         notification.receiver_id = receiver_id
         notification.message_type = self.message_type
         notification.data = self.data
         notification.create()
Exemplo n.º 3
0
 def execute(self):
     json_serializer = Serializer()
     current_id = str(ObjectId())
     while True:
         time.sleep(5)
         try:
             notifications = Notification.notification_new_updates_by_receiver_id_and_message_type(self.receiver_id, self.message_type, current_id)
             if notifications:
                 current_id = notifications[0]._id
                 serialized_notification = json_serializer.serialize_to_string(notifications)
                 result = "data:{}{}".format(serialized_notification, '\nretry:500\n\n')
                 yield result
         except StopIteration:
             continue
 def execute(self):
     query_string_info = QueryStringInfo()
     query_string_info.load(self.query_string)
     notifications = Notification.notification_get_by_receiver_id(self.receiver_id, self.message_type, query_string_info.skip,
                                                              query_string_info.take, query_string_info.sort)
     return NotificationDetail.create_from_notifications(notifications)
 def execute(self):
     notification = Notification()
     notification.view_status = 1
     notification._id = self.notification_id
     notification.mark_as_viewed()
Exemplo n.º 6
0
 def validate(self, notification_id):
     is_available_notification = Notification.id_exists(notification_id)
     if not is_available_notification:
         super().custom.manual(NotificationErrorCodes.NOTIFICATION_ID_NOT_EXIST)
 def execute(self):
     Notification.mark_as_viewed_by_message_type(auth.user_id, self.message_type)
 def execute(self):
     notification_count_of_user = Notification.notification_count_get_by_receiver_id(self.receiver_id, self.message_type)
     return notification_count_of_user