Send new location notification after device is saved.

This commit is contained in:
Martin Edenhofer 2016-03-30 20:43:38 +02:00
parent 64296b645d
commit 41eb9901d7

View file

@ -145,6 +145,7 @@ log user device action
user_device = UserDevice.find(user_device_id)
# update location if needed
notify = false
if user_device.ip != ip
user_device.ip = ip
location_details = Service::GeoIp.location(ip)
@ -154,14 +155,19 @@ log user device action
# notify if country has changed
if user_device.location != location
user_device.notification_send('user_device_new_location')
end
notify = true
user_device.location = location
end
end
# update attributes
user_device.updated_at = Time.zone.now # force update, also if no other attribute has changed
user_device.save
if notify
user_device.notification_send('user_device_new_location')
end
user_device
end