Fixed Twitter notifications

New: Twitter notifications now require a Twitter (see settings for details)

Closes #1049
This commit is contained in:
Mark McDowall
2016-01-06 22:32:12 -08:00
parent 7ca67fe57a
commit a96718f7b3
8 changed files with 65 additions and 32 deletions

View File

@@ -4,14 +4,19 @@ var DeepModel = require('backbone.deepmodel');
var Messenger = require('../Shared/Messenger');
module.exports = DeepModel.extend({
connectData : function(action, initialQueryString) {
connectData : function(action, initialQueryParams) {
var self = this;
this.trigger('connect:sync');
var promise = $.Deferred();
var callAction = function(action) {
var callAction = function(action, queryParams) {
if (queryParams) {
action = action + '?' + $.param(queryParams, true);
}
var params = {
url : self.collection.url + '/connectData/' + action,
contentType : 'application/json',
@@ -30,11 +35,20 @@ module.exports = DeepModel.extend({
{
window.open(response.url);
var selfWindow = window;
selfWindow.onCompleteOauth = function(query, callback) {
delete selfWindow.onCompleteOauth;
if (response.nextStep) {
callAction(response.nextStep + query);
var queryParams = {};
var splitQuery = query.substring(1).split('&');
_.each(splitQuery, function (param) {
var paramSplit = param.split('=');
queryParams[paramSplit[0]] = paramSplit[1];
});
callAction(response.nextStep, _.extend(initialQueryParams, queryParams));
}
else {
promise.resolve(response);
@@ -59,7 +73,7 @@ module.exports = DeepModel.extend({
}
}
if (response.nextStep) {
callAction(response.nextStep);
callAction(response.nextStep, initialQueryParams);
}
else {
promise.resolve(response);
@@ -67,7 +81,7 @@ module.exports = DeepModel.extend({
});
};
callAction(action, initialQueryString);
callAction(action, initialQueryParams);
Messenger.monitor({
promise : promise,