Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop
This commit is contained in:
commit
f8b3d8cc7d
|
|
@ -242,3 +242,4 @@ active_jam_track.sql
|
|||
bpms_on_tap_in.sql
|
||||
jamtracks_job.sql
|
||||
text_messages.sql
|
||||
text_message_migration.sql
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
insert into text_messages(source_user_id, target_user_id, message, created_at, updated_at) (
|
||||
select source_user_id, target_user_id, message, created_at, updated_at
|
||||
from notifications
|
||||
where description='TEXT_MESSAGE'
|
||||
);
|
||||
|
|
@ -41,9 +41,10 @@ module JamRuby
|
|||
tm.message = sanitized_text
|
||||
tm.target_user_id = target_user_id
|
||||
tm.source_user_id = source_user_id
|
||||
tm.save
|
||||
|
||||
# send notification
|
||||
@notification = Notification.send_text_message(sanitized_text, source_user_id, User.find_by_id(target_user_id))
|
||||
@notification = Notification.send_text_message(sanitized_text, User.find(source_user_id), User.find(target_user_id))
|
||||
|
||||
tm
|
||||
end
|
||||
|
|
|
|||
|
|
@ -37,14 +37,14 @@
|
|||
}
|
||||
|
||||
function buildParams() {
|
||||
return { type: 'TEXT_MESSAGE', receiver: otherId, offset: offset, limit: LIMIT};
|
||||
return { target_user_id: otherId, offset: offset, limit: LIMIT};
|
||||
}
|
||||
|
||||
function buildMessage() {
|
||||
var message = {};
|
||||
|
||||
message['message'] = $textBox.val();
|
||||
message['receiver'] = otherId;
|
||||
message['target_user_id'] = otherId;
|
||||
|
||||
return message;
|
||||
}
|
||||
|
|
@ -66,17 +66,17 @@
|
|||
$sendTextMessage.text('SENDING...')
|
||||
|
||||
rest.createTextMessage(buildMessage())
|
||||
.done(function() {
|
||||
$textBox.val('');
|
||||
renderMessage(msg, user.id, user.name, new Date().toISOString(), true);
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
app.notifyServerError(jqXHR, 'Unable to Send Message');
|
||||
})
|
||||
.always(function() {
|
||||
sendingMessage = false;
|
||||
$sendTextMessage.text('SEND');
|
||||
})
|
||||
.done(function() {
|
||||
$textBox.val('');
|
||||
renderMessage(msg, user.id, user.name, new Date().toISOString(), true);
|
||||
})
|
||||
.fail(function(jqXHR) {
|
||||
app.notifyServerError(jqXHR, 'Unable to Send Message');
|
||||
})
|
||||
.always(function() {
|
||||
sendingMessage = false;
|
||||
$sendTextMessage.text('SEND');
|
||||
});
|
||||
|
||||
}
|
||||
return false;
|
||||
|
|
@ -163,8 +163,7 @@
|
|||
}
|
||||
$sendTextMessage.click(sendMessage);
|
||||
|
||||
// TODO: PULL FROM NEW TABLE
|
||||
rest.getNotifications(buildParams())
|
||||
rest.getTextMessages(buildParams())
|
||||
.done(function (response) {
|
||||
context._.each(response, function (textMessage) {
|
||||
renderMessage(textMessage.message, textMessage.source_user_id, userLookup[textMessage.source_user_id].name, textMessage.created_at);
|
||||
|
|
|
|||
|
|
@ -1258,12 +1258,11 @@
|
|||
});
|
||||
}
|
||||
|
||||
// TODO: push into new table
|
||||
function createTextMessage(options) {
|
||||
var id = getId(options);
|
||||
return $.ajax({
|
||||
type: "POST",
|
||||
url: '/api/users/' + id + '/notifications',
|
||||
url: '/api/text_messages',
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(options)
|
||||
|
|
@ -1275,7 +1274,7 @@
|
|||
var id = getId(options);
|
||||
return $.ajax({
|
||||
type: "GET",
|
||||
url: '/api/users/' + id + '/text_messages?' + $.param(options),
|
||||
url: '/api/text_messages?' + $.param(options),
|
||||
dataType: "json",
|
||||
contentType: 'application/json'
|
||||
});
|
||||
|
|
@ -1587,6 +1586,7 @@
|
|||
this.tweet = tweet;
|
||||
this.createFbInviteUrl = createFbInviteUrl;
|
||||
this.createTextMessage = createTextMessage;
|
||||
this.getTextMessages = getTextMessages;
|
||||
this.getNotifications = getNotifications;
|
||||
this.createChatMessage = createChatMessage;
|
||||
this.getChatMessages = getChatMessages;
|
||||
|
|
|
|||
|
|
@ -2,17 +2,17 @@ require 'sanitize'
|
|||
class ApiTextMessagesController < ApiController
|
||||
|
||||
before_filter :api_signed_in_user
|
||||
before_filter :auth_user, :only => [:index, :create]
|
||||
|
||||
respond_to :json
|
||||
|
||||
def index
|
||||
@text_messages = TextMessage.index(params[:target_user_id], @user.id, {:offset => params[:offset]})
|
||||
@text_messages = TextMessage.index(params[:target_user_id], current_user.id, {:offset => params[:offset]})
|
||||
respond_with @text_messages, responder: ApiResponder, :status => 200
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@text_message = TextMessage.create(params[:message], params[:target_user_id], current_user.id)
|
||||
respond_with_model(@text_message, new: true)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -194,7 +194,7 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
|
|||
|
||||
describe "start session behavior" do
|
||||
before(:each) do
|
||||
stub_const("APP_CONFIG", web_config)
|
||||
|
||||
@music_session = FactoryGirl.create(:music_session, creator: user)
|
||||
|
||||
@invited_user = FactoryGirl.create(:user)
|
||||
|
|
@ -209,7 +209,6 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
|
|||
|
||||
it "should always show start session link for session creator" do
|
||||
pending
|
||||
# sign in as creator
|
||||
fast_signin(user, Nav.find_session)
|
||||
find("#sessions-scheduled .rsvp-msg span.text a.start", text: "Start session now?")
|
||||
fast_signout
|
||||
|
|
|
|||
Loading…
Reference in New Issue