def _make(self, user = None, settings = None): if settings: self._settings = settings contacts = self.proto.contacts if user.getItemType() == XMPP_ITEM_TYPE.SUB_PENDING: self._receivedAt = user.getItem().receivedAt() canCancel, error = contacts.canCancelFriendship(user) if canCancel: canApprove, error = contacts.canApproveFriendship(user) else: canApprove = False if canApprove or canCancel: submitState = cancelState = NOTIFICATION_BUTTON_STATE.VISIBLE if canApprove: submitState |= NOTIFICATION_BUTTON_STATE.ENABLED if canCancel: cancelState |= NOTIFICATION_BUTTON_STATE.ENABLED self._settings.isNotify = True self._settings.priorityLevel = NotificationPriorityLevel.HIGH else: submitState = cancelState = NOTIFICATION_BUTTON_STATE.HIDDEN message = g_settings.msgTemplates.format('friendshipRequest', ctx={'text': makeFriendshipRequestText(user, error)}, data={'timestamp': self._receivedAt, 'icon': makePathToIcon('friendshipIcon'), 'buttonsStates': {'submit': submitState, 'cancel': cancelState}}) self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': []}
def _make(self, user = None, settings = None): if settings: self._settings = settings contacts = self.proto.contacts if user.getItemType() in XMPP_ITEM_TYPE.SUB_PENDING_ITEMS: self._receivedAt = user.getItem().receivedAt() canCancel, error = contacts.canCancelFriendship(user) if canCancel: canApprove, error = contacts.canApproveFriendship(user) else: canApprove = False if canApprove or canCancel: submitState = cancelState = NOTIFICATION_BUTTON_STATE.VISIBLE if canApprove: submitState |= NOTIFICATION_BUTTON_STATE.ENABLED if canCancel: cancelState |= NOTIFICATION_BUTTON_STATE.ENABLED self._settings.isNotify = True self._settings.priorityLevel = NotificationPriorityLevel.HIGH else: submitState = cancelState = NOTIFICATION_BUTTON_STATE.HIDDEN message = g_settings.msgTemplates.format('friendshipRequest', ctx={'text': makeFriendshipRequestText(user, error)}, data={'timestamp': self._receivedAt, 'icon': makePathToIcon('friendshipIcon'), 'buttonsStates': {'submit': submitState, 'cancel': cancelState}}) self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': []}
def _make(self, user=None, settings=None): if settings: self._settings = settings contacts = self.proto.contacts if user.getItemType() in XMPP_ITEM_TYPE.SUB_PENDING_ITEMS: self._receivedAt = user.getItem().receivedAt() canCancel, error = contacts.canCancelFriendship(user) if canCancel: canApprove, error = contacts.canApproveFriendship(user) else: canApprove = False if canApprove or canCancel: submitState = cancelState = NOTIFICATION_BUTTON_STATE.VISIBLE if canApprove: submitState |= NOTIFICATION_BUTTON_STATE.ENABLED if canCancel: cancelState |= NOTIFICATION_BUTTON_STATE.ENABLED self._settings.isNotify = True self._settings.priorityLevel = NotificationPriorityLevel.HIGH else: submitState = cancelState = NOTIFICATION_BUTTON_STATE.HIDDEN message = g_settings.msgTemplates.format( "friendshipRequest", ctx={"text": makeFriendshipRequestText(user, error)}, data={ "timestamp": self._receivedAt, "icon": makePathToIcon("friendshipIcon"), "buttonsStates": {"submit": submitState, "cancel": cancelState}, }, ) self._vo = { "typeID": self.getType(), "entityID": self.getID(), "message": message, "notify": self.isNotify(), "auxData": [], }