Version 0.1.8 0.1.8
authorThierry Florac <thierry.florac@onf.fr>
Fri, 16 Nov 2018 15:20:22 +0100
changeset 41 41d6c78a4915
parent 40 4b36d3cc3d5e
child 42 cd8c5dc6fa9e
Version 0.1.8
docs/HISTORY.txt
src/pyams_notify.egg-info/PKG-INFO
src/pyams_notify/skin/resources/js/pyams_notify.min.js
--- a/docs/HISTORY.txt	Fri Nov 09 10:43:01 2018 +0100
+++ b/docs/HISTORY.txt	Fri Nov 16 15:20:22 2018 +0100
@@ -1,6 +1,10 @@
 History
 =======
 
+0.1.8
+-----
+ - use secure WebSockets when using HTTPS
+
 0.1.7
 -----
  - use constants for roles
--- a/src/pyams_notify.egg-info/PKG-INFO	Fri Nov 09 10:43:01 2018 +0100
+++ b/src/pyams_notify.egg-info/PKG-INFO	Fri Nov 16 15:20:22 2018 +0100
@@ -1,12 +1,11 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
 Name: pyams-notify
-Version: 0.1.7
+Version: 0.1.8
 Summary: PyAMS notifications management package
 Home-page: http://hg.ztfy.org/pyams/pyams_notify
 Author: Thierry Florac
 Author-email: tflorac@ulthar.net
 License: ZPL
-Description-Content-Type: UNKNOWN
 Description: .. contents::
         
         
@@ -22,6 +21,10 @@
         History
         =======
         
+        0.1.8
+        -----
+         - use secure WebSockets when using HTTPS
+        
         0.1.7
         -----
          - use constants for roles
@@ -63,3 +66,4 @@
 Classifier: Programming Language :: Python
 Classifier: Framework :: Pyramid
 Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Provides-Extra: test
--- a/src/pyams_notify/skin/resources/js/pyams_notify.min.js	Fri Nov 09 10:43:01 2018 +0100
+++ b/src/pyams_notify/skin/resources/js/pyams_notify.min.js	Fri Nov 16 15:20:22 2018 +0100
@@ -1,1 +1,1 @@
-!function(t,n){"use strict";var o=n.MyAMS,i={connection:null,initConnection:function(){var n=t("[data-ams-notify-server]","#user-activity").data("ams-notify-server");if(n){var o="ws";"https"===window.location.protocol&&(o+="s");var e=t.WebSocket(o+"://"+n+"/subscribe");e.onopen=i.onSocketOpened,e.onmessage=i.onSocketMessage,e.onerror=i.onSocketError,e.onclose=i.onSocketClosed,i.connection=e,setInterval(i.checkConnection,3e4)}},checkConnection:function(){null!==i.connection&&i.connection.readyState!==WebSocket.CLOSED||i.initConnection()},onSocketOpened:function(t){n.console&&n.console.debug("WS notifications connection opened"),o.ajax.post("get-notifications-context.json",{},function(t){""!==t.principal.id&&(i.connection.send(JSON.stringify({action:"subscribe",principal:t.principal,context:t.context})),o.ajax.post("get-user-notifications.json",{},i.showNotifications))})},onSocketMessage:function(t){var n=JSON.parse(t.data);i.notifyOnDesktop(n),i.notifyInWebpage(n)},onSocketError:function(t){n.console&&n.console.log(t)},onSocketClosed:function(t){i.connection=null,n.console&&n.console.debug("WS connection closed")},notifyOnDesktop:function(t){function n(){var n={title:t.title,body:t.message,icon:t.source.avatar};new Notification(n.title,n).onclick=function(){t.url&&window.open(t.url)}}window.Notification&&"denied"!==Notification.permission&&("default"===Notification.permission?Notification.requestPermission(function(t){"granted"===t&&n()}):n())},createNotification:function(n){var o=t("<li></li>"),i=t("<span></span>"),e=t("<a></a>").addClass("msg").attr("href",n.url);return n.source.avatar?t("<img>").addClass("air air-top-left margin-top-2").attr("src",n.source.avatar).appendTo(e):t("<i></i>").addClass("fa fa-2x fa-user air air-top-left img margin-left-5 margin-top-2").appendTo(e),t("<time></time>").text(n.timestamp).appendTo(e),t("<span></span>").addClass("from").text(n.source.title).appendTo(e),t("<span></span>").addClass("msg-body").text(n.message).appendTo(e),e.appendTo(i),i.appendTo(o),o},notifyInWebpage:function(n){var e=t(".badge","#user-activity >span"),a=parseInt(e.text());e.text(a+1);var c=t(".notification-body","#user-activity");i.createNotification(n).prependTo(c),o.skin.checkNotification()},showNotifications:function(n){var e=n.timestamp,a=n.notifications,c=t(".badge","#user-activity >span"),s=t(".notification-body","#user-activity"),r=t("li",s).length;if(s.empty(),a.length>0){s.prev("p").hide();for(var p=0;p<a.length;p++){var f=a[p];i.createNotification(f).appendTo(s)}var l=t("li",s).length;c.text(l-r)}else s.prev("p").show(),c.text("");var d=t("#activity-update");d.text(d.data("ams-base-label").replace(/\{0\}/,e)),o.skin.checkNotification()},refreshNotifications:function(){return function(){o.ajax.post("get-user-notifications.json",{},i.showNotifications)}}};n.PyAMS_notify=i,o.ajax.check(t.WebSocket,"/--static--/pyams_notify/js/jquery-WebSocket"+o.devext+".js",function(){i.initConnection()})}(jQuery,this);
+!function(f,n){"use strict";var l=n.MyAMS,d={connection:null,initConnection:function(){var t=f("[data-ams-notify-server]","#user-activity").data("ams-notify-server");if(t){var n="ws";"https"===window.location.protocol&&(n+="s");var o=f.WebSocket(n+"://"+t+"/subscribe");o.onopen=d.onSocketOpened,o.onmessage=d.onSocketMessage,o.onerror=d.onSocketError,o.onclose=d.onSocketClosed,d.connection=o,setInterval(d.checkConnection,3e4)}},checkConnection:function(){null!==d.connection&&d.connection.readyState!==WebSocket.CLOSED||d.initConnection()},onSocketOpened:function(t){n.console&&n.console.debug("WS notifications connection opened"),l.ajax.post("get-notifications-context.json",{},function(t){""!==t.principal.id&&(d.connection.send(JSON.stringify({action:"subscribe",principal:t.principal,context:t.context})),l.ajax.post("get-user-notifications.json",{},d.showNotifications))})},onSocketMessage:function(t){var n=JSON.parse(t.data);d.notifyOnDesktop(n),d.notifyInWebpage(n)},onSocketError:function(t){n.console&&n.console.log(t)},onSocketClosed:function(t){d.connection=null,n.console&&n.console.debug("WS connection closed")},notifyOnDesktop:function(n){function o(){var t={title:n.title,body:n.message,icon:n.source.avatar};new Notification(t.title,t).onclick=function(){n.url&&window.open(n.url)}}window.Notification&&"denied"!==Notification.permission&&("default"===Notification.permission?Notification.requestPermission(function(t){"granted"===t&&o()}):o())},createNotification:function(t){var n=f("<li></li>"),o=f("<span></span>"),i=f("<a></a>").addClass("msg").attr("href",t.url);return t.source.avatar?f("<img>").addClass("air air-top-left margin-top-2").attr("src",t.source.avatar).appendTo(i):f("<i></i>").addClass("fa fa-2x fa-user air air-top-left img margin-left-5 margin-top-2").appendTo(i),f("<time></time>").text(t.timestamp).appendTo(i),f("<span></span>").addClass("from").text(t.source.title).appendTo(i),f("<span></span>").addClass("msg-body").text(t.message).appendTo(i),i.appendTo(o),o.appendTo(n),n},notifyInWebpage:function(t){var n=f(".badge","#user-activity >span"),o=parseInt(n.text());n.text(o+1);var i=f(".notification-body","#user-activity");d.createNotification(t).prependTo(i),l.skin.checkNotification()},showNotifications:function(t){var n=t.timestamp,o=t.notifications,i=f(".badge","#user-activity >span"),e=f(".notification-body","#user-activity"),a=f("li",e).length;if(e.empty(),0<o.length){e.prev("p").hide();for(var c=0;c<o.length;c++){var s=o[c];d.createNotification(s).appendTo(e)}var r=f("li",e).length;i.text(r-a)}else e.prev("p").show(),i.text("");var p=f("#activity-update");p.text(p.data("ams-base-label").replace(/\{0\}/,n)),l.skin.checkNotification()},refreshNotifications:function(){return function(){l.ajax.post("get-user-notifications.json",{},d.showNotifications)}}};n.PyAMS_notify=d,l.ajax.check(f.WebSocket,"/--static--/pyams_notify/js/jquery-WebSocket"+l.devext+".js",function(){d.initConnection()})}(jQuery,this);