{"size": 832, "ext": "js", "max_stars_repo_path": "common/models/follow.js", "max_stars_repo_name": "e-part/open-community-app", "max_stars_repo_stars_event_min_datetime": "2018-02-10T14:50:05.000Z", "max_stars_repo_stars_event_max_datetime": "2018-02-10T14:50:05.000Z", "max_issues_repo_path": "common/models/follow.js", "max_issues_repo_name": "e-part/open-community-app", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "common/models/follow.js", "max_forks_repo_name": "e-part/open-community-app", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.0, "max_line_length": 100, "alphanum_fraction": 0.6262019231}
/**
 * Created by yotam on 31/08/2016.
 */
var notificationsTargeter = require("./../../server/services/notifications/notifications-targeter");
var EVENTS = require("./../../server/services/enums").EVENTS;

module.exports = function (Follow) {

  function sendNotifications(){

  }
  Follow.observe('after save', function sendNotifications(ctx, next) {
    console.log("sendNotifications ");
    if (ctx.instance) {
      var followRow = ctx.instance;
      console.log("sendNotifications, followRow: " + JSON.stringify(followRow));
      notificationsTargeter.targetToUsers(EVENTS.USER_FOLLOWED,{
        // event metadata
        follower_data : {
          id : ctx.instance.followerId
        },
        extra_meta : {
        }
      }, {
        targetedUsers : [ctx.instance.followeeId]
      });
    }
    next();
  });

};
