mirror of
https://github.com/OpenMTC/OpenMTC.git
synced 2025-06-02 07:00:56 +00:00
fixes notification for deleted subscriptions
This commit is contained in:
parent
7a91493597
commit
1242ba060d
@ -67,6 +67,14 @@ class NotificationHandler(Plugin):
|
|||||||
|
|
||||||
self._initialized()
|
self._initialized()
|
||||||
|
|
||||||
|
def _get_subscription_reference(self, to, path):
|
||||||
|
if to.startswith('//'):
|
||||||
|
return self._abs_cse_id + '/' + path
|
||||||
|
elif to.startswith('/'):
|
||||||
|
return self._rel_cse_id + '/' + path
|
||||||
|
else:
|
||||||
|
return path
|
||||||
|
|
||||||
def _get_sub_list(self, pid, net):
|
def _get_sub_list(self, pid, net):
|
||||||
return [
|
return [
|
||||||
v['sub'] for v in self.subscriptions_info.itervalues()
|
v['sub'] for v in self.subscriptions_info.itervalues()
|
||||||
@ -123,7 +131,10 @@ class NotificationHandler(Plugin):
|
|||||||
su,
|
su,
|
||||||
pc=Notification(
|
pc=Notification(
|
||||||
subscriptionDeletion=True,
|
subscriptionDeletion=True,
|
||||||
subscriptionReference=subscription.path,
|
subscriptionReference=self._get_subscription_reference(su, subscription.path),
|
||||||
|
# TODO(rst): check if this is the sub creator or the creator of the notification
|
||||||
|
# TODO in this case the CSE
|
||||||
|
creator=subscription.creator,
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
except CSENotFound:
|
except CSENotFound:
|
||||||
@ -348,14 +359,6 @@ class NotificationHandler(Plugin):
|
|||||||
def _send_notification(self, resource, sub):
|
def _send_notification(self, resource, sub):
|
||||||
self.logger.debug("sending notification for resource: %s", resource)
|
self.logger.debug("sending notification for resource: %s", resource)
|
||||||
|
|
||||||
def get_subscription_reference(to, path):
|
|
||||||
if to.startswith('//'):
|
|
||||||
return self._abs_cse_id + '/' + path
|
|
||||||
elif to.startswith('/'):
|
|
||||||
return self._rel_cse_id + '/' + path
|
|
||||||
else:
|
|
||||||
return path
|
|
||||||
|
|
||||||
for uri in sub.notificationURI:
|
for uri in sub.notificationURI:
|
||||||
self.api.handle_onem2m_request(OneM2MRequest(
|
self.api.handle_onem2m_request(OneM2MRequest(
|
||||||
op=OneM2MOperation.notify,
|
op=OneM2MOperation.notify,
|
||||||
@ -364,7 +367,7 @@ class NotificationHandler(Plugin):
|
|||||||
notificationEvent=NotificationEventC(
|
notificationEvent=NotificationEventC(
|
||||||
representation=resource
|
representation=resource
|
||||||
),
|
),
|
||||||
subscriptionReference=get_subscription_reference(uri, sub.path),
|
subscriptionReference=self._get_subscription_reference(uri, sub.path),
|
||||||
# TODO(rst): check if this is the sub creator or the creator of the notification
|
# TODO(rst): check if this is the sub creator or the creator of the notification
|
||||||
# TODO in this case the CSE
|
# TODO in this case the CSE
|
||||||
creator=sub.creator
|
creator=sub.creator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user