VRFS-933 notification work
This commit is contained in:
parent
7e78163bb9
commit
1806c5245f
|
|
@ -316,25 +316,46 @@ module JamRuby
|
|||
# (1) save to database
|
||||
notification = Notification.new
|
||||
notification.description = NotificationTypes::NEW_USER_FOLLOWER
|
||||
notification.source_user_id = sender.id
|
||||
notification.target_user_id = receiver.id
|
||||
notification.session_id = session_id
|
||||
notification.source_user_id = follower.id
|
||||
notification.target_user_id = user.id
|
||||
notification.save
|
||||
|
||||
# (2) create notification
|
||||
msg = @@message_factory.session_invitation(
|
||||
receiver_id,
|
||||
sender.name,
|
||||
session_id,
|
||||
notification_msg = format_msg(notification.description, follower)
|
||||
msg = @@message_factory.new_user_follower(
|
||||
user.id,
|
||||
follower.name,
|
||||
follower.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
|
||||
# (3) send notification
|
||||
@@mq_router.publish_to_user(receiver.id, msg)
|
||||
@@mq_router.publish_to_user(user.id, msg)
|
||||
end
|
||||
|
||||
def send_new_band_follower(follower, band)
|
||||
# (1) save to database
|
||||
notification = Notification.new
|
||||
notification.description = NotificationTypes::NEW_BAND_FOLLOWER
|
||||
notification.source_user_id = follower.id
|
||||
notification.target_user_id = user.id
|
||||
notification.save
|
||||
|
||||
# (2) create notification
|
||||
notification_msg = format_msg(notification.description, follower, band)
|
||||
msg = @@message_factory.new_user_follower(
|
||||
user.id,
|
||||
follower.name,
|
||||
follower.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
|
||||
# (3) send notification
|
||||
@@mq_router.publish_to_user(user.id, msg)
|
||||
end
|
||||
|
||||
################## SESSION INVITATION ##################
|
||||
|
|
@ -440,7 +461,6 @@ module JamRuby
|
|||
music_session.id,
|
||||
music_session.creator.name,
|
||||
music_session.creator.photo_url,
|
||||
notification_msg,
|
||||
notification.id,
|
||||
notification.created_at.to_s
|
||||
)
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
function beforeShow(data) {
|
||||
userId = data.id;
|
||||
user = null;
|
||||
user = null;
|
||||
}
|
||||
|
||||
function afterShow(data) {
|
||||
|
|
@ -46,83 +46,83 @@
|
|||
$('.profile-nav a.#profile-about-link').addClass('active');
|
||||
}
|
||||
|
||||
function getUser() {
|
||||
if (user === null) {
|
||||
var url = "/api/users/" + userId;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData:false,
|
||||
success: function(response) {
|
||||
user = response;
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorMessage) {
|
||||
user = null;
|
||||
app.ajaxError(jqXHR, textStatus, errorMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
return user;
|
||||
}
|
||||
function getUser() {
|
||||
if (user === null) {
|
||||
var url = "/api/users/" + userId;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData:false,
|
||||
success: function(response) {
|
||||
user = response;
|
||||
},
|
||||
error: function(jqXHR, textStatus, errorMessage) {
|
||||
user = null;
|
||||
app.ajaxError(jqXHR, textStatus, errorMessage);
|
||||
}
|
||||
});
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
function isMusician() {
|
||||
if (getUser()) {
|
||||
return user.musician === true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function isMusician() {
|
||||
if (getUser()) {
|
||||
return user.musician === true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isCurrentUser() {
|
||||
return userId === context.JK.currentUserId;
|
||||
}
|
||||
function isCurrentUser() {
|
||||
return userId === context.JK.currentUserId;
|
||||
}
|
||||
|
||||
function configureUserType() {
|
||||
if (isMusician()) {
|
||||
$('#profile-history-link').show();
|
||||
$('#profile-bands-link').show();
|
||||
$('#profile-instruments').show();
|
||||
$('#profile-session-stats').show();
|
||||
$('#profile-recording-stats').show();
|
||||
function configureUserType() {
|
||||
if (isMusician()) {
|
||||
$('#profile-history-link').show();
|
||||
$('#profile-bands-link').show();
|
||||
$('#profile-instruments').show();
|
||||
$('#profile-session-stats').show();
|
||||
$('#profile-recording-stats').show();
|
||||
|
||||
// $('#profile-following-stats').hide();
|
||||
// $('#profile-favorites-stats').hide();
|
||||
// $('#profile-following-stats').hide();
|
||||
// $('#profile-favorites-stats').hide();
|
||||
|
||||
$('#btn-add-friend').show();
|
||||
$('#btn-add-friend').show();
|
||||
$('.profile-social-left').show();
|
||||
|
||||
$('#profile-type-label').text('musician');
|
||||
$('#profile-location-label').text('Location');
|
||||
$('#profile-type-label').text('musician');
|
||||
$('#profile-location-label').text('Location');
|
||||
|
||||
} else {
|
||||
$('#profile-history-link').hide();
|
||||
$('#profile-bands-link').hide();
|
||||
$('#profile-instruments').hide();
|
||||
$('#profile-session-stats').hide();
|
||||
$('#profile-recording-stats').hide();
|
||||
} else {
|
||||
$('#profile-history-link').hide();
|
||||
$('#profile-bands-link').hide();
|
||||
$('#profile-instruments').hide();
|
||||
$('#profile-session-stats').hide();
|
||||
$('#profile-recording-stats').hide();
|
||||
|
||||
// $('#profile-following-stats').show();
|
||||
// $('#profile-favorites-stats').show();
|
||||
|
||||
$('#btn-add-friend').hide();
|
||||
// $('#profile-following-stats').show();
|
||||
// $('#profile-favorites-stats').show();
|
||||
|
||||
$('#btn-add-friend').hide();
|
||||
$('.profile-social-left').hide();
|
||||
|
||||
$('#profile-type-label').text('fan');
|
||||
$('#profile-location-label').text('Presence');
|
||||
}
|
||||
$('#profile-type-label').text('fan');
|
||||
$('#profile-location-label').text('Presence');
|
||||
}
|
||||
|
||||
if (isCurrentUser()) {
|
||||
if (isCurrentUser()) {
|
||||
$('#btn-profile-edit').show();
|
||||
} else {
|
||||
} else {
|
||||
$('#btn-profile-edit').hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************** MAIN PORTION OF SCREEN *****************/
|
||||
// events for main screen
|
||||
function events() {
|
||||
configureUserType();
|
||||
configureUserType();
|
||||
|
||||
// wire up panel clicks
|
||||
$('#profile-about-link').click(renderAbout);
|
||||
|
|
@ -168,7 +168,7 @@
|
|||
}
|
||||
|
||||
function isFriend() {
|
||||
return getUser() ? user.is_friend : false;
|
||||
return getUser() ? user.is_friend : false;
|
||||
}
|
||||
|
||||
function friendRequestCallback() {
|
||||
|
|
@ -240,7 +240,7 @@
|
|||
}
|
||||
|
||||
function isFollowing() {
|
||||
return getUser() ? user.is_following : false;
|
||||
return getUser() ? user.is_following : false;
|
||||
}
|
||||
|
||||
function configureFollowingButton(following) {
|
||||
|
|
@ -338,18 +338,18 @@
|
|||
text = user.follower_count > 1 || user.follower_count === 0 ? " Followers" : " Follower";
|
||||
$('#profile-follower-stats').html(user.follower_count + text);
|
||||
|
||||
if (isMusician()) {
|
||||
if (isMusician()) {
|
||||
text = user.session_count > 1 || user.session_count === 0 ? " Sessions" : " Session";
|
||||
$('#profile-session-stats').html(user.session_count + text);
|
||||
|
||||
text = user.recording_count > 1 || user.recording_count === 0 ? " Recordings" : " Recording";
|
||||
$('#profile-recording-stats').html(user.recording_count + text);
|
||||
} else {
|
||||
} else {
|
||||
text = " Following";
|
||||
$('#profile-following-stats').html(user.following_count + text);
|
||||
text = user.favorite_count > 1 || user.favorite_count === 0 ? " Favorites" : " Favorite";
|
||||
$('#profile-favorite-stats').html(user.favorite_count + text);
|
||||
}
|
||||
}
|
||||
|
||||
$('#profile-biography').html(user.biography);
|
||||
}
|
||||
|
|
@ -373,41 +373,41 @@
|
|||
$('.profile-nav a.active').removeClass('active');
|
||||
$('.profile-nav a.#profile-social-link').addClass('active');
|
||||
|
||||
/*if (isMusician()) {
|
||||
/*if (isMusician()) {
|
||||
$('.profile-social-left').show();
|
||||
} else {
|
||||
} else {
|
||||
$('.profile-social-left').hide();
|
||||
}*/
|
||||
}*/
|
||||
|
||||
bindSocial();
|
||||
}
|
||||
|
||||
function bindSocial() {
|
||||
if (isMusician()) {
|
||||
// FRIENDS
|
||||
var url = "/api/users/" + userId + "/friends";
|
||||
$.ajax({
|
||||
if (isMusician()) {
|
||||
// FRIENDS
|
||||
var url = "/api/users/" + userId + "/friends";
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: url,
|
||||
async: false,
|
||||
processData:false,
|
||||
success: function(response) {
|
||||
$.each(response, function(index, val) {
|
||||
$.each(response, function(index, val) {
|
||||
var template = $('#template-profile-social').html();
|
||||
var friendHtml = context.JK.fillTemplate(template, {
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location,
|
||||
type: "Friends"
|
||||
avatar_url: context.JK.resolveAvatarUrl(val.photo_url),
|
||||
userName: val.name,
|
||||
location: val.location,
|
||||
type: "Friends"
|
||||
});
|
||||
|
||||
$('#profile-social-friends').append(friendHtml);
|
||||
});
|
||||
});
|
||||
},
|
||||
error: app.ajaxError
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// FOLLOWINGS (USERS)
|
||||
url = "/api/users/" + userId + "/followings";
|
||||
|
|
|
|||
|
|
@ -161,6 +161,10 @@
|
|||
$notification.find('#div-actions').hide();
|
||||
}
|
||||
|
||||
else if (type === context.JK.MessageType.NEW_USER_FOLLOWER || type === context.JK.MessageType.NEW_BAND_FOLLOWER) {
|
||||
$notification.find('#div-actions').hide();
|
||||
}
|
||||
|
||||
else if (type === context.JK.MessageType.SESSION_INVITATION) {
|
||||
var $action_btn = $notification.find('#btn-notification-action');
|
||||
$action_btn.text('JOIN');
|
||||
|
|
|
|||
Loading…
Reference in New Issue