Skip to content

Instantly share code, notes, and snippets.

@jacobjuul
Last active October 5, 2016 10:10
Show Gist options
  • Select an option

  • Save jacobjuul/484a17f7869ed2510b712f4ee216a925 to your computer and use it in GitHub Desktop.

Select an option

Save jacobjuul/484a17f7869ed2510b712f4ee216a925 to your computer and use it in GitHub Desktop.

Revisions

  1. jacobjuul revised this gist Oct 5, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion notifcaitonsender.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    // ActivityView.js
    notificationSender(notificationTypes.USER_UNJOINED_ACTIVITY_USER, {
    payload: { activity: activity },
    payload: { activity },
    sender: userId
    });

  2. jacobjuul revised this gist Oct 5, 2016. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions notifcaitonsender.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    // ActivityView.js
    notificationSender(notificationTypes.USER_UNJOINED_ACTIVITY_USER, {
    payload: { activity: activity },
    sender: userId
    @@ -9,7 +10,7 @@ notificationSender(notificationTypes.USER_UNJOINED_ACTIVITY_COACH, {
    reciever: activity.coachId
    });


    // notficationHandler.js
    export const notificationSender = (notificationType, { sender, reciever, payload }) => {
    switch(notificationType) {
    case types.USER_JOINED_ACTIVITY_COACH:
    @@ -34,7 +35,7 @@ export const notificationSender = (notificationType, { sender, reciever, payload
    }
    };


    // notificationMethods.js
    export function userUnjoinedActivity(notificationType, { sender, reciever, payload }) {
    const userId = user._id;

  3. jacobjuul revised this gist Oct 5, 2016. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions notifcaitonsender.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,15 @@
    notificationSender(notificationTypes.USER_UNJOINED_ACTIVITY_USER, {
    payload: { activity: activity },
    sender: userId
    });

    notificationSender(notificationTypes.USER_UNJOINED_ACTIVITY_COACH, {
    payload: { activityId: activity._id },
    sender: userId,
    reciever: activity.coachId
    });


    export const notificationSender = (notificationType, { sender, reciever, payload }) => {
    switch(notificationType) {
    case types.USER_JOINED_ACTIVITY_COACH:
  4. jacobjuul revised this gist Oct 5, 2016. No changes.
  5. jacobjuul revised this gist Oct 5, 2016. 1 changed file with 28 additions and 1 deletion.
    29 changes: 28 additions & 1 deletion notifcaitonsender.js
    Original file line number Diff line number Diff line change
    @@ -20,4 +20,31 @@ export const notificationSender = (notificationType, { sender, reciever, payload
    default:
    break;
    }
    };
    };


    export function userUnjoinedActivity(notificationType, { sender, reciever, payload }) {
    const userId = user._id;

    if (notificationType === types.USER_UNJOINED_ACTIVITY_USER)
    // send notification to user
    Notification.insert({
    createdBy: sender,
    targetId: sender,
    type: notificationType,
    data: payload.activity,
    message: `Du har afmeldt dig fra ${payload.activity.title}`,
    activityId: payload.activity._id
    });
    } else {
    // send notification to coach
    Notification.insert({
    createdBy: sender,
    targetId: reciever,
    type: notificationType,
    data: payload.activity,
    message: `Du har afmeldt dig fra ${payload.activity.title}`,
    activityId: payload.activity._id
    });
    }
    }
  6. jacobjuul created this gist Oct 5, 2016.
    23 changes: 23 additions & 0 deletions notifcaitonsender.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    export const notificationSender = (notificationType, { sender, reciever, payload }) => {
    switch(notificationType) {
    case types.USER_JOINED_ACTIVITY_COACH:
    break;

    case types.USER_JOINED_ACTIVITY_USER:
    break;

    case types.USER_UNJOINED_ACTIVITY_COACH:
    userUnjoinedActivity(notificationType, { sender, reciever, payload });
    break;

    case types.USER_UNJOINED_ACTIVITY_USER:
    userUnjoinedActivity(notificationType, { sender, reciever, payload });
    break;

    case types.USER_ENQUIRED_PACKAGE_COACH:
    break;

    default:
    break;
    }
    };