use new routes and params from v1 ip matcher endpoint
This commit is contained in:
@@ -39,7 +39,7 @@ module.exports =
|
||||
_key = @key
|
||||
request {
|
||||
method: 'GET'
|
||||
url: "#{settings.apis.v1.url}/api/v2/users/ip_matcher/#{userId}"
|
||||
url: "#{settings.apis.v1.url}/api/v2/users/#{userId}/ip_matcher"
|
||||
auth: { user: settings.apis.v1.user, pass: settings.apis.v1.pass }
|
||||
body: { ip: ip }
|
||||
json: true
|
||||
@@ -49,9 +49,9 @@ module.exports =
|
||||
return null if response.statusCode == 204
|
||||
|
||||
messageOpts =
|
||||
university_id: body.university_id
|
||||
university_name: body.university_name
|
||||
content: body.ad_copy
|
||||
university_id: body.id
|
||||
university_name: body.name
|
||||
content: body.enrolment_ad_html
|
||||
logger.log user_id:userId, key:_key, "creating notification key for user"
|
||||
NotificationsHandler.createNotification userId, _key, "notification_ip_matched_affiliation", messageOpts, null, callback
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ NotificationsHandler = require("./NotificationsHandler")
|
||||
NotificationsBuilder = require("./NotificationsBuilder")
|
||||
AuthenticationController = require("../Authentication/AuthenticationController")
|
||||
Settings = require 'settings-sharelatex'
|
||||
UserGetter = require("../User/UserGetter")
|
||||
logger = require("logger-sharelatex")
|
||||
async = require "async"
|
||||
_ = require("underscore")
|
||||
|
||||
module.exports =
|
||||
@@ -15,9 +17,15 @@ module.exports =
|
||||
|
||||
# in v2 add notifications for matching university IPs
|
||||
if Settings.overleaf?
|
||||
NotificationsBuilder.ipMatcherAffiliation(user_id, ip).create((err) ->
|
||||
return err
|
||||
)
|
||||
UserGetter.getUser user_id, { 'lastLoginIp': 1 }, (error, user) ->
|
||||
console.log(user.lastLoginIp)
|
||||
if ip != user.lastLoginIp
|
||||
async.series ([
|
||||
() ->
|
||||
NotificationsBuilder.ipMatcherAffiliation(user_id, ip).create((err) ->
|
||||
return err
|
||||
)
|
||||
])
|
||||
|
||||
NotificationsHandler.getUserNotifications user_id, (err, unreadNotifications)->
|
||||
unreadNotifications = _.map unreadNotifications, (notification)->
|
||||
|
||||
@@ -63,7 +63,8 @@ span(ng-controller="NotificationsController").userNotifications
|
||||
.alert.alert-info(ng-switch-when="notification_ip_matched_affiliation")
|
||||
div.notification_inner
|
||||
.notification_body
|
||||
| Add an email for: {{ notification.messageOpts.university_name }}
|
||||
| Add an email for
|
||||
strong {{ notification.messageOpts.university_name }}
|
||||
a.pull-right.btn.btn-sm.btn-info(href="/user/settings")
|
||||
| Add Affiliation
|
||||
span().notification_close
|
||||
|
||||
Reference in New Issue
Block a user