[CalendarServer-changes] [10166] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu Dec 13 20:03:08 PST 2012
Revision: 10166
http://trac.calendarserver.org//changeset/10166
Author: sagen at apple.com
Date: 2012-12-13 20:03:07 -0800 (Thu, 13 Dec 2012)
Log Message:
-----------
calendarserver_manage_push now displays user-agent and IP address of device that subscribed to APNS
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/push/test/test_applepush.py
CalendarServer/trunk/calendarserver/tools/push.py
CalendarServer/trunk/txdav/common/datastore/sql.py
Modified: CalendarServer/trunk/calendarserver/push/test/test_applepush.py
===================================================================
--- CalendarServer/trunk/calendarserver/push/test/test_applepush.py 2012-12-13 01:46:20 UTC (rev 10165)
+++ CalendarServer/trunk/calendarserver/push/test/test_applepush.py 2012-12-14 04:03:07 UTC (rev 10166)
@@ -96,9 +96,9 @@
yield txn.addAPNSubscription(token, key2, timestamp2, uid, userAgent, ipAddr)
subscriptions = (yield txn.apnSubscriptionsBySubscriber(uid))
- self.assertTrue([token, key1, timestamp1] in subscriptions)
- self.assertTrue([token, key2, timestamp2] in subscriptions)
- self.assertTrue([token2, key1, timestamp1] in subscriptions)
+ self.assertTrue([token, key1, timestamp1, userAgent, ipAddr] in subscriptions)
+ self.assertTrue([token, key2, timestamp2, userAgent, ipAddr] in subscriptions)
+ self.assertTrue([token2, key1, timestamp1, userAgent, ipAddr] in subscriptions)
# Verify an update to a subscription with a different uid takes on
# the new uid
@@ -106,10 +106,10 @@
uid2 = "D8FFB335-9D36-4CE8-A3B9-D1859E38C0DA"
yield txn.addAPNSubscription(token, key2, timestamp3, uid2, userAgent, ipAddr)
subscriptions = (yield txn.apnSubscriptionsBySubscriber(uid))
- self.assertTrue([token, key1, timestamp1] in subscriptions)
- self.assertFalse([token, key2, timestamp3] in subscriptions)
+ self.assertTrue([token, key1, timestamp1, userAgent, ipAddr] in subscriptions)
+ self.assertFalse([token, key2, timestamp3, userAgent, ipAddr] in subscriptions)
subscriptions = (yield txn.apnSubscriptionsBySubscriber(uid2))
- self.assertTrue([token, key2, timestamp3] in subscriptions)
+ self.assertTrue([token, key2, timestamp3, userAgent, ipAddr] in subscriptions)
# Change it back
yield txn.addAPNSubscription(token, key2, timestamp2, uid, userAgent, ipAddr)
Modified: CalendarServer/trunk/calendarserver/tools/push.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/push.py 2012-12-13 01:46:20 UTC (rev 10165)
+++ CalendarServer/trunk/calendarserver/tools/push.py 2012-12-14 04:03:07 UTC (rev 10166)
@@ -154,8 +154,8 @@
(yield txn.commit())
if subscriptions:
byKey = { }
- for token, key, timestamp in subscriptions:
- byKey.setdefault(key, []).append((token, timestamp))
+ for token, key, timestamp, userAgent, ipAddr in subscriptions:
+ byKey.setdefault(key, []).append((token, timestamp, userAgent, ipAddr))
for key, tokens in byKey.iteritems():
print
protocol, host, path = key.strip("/").split("/", 2)
@@ -176,8 +176,9 @@
print "...is subscribed to %s's %s home" % (user, resource),
# print " (key: %s)\n" % (key,)
print "with %d device(s):" % (len(tokens),)
- for token, timestamp in tokens:
- print " %s %ss ago" % (token, int(time.time()) - timestamp)
+ for token, timestamp, userAgent, ipAddr in tokens:
+ print " %s\n '%s' from %s\n %s" % (token, userAgent, ipAddr,
+ time.strftime("on %a, %d %b %Y at %H:%M:%S %z(%Z)", time.localtime(timestamp)))
else:
print " ...is not subscribed to anything."
else:
Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py 2012-12-13 01:46:20 UTC (rev 10165)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py 2012-12-14 04:03:07 UTC (rev 10166)
@@ -684,7 +684,7 @@
@classproperty
def _apnSubscriptionsBySubscriberQuery(cls): #@NoSelf
apn = schema.APN_SUBSCRIPTIONS
- return Select([apn.TOKEN, apn.RESOURCE_KEY, apn.MODIFIED],
+ return Select([apn.TOKEN, apn.RESOURCE_KEY, apn.MODIFIED, apn.USER_AGENT, apn.IP_ADDR],
From=apn, Where=apn.SUBSCRIBER_GUID == Parameter("subscriberGUID"))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121213/8ddc93f6/attachment.html>
More information about the calendarserver-changes
mailing list