def recvNotification(self, node): if node["type"] == "picture": if node.getChild("set"): self.toUpper(SetPictureNotificationProtocolEntity.fromProtocolTreeNode(node)) elif node.getChild("delete"): self.toUpper(DeletePictureNotificationProtocolEntity.fromProtocolTreeNode(node)) else: self.raiseErrorForNode(node) elif node["type"] == "status": self.toUpper(StatusNotificationProtocolEntity.fromProtocolTreeNode(node)) elif node["type"] == "features": # Not implemented pass elif node["type"] in [ "contacts", "subject", "w:gp2" ]: # Implemented in respectively the protocol_contacts and protocol_groups layer pass elif node["type"] == "contacts": pass elif node["type"] == "mediaretry": # Not implemented pass elif node["type"] == "web": # Not implemented pass else: self.raiseErrorForNode(node) ack = OutgoingAckProtocolEntity(node["id"], "notification", node["type"], node["from"]) self.toLower(ack.toProtocolTreeNode())
def recvNotification(self, node): if node["type"] == "picture": if node.getChild("set"): self.toUpper( SetPictureNotificationProtocolEntity.fromProtocolTreeNode( node)) elif node.getChild("delete"): self.toUpper( DeletePictureNotificationProtocolEntity. fromProtocolTreeNode(node)) else: self.raiseErrorForNode(node) elif node["type"] == "status": self.toUpper( StatusNotificationProtocolEntity.fromProtocolTreeNode(node)) elif node["type"] in ["contacts", "subject", "w:gp2"]: # Implemented in respectively the protocol_contacts and protocol_groups layer pass else: logger.warning("Unsupported notification type: %s " % node["type"]) logger.debug("Unsupported notification node: %s" % node) ack = OutgoingAckProtocolEntity(node["id"], "notification", node["type"], node["from"], participant=node["participant"]) self.toLower(ack.toProtocolTreeNode())
def recvNotification(self, node): if node["type"] == "picture": if node.getChild("set"): self.toUpper( SetPictureNotificationProtocolEntity.fromProtocolTreeNode( node)) elif node.getChild("delete"): self.toUpper( DeletePictureNotificationProtocolEntity. fromProtocolTreeNode(node)) else: self.raiseErrorForNode(node) elif node["type"] == "status": self.toUpper( StatusNotificationProtocolEntity.fromProtocolTreeNode(node)) elif node["type"] == "features": # Not implemented pass elif node["type"] in ["contacts", "subject", "w:gp2"]: # Implemented in respectively the protocol_contacts and protocol_groups layer pass elif node["type"] == "contacts": pass elif node["type"] == "web": # Not implemented pass #else: #pass # self.raiseErrorForNode(node) ack = OutgoingAckProtocolEntity(node["id"], "notification", node["type"], node["from"]) self.toLower(ack.toProtocolTreeNode())
def recvNotification(self, node): if node["type"] == "picture": if node.getChild("set"): self.toUpper(SetPictureNotificationProtocolEntity.fromProtocolTreeNode(node)) elif node.getChild("delete"): self.toUpper(DeletePictureNotificationProtocolEntity.fromProtocolTreeNode(node)) else: self.raiseErrorForNode(node) elif node["type"] == "status": self.toUpper(StatusNotificationProtocolEntity.fromProtocolTreeNode(node)) elif node["type"] == "features": # Not implemented pass elif node["type"] in ["contacts", "subject", "w:gp2"]: # Implemented in respectively the protocol_contacts and protocol_groups layer pass elif node["type"] in ["features", "contacts", "web", "location"]: # implement individually at some point # but keep this pass block so system doesn't crash on these types pass else: self.raiseErrorForNode(node) ack = OutgoingAckProtocolEntity(node["id"], "notification", node["type"], node["from"]) self.toLower(ack.toProtocolTreeNode())
def onEncryptNotification(self, protocolTreeNode): entity = EncryptNotification.fromProtocolTreeNode(protocolTreeNode) ack = OutgoingAckProtocolEntity(protocolTreeNode["id"], "notification", protocolTreeNode["type"]) self.toLower(ack.toProtocolTreeNode()) self.sendKeys(fresh=False, countPreKeys=self.__class__._COUNT_PREKEYS - entity.getCount())
def onEncryptNotification(self, protocolTreeNode): entity = EncryptNotification.fromProtocolTreeNode(protocolTreeNode) ack = OutgoingAckProtocolEntity(protocolTreeNode["id"], "notification", protocolTreeNode["type"], protocolTreeNode["from"]) self.toLower(ack.toProtocolTreeNode()) self.flush_keys( self.manager.generate_signed_prekey(), self.manager.level_prekeys(force=True) )
def recvCall(self, node): entity = CallProtocolEntity.fromProtocolTreeNode(node) if entity.getType() == "offer": receipt = OutgoingReceiptProtocolEntity(node["id"], node["from"], callId = entity.getCallId()) self.toLower(receipt.toProtocolTreeNode()) else: ack = OutgoingAckProtocolEntity(node["id"], "call", None, node["from"]) self.toLower(ack.toProtocolTreeNode()) self.toUpper(entity)
def onIdentityChangeEncryptNotification(self, protocoltreenode): entity = IdentityChangeEncryptNotification.fromProtocolTreeNode( protocoltreenode) ack = OutgoingAckProtocolEntity(protocoltreenode["id"], "notification", protocoltreenode["type"], protocoltreenode["from"]) self.toLower(ack.toProtocolTreeNode()) self.getKeysFor([entity.getFrom(True)], resultClbk=lambda _, __: None, reason="identity")
def recvCall(self, node): entity = CallProtocolEntity.fromProtocolTreeNode(node) if entity.getType() == "offer": receipt = OutgoingReceiptProtocolEntity(node["id"], node["from"], callId=entity.getCallId()) self.toLower(receipt.toProtocolTreeNode()) else: ack = OutgoingAckProtocolEntity(node["id"], "call", None, node["from"]) self.toLower(ack.toProtocolTreeNode()) self.toUpper(entity)
def recvNotification(self, node): if node["type"] == "picture": if node.getChild("set"): self.toUpper(PictureNotificationProtocolEntity.fromProtocolTreeNode(node)) else: self.raiseErrorForNode(node) elif node["type"] == "status": self.toUpper(StatusNotificationProtocolEntity.fromProtocolTreeNode(node)) elif node["type"] == "features": pass else: self.raiseErrorForNode(node) ack = OutgoingAckProtocolEntity(node["id"], "notification", node["type"]) self.toLower(ack.toProtocolTreeNode())
def onReceipt(self, entity): ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom()) if args.debug: print "<= WhatsApp: receipt %s" % (entity) if not args.dry: self.toLower(ack)
def on_receipt(self, entity): logger.debug('Mensaje ACK') ack = OutgoingAckProtocolEntity( entity.getId(), 'receipt', entity.getType(), entity.getFrom() ) self.toLower(ack)
def on_receipt(self, entity): """Received a "receipt" for a message.""" logger.debug('ACK message') # Acknowledge ack = OutgoingAckProtocolEntity(entity.getId(), 'receipt', entity.getType(), entity.getFrom()) self.toLower(ack)
def recvNotification(self, node): if node["type"] == "picture": if node.getChild("set"): self.toUpper( PictureNotificationProtocolEntity.fromProtocolTreeNode( node)) else: self.raiseErrorForNode(node) elif node["type"] == "status": self.toUpper( StatusNotificationProtocolEntity.fromProtocolTreeNode(node)) elif node["type"] == "features": pass else: self.raiseErrorForNode(node) ack = OutgoingAckProtocolEntity(node["id"], "notification", node["type"]) self.toLower(ack.toProtocolTreeNode())
def recvNotification(self, node): if node["type"] == "picture": if node.getChild("set"): self.toUpper(SetPictureNotificationProtocolEntity.fromProtocolTreeNode(node)) elif node.getChild("delete"): self.toUpper(DeletePictureNotificationProtocolEntity.fromProtocolTreeNode(node)) else: self.raiseErrorForNode(node) elif node["type"] == "status": self.toUpper(StatusNotificationProtocolEntity.fromProtocolTreeNode(node)) elif node["type"] in ["contacts", "subject", "w:gp2"]: # Implemented in respectively the protocol_contacts and protocol_groups layer pass else: logger.warn("Unsupported notification type: %s " % node["type"]) logger.debug("Unsupported notification node: %s" % node) ack = OutgoingAckProtocolEntity(node["id"], "notification", node["type"], node["from"], participant=node["participant"]) self.toLower(ack.toProtocolTreeNode())
def onReceipt(self, entity): """ When a receipt is received from WhatsApp. First it is acknowledged then depening on the type of receipt the right delivery status is made. """ # Acknowledge the receipt ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom()) self.toLower(ack) id = entity.getId() receipt_type = entity.getType() _session = self.session() job = _session.query(Job).filter_by(account_id=self.account.id, whatsapp_message_id=id).scalar() if job is not None: if job.method == 'sendMessage': # In the event that this is from a text message message = _session.query(Message).get(job.message_id) if message is not None: # TODO: Make this uniform. Post the received to the API instead of updating the DB message.received = True message.receipt_timestamp = datetime.now() _session.commit() if receipt_type == 'read': data = { 'receipt': { 'type': 'read', 'message_id': message.id } } post_to_server('receipt', self.phone_number, data) elif job.method == 'broadcast_Text': contact = entity.getParticipant() data = { 'receipt': { 'message_id': id, 'phone_number': strip_jid(contact) } } post_to_server('broadcast_receipt', self.phone_number, data)
def onReceipt(self, entity): ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom()) print("Receipt: %s" % ack) self.toLower(ack)
def onReceipt(self, entity): print "aaaaa", entity.getId() ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", "delivery") self.toLower(ack)
def onReceipt(self, entity): """ Acknowledge the receipt """ ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom()) self.toLower(ack)
def onEncryptNotification(self, protocolTreeNode): entity = EncryptNotification.fromProtocolTreeNode(protocolTreeNode) ack = OutgoingAckProtocolEntity(protocolTreeNode["id"], "notification", protocolTreeNode["type"], protocolTreeNode["from"]) self.toLower(ack.toProtocolTreeNode()) self.sendKeys(fresh=False, countPreKeys = self.__class__._COUNT_PREKEYS - entity.getCount())
def onReceipt(self, entity): # ack ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom()) self.toLower(ack)
def onReceipt(self, entity): self.toLower( OutgoingAckProtocolEntity(entity.getId(), 'receipt', entity.getType(), entity.getFrom()))
def onReceipt(self, entity): """Called when received an ACK.""" ack = OutgoingAckProtocolEntity(entity.getId(), 'receipt', entity.getType(), entity.getFrom()) self.toLower(ack)
def onAck(self, entity): name = entity.getClass() if name == "receipt": ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", "receipt", entity._from) self.toLower(ack)
def onReceipt(self, entity): print "Id-->", entity.getId(), "Type-->", entity.getType( ), "From-->", entity.getFrom() ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom()) self.toLower(ack)
def onReceipt(self, entity): logger.info("Received Receipt: ID {}".format(entity._id)) logger.info("Sending ACK") ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom()) self.toLower(ack)
def ack(self): return OutgoingAckProtocolEntity(self.getId(), "receipt", self.getType(), self.getFrom(), participant=self.participant)
def onReceipt(self, entity): ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", "delivery", entity.getFrom()) self.toLower(ack)
def onReceipt(self, entity): ack = OutgoingAckProtocolEntity(entity.getId(), "receipt", entity.getType(), entity.getFrom())