Send new location notification after device is saved.
This commit is contained in:
parent
64296b645d
commit
41eb9901d7
1 changed files with 8 additions and 2 deletions
|
@ -145,6 +145,7 @@ log user device action
|
||||||
user_device = UserDevice.find(user_device_id)
|
user_device = UserDevice.find(user_device_id)
|
||||||
|
|
||||||
# update location if needed
|
# update location if needed
|
||||||
|
notify = false
|
||||||
if user_device.ip != ip
|
if user_device.ip != ip
|
||||||
user_device.ip = ip
|
user_device.ip = ip
|
||||||
location_details = Service::GeoIp.location(ip)
|
location_details = Service::GeoIp.location(ip)
|
||||||
|
@ -154,14 +155,19 @@ log user device action
|
||||||
|
|
||||||
# notify if country has changed
|
# notify if country has changed
|
||||||
if user_device.location != location
|
if user_device.location != location
|
||||||
user_device.notification_send('user_device_new_location')
|
notify = true
|
||||||
end
|
|
||||||
user_device.location = location
|
user_device.location = location
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# update attributes
|
# update attributes
|
||||||
user_device.updated_at = Time.zone.now # force update, also if no other attribute has changed
|
user_device.updated_at = Time.zone.now # force update, also if no other attribute has changed
|
||||||
user_device.save
|
user_device.save
|
||||||
|
|
||||||
|
if notify
|
||||||
|
user_device.notification_send('user_device_new_location')
|
||||||
|
end
|
||||||
|
|
||||||
user_device
|
user_device
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue