comparison sat/core/xmpp.py @ 2715:b35c84ea73cf

plugin XEP-0045: MAM implementation for MUC
author Goffi <goffi@goffi.org>
date Fri, 07 Dec 2018 19:13:28 +0100
parents 57eac4fd0ec0
children a58e380c1c37
comparison
equal deleted inserted replaced
2714:57eac4fd0ec0 2715:b35c84ea73cf
923 """ 923 """
924 if not cont: 924 if not cont:
925 return 925 return
926 data = self.parseMessage(message_elt) 926 data = self.parseMessage(message_elt)
927 post_treat.addCallback(self.skipEmptyMessage) 927 post_treat.addCallback(self.skipEmptyMessage)
928 post_treat.addCallback(self.addToHistory, client) 928 post_treat.addCallback(self.addToHistory)
929 post_treat.addCallback(self.bridgeSignal, client, data) 929 post_treat.addCallback(self.bridgeSignal, data)
930 post_treat.addErrback(self.cancelErrorTrap) 930 post_treat.addErrback(self.cancelErrorTrap)
931 post_treat.callback(data) 931 post_treat.callback(data)
932 932
933 def onMessage(self, message_elt): 933 def onMessage(self, message_elt):
934 # TODO: handle threads 934 # TODO: handle threads
949 def skipEmptyMessage(self, data): 949 def skipEmptyMessage(self, data):
950 if not data["message"] and not data["extra"] and not data["subject"]: 950 if not data["message"] and not data["extra"] and not data["subject"]:
951 raise failure.Failure(exceptions.CancelError("Cancelled empty message")) 951 raise failure.Failure(exceptions.CancelError("Cancelled empty message"))
952 return data 952 return data
953 953
954 def addToHistory(self, data, client): 954 def addToHistory(self, data):
955 if data.pop(u"history", None) == C.HISTORY_SKIP: 955 if data.pop(u"history", None) == C.HISTORY_SKIP:
956 log.info(u"history is skipped as requested") 956 log.info(u"history is skipped as requested")
957 data[u"extra"][u"history"] = C.HISTORY_SKIP 957 data[u"extra"][u"history"] = C.HISTORY_SKIP
958 else: 958 else:
959 return self.host.memory.addToHistory(client, data) 959 return self.host.memory.addToHistory(self.parent, data)
960 960
961 def bridgeSignal(self, __, client, data): 961 def bridgeSignal(self, __, data):
962 try: 962 try:
963 data["extra"]["received_timestamp"] = data["received_timestamp"] 963 data["extra"]["received_timestamp"] = data["received_timestamp"]
964 data["extra"]["delay_sender"] = data["delay_sender"] 964 data["extra"]["delay_sender"] = data["delay_sender"]
965 except KeyError: 965 except KeyError:
966 pass 966 pass
974 data["to"].full(), 974 data["to"].full(),
975 data["message"], 975 data["message"],
976 data["subject"], 976 data["subject"],
977 data["type"], 977 data["type"],
978 data["extra"], 978 data["extra"],
979 profile=client.profile, 979 profile=self.parent.profile,
980 ) 980 )
981 return data 981 return data
982 982
983 def cancelErrorTrap(self, failure_): 983 def cancelErrorTrap(self, failure_):
984 """A message sending can be cancelled by a plugin treatment""" 984 """A message sending can be cancelled by a plugin treatment"""