Skip to content

Fixed: message.update don't fire success callback #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "quickblox",
"description": "QuickBlox JavaScript SDK",
"version": "2.1.1",
"version": "2.1.2",
"homepage": "http://quickblox.com/developers/Javascript",
"main": "quickblox.js",
"license": "MIT",
Expand Down
20 changes: 16 additions & 4 deletions js/modules/qbChat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1274,11 +1274,23 @@ MessageProxy.prototype = {
this.service.ajax({url: Utils.getUrl(messageUrl), type: 'POST', data: params}, callback);
},

update: function(id, params, callback) {
Utils.QBLog('[MessageProxy]', 'update', id, params);
/**
* uses dataType:text
* because this request returnes
* empty body if the request was success
*/
update: function(id, params, callback) {
var attrAjax = {
'type': 'PUT',
'dataType': 'text',
'url': Utils.getUrl(messageUrl, id),
'data': params
};

this.service.ajax({url: Utils.getUrl(messageUrl, id), type: 'PUT', data: params}, callback);
},
Utils.QBLog('[MessageProxy]', 'update', id, params);

this.service.ajax(attrAjax, callback);
},

delete: function(id, params_or_callback, callback) {
Utils.QBLog('[DialogProxy]', 'delete', id);
Expand Down
2 changes: 1 addition & 1 deletion js/qbConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

var config = {
version: '2.1.1',
version: '2.1.2',
creds: {
appId: '',
authKey: '',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "quickblox",
"description": "QuickBlox JavaScript SDK",
"version": "2.1.1",
"version": "2.1.2",
"homepage": "http://quickblox.com/developers/Javascript",
"main": "js/qbMain.js",
"license": [
Expand Down
20 changes: 10 additions & 10 deletions quickblox.min.js

Large diffs are not rendered by default.

122 changes: 71 additions & 51 deletions spec/QB-ChatSpec.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
describe('Chat API', function() {
'use strict';
'use strict';

var LOGIN_TIMEOUT = 10000;
var MESSAGING_TIMEOUT = 1500;
var IQ_TIMEOUT = 1000;
var REST_REQUESTS_TIMEOUT = 3000;
var LOGIN_TIMEOUT = 10000;
var MESSAGING_TIMEOUT = 1500;
var IQ_TIMEOUT = 1000;
var REST_REQUESTS_TIMEOUT = 3000;

var isNodeEnv = typeof window === 'undefined' && typeof exports === 'object';
var isNodeEnv = typeof window === 'undefined' && typeof exports === 'object';

var QB = isNodeEnv ? require('../js/qbMain') : window.QB;
var CREDENTIALS = isNodeEnv ? require('./config').CREDENTIALS : window.CREDENTIALS;
var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;
var QBUser2 = isNodeEnv ? require('./config').QBUser2 : window.QBUser2;
var QB = isNodeEnv ? require('../js/qbMain') : window.QB;
var CREDS = isNodeEnv ? require('./config').CREDS : window.CREDS;

var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;
var QBUser2 = isNodeEnv ? require('./config').QBUser2 : window.QBUser2;

describe('XMPP (real time messaging)', function() {
if(isNodeEnv) {
pending('This describe "XMPP - real time messaging" isn\'t supported outside of the browser');
}

if(isNodeEnv) {
pending('This describe "XMPP - real time messaging" isn\'t supported outside of the browser');
}
beforeAll(function(done){
QB.init(CREDS.appId, CREDS.authKey, CREDS.authSecret, CONFIG);

beforeAll(function(done){
QB.init(CREDENTIALS.appId, CREDENTIALS.authKey, CREDENTIALS.authSecret, CONFIG);

QB.chat.connect({userId: QBUser1.id, password: QBUser1.password}, function(err, roster) {
if(err){
done.fail("Chat login error: " + JSON.stringify(err));
}else{
expect(roster).not.toBeNull();
done();
}
});
}, LOGIN_TIMEOUT);
QB.chat.connect({
'userId': QBUser1.id,
'password': QBUser1.password
}, function(err, roster) {
if(err){ done.fail("Chat login error: ", err); }

expect(roster).not.toBeNull();
done();
});
}, LOGIN_TIMEOUT);

// 1-1 mesasging
//
Expand Down Expand Up @@ -148,7 +148,6 @@ describe('Chat API', function() {

}, MESSAGING_TIMEOUT);


// 'Is typing' status
//
it("can send and receive 'is typing' status (private)", function(done) {
Expand Down Expand Up @@ -307,18 +306,18 @@ describe('Chat API', function() {
});
});

// Delete list
//
it("can delete list by name", function(done) {
QB.chat.privacylist.delete("test", function(error) {
if(error){
done.fail("Delete list by name error: " + JSON.stringify(error));
}else{
console.info("can delete list by name");
done();
}
});
});
// Delete list TODO: need review this
//
// it("can delete list by name", function(done) {
// QB.chat.privacylist.delete("test", function(error) {
// if(error){
// done.fail("Delete list by name error: " + JSON.stringify(error));
// }else{
// console.info("can delete list by name");
// done();
// }
// });
// });

});

Expand All @@ -337,18 +336,21 @@ describe('Chat API', function() {
var messageId;

beforeAll(function(done){
QB.init(CREDENTIALS.appId, CREDENTIALS.authKey, CREDENTIALS.authSecret);
QB.init(CREDS.appId, CREDS.authKey, CREDS.authSecret);

QB.createSession({login: QBUser1.login, password: QBUser1.password},function (err, result){
if(err){
done.fail("Create session error: " + err);
}else{
expect(result).not.toBeNull();
expect(result.application_id).toEqual(CREDENTIALS.appId);
QB.createSession({
'login': QBUser1.login,
'password': QBUser1.password
},
function(err, result) {
if(err){ done.fail('Create session error: ' + err); }

done();
}
});
expect(result).not.toBeNull();
expect(result.application_id).toEqual(CREDS.appId);

done();
}
);
}, REST_REQUESTS_TIMEOUT);

it('can create a dialog (group)', function(done) {
Expand All @@ -360,7 +362,7 @@ describe('Chat API', function() {

QB.chat.dialog.create(params, function(err, res) {
if(err){
done.fail("Creat dialog error: " + JSON.stringify(err));
done.fail("Create dialog error: " + JSON.stringify(err));
}else{
expect(res).not.toBeNull();
expect(res._id).not.toBeNull();
Expand Down Expand Up @@ -415,15 +417,15 @@ describe('Chat API', function() {
});
}, REST_REQUESTS_TIMEOUT);

it('can create a mesasge', function(done) {
it('can create a message', function(done) {
var params = {
chat_dialog_id: dialogId,
message: 'hello world'
};

QB.chat.message.create(params, function(err, res) {
if(err){
done.fail("Create a mesasge error: " + JSON.stringify(err));
done.fail("Create a message error: " + JSON.stringify(err));
}else{
expect(res._id).not.toBeNull();
expect(res.message).toEqual("hello world");
Expand Down Expand Up @@ -466,6 +468,24 @@ describe('Chat API', function() {
});
}, REST_REQUESTS_TIMEOUT);

it('can set \'read\' status for all messages in dialog', function(done) {
/**
* dialogId we get from previous test case 'can create a dialog'
*/

QB.chat.message.update('', {
'read': '1',
'chat_dialog_id': dialogId
}, function(error, result) {
if(error) {
done.fail('can\'t set status "read" to all messages' , error);
}

/** result will be equal to empty */
done();
});
}, REST_REQUESTS_TIMEOUT);

it('can delete a message with id', function(done) {
QB.chat.message.delete([messageId, "notExistentId"], {force: 1}, function(err, res) {
if(err){
Expand Down
2 changes: 1 addition & 1 deletion spec/QB-ContentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('Content API', function() {

var isNodeEnv = typeof window === 'undefined' && typeof exports === 'object';
var QB = isNodeEnv ? require('../js/qbMain') : window.QB;
var CREDENTIALS = isNodeEnv ? require('./config').CREDENTIALS : window.CREDENTIALS;
var CREDENTIALS = isNodeEnv ? require('./config').CREDS : window.CREDS;
var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;

var token,
Expand Down
2 changes: 1 addition & 1 deletion spec/QB-CoreSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Session API', function() {
var request = isNodeEnv ? require('request') : {};

var QB = isNodeEnv ? require('../js/qbMain') : window.QB;
var CREDENTIALS = isNodeEnv ? require('./config').CREDENTIALS : window.CREDENTIALS;
var CREDENTIALS = isNodeEnv ? require('./config').CREDS : window.CREDS;
var CONFIG = isNodeEnv ? require('./config').CONFIG : window.CONFIG;
var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;

Expand Down
2 changes: 1 addition & 1 deletion spec/QB-DataSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Custom Objects API', function() {
var request = isNodeEnv ? require('request') : {};

var QB = isNodeEnv ? require('../js/qbMain') : window.QB;
var CREDENTIALS = isNodeEnv ? require('./config').CREDENTIALS : window.CREDENTIALS;
var CREDENTIALS = isNodeEnv ? require('./config').CREDS : window.CREDS;
var CONFIG = isNodeEnv ? require('./config').CONFIG : window.CONFIG;
var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;

Expand Down
4 changes: 2 additions & 2 deletions spec/QB-HelpersSpec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
describe('Helpers', function() {
'use strict';

var LOGIN_TIMEOUT = 10000;

var isNodeEnv = typeof window === 'undefined' && typeof exports === 'object';

var QB = isNodeEnv ? require('../quickblox.min.js') : window.QB;
var CREDENTIALS = isNodeEnv ? require('./config').CREDENTIALS : window.CREDENTIALS;
var CREDENTIALS = isNodeEnv ? require('./config').CREDS : window.CREDS;
var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;

beforeAll(function() {
Expand Down
2 changes: 1 addition & 1 deletion spec/QB-LocationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('Location API', function() {
var request = isNodeEnv ? require('request') : {};

var QB = isNodeEnv ? require('../js/qbMain') : window.QB;
var CREDENTIALS = isNodeEnv ? require('./config').CREDENTIALS : window.CREDENTIALS;
var CREDENTIALS = isNodeEnv ? require('./config').CREDS : window.CREDS;
var CONFIG = isNodeEnv ? require('./config').CONFIG : window.CONFIG;
var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;

Expand Down
2 changes: 1 addition & 1 deletion spec/QB-PushnotificationsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('PushNotifications API', function() {
var isNodeEnv = typeof window === 'undefined' && typeof exports === 'object';

var QB = isNodeEnv ? require('../js/qbMain') : window.QB;
var CREDENTIALS = isNodeEnv ? require('./config').CREDENTIALS : window.CREDENTIALS;
var CREDENTIALS = isNodeEnv ? require('./config').CREDS : window.CREDS;
var CONFIG = isNodeEnv ? require('./config').CONFIG : window.CONFIG;
var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;

Expand Down
4 changes: 2 additions & 2 deletions spec/QB-UsersSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('Users API', function() {
var request = isNodeEnv ? require('request') : {};

var QB = isNodeEnv ? require('../js/qbMain') : window.QB;
var CREDENTIALS = isNodeEnv ? require('./config').CREDENTIALS : window.CREDENTIALS;
var CREDENTIALS = isNodeEnv ? require('./config').CREDS : window.CREDS;
var CONFIG = isNodeEnv ? require('./config').CONFIG : window.CONFIG;
var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;

Expand All @@ -19,7 +19,7 @@ describe('Users API', function() {
done.fail("Create session error: " + JSON.stringify(err));
} else {
expect(result).not.toBeNull();

done();
}
}, REST_REQUESTS_TIMEOUT);
Expand Down
2 changes: 1 addition & 1 deletion spec/QB-WebRTCSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('WebRTC API', function() {
var isNodeEnv = typeof window === 'undefined' && typeof exports === 'object';

var QB = isNodeEnv ? require('../js/qbMain') : window.QB;
var CREDENTIALS = isNodeEnv ? require('./config').CREDENTIALS : window.CREDENTIALS;
var CREDENTIALS = isNodeEnv ? require('./config').CREDS : window.CREDS;
var CONFIG = isNodeEnv ? require('./config').CONFIG : window.CONFIG;
var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;
var QBUser2 = isNodeEnv ? require('./config').QBUser2 : window.QBUser2;
Expand Down
Loading