mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-19 12:58:29 +00:00
Resubscribing to real-time feeds on add/remove feed.
This commit is contained in:
parent
a74be1b604
commit
4348e7f497
5 changed files with 23 additions and 6 deletions
|
@ -58,7 +58,9 @@ def push_callback(request, push_id):
|
||||||
callback=request.build_absolute_uri(),
|
callback=request.build_absolute_uri(),
|
||||||
lease_seconds=seconds)
|
lease_seconds=seconds)
|
||||||
|
|
||||||
subscription.feed.queue_pushed_feed_xml(request.raw_post_data)
|
# subscription.feed.queue_pushed_feed_xml(request.raw_post_data)
|
||||||
|
# Don't give fat ping, just fetch.
|
||||||
|
subscription.feed.queue_pushed_feed_xml("Fetch me")
|
||||||
|
|
||||||
updated.send(sender=subscription, update=parsed)
|
updated.send(sender=subscription, update=parsed)
|
||||||
return HttpResponse('')
|
return HttpResponse('')
|
||||||
|
|
|
@ -1098,8 +1098,12 @@
|
||||||
this.add_url_from_querystring();
|
this.add_url_from_querystring();
|
||||||
_.defer(_.bind(function() {
|
_.defer(_.bind(function() {
|
||||||
this.model.load_feed_favicons($.rescope(this.make_feed_favicons, this), this.flags['favicons_downloaded'], this.flags['has_chosen_feeds']);
|
this.model.load_feed_favicons($.rescope(this.make_feed_favicons, this), this.flags['favicons_downloaded'], this.flags['has_chosen_feeds']);
|
||||||
var force_socket = NEWSBLUR.Globals.is_admin;
|
if (this.socket) {
|
||||||
this.setup_socket_realtime_unread_counts(force_socket);
|
this.send_socket_active_feeds();
|
||||||
|
} else {
|
||||||
|
var force_socket = NEWSBLUR.Globals.is_admin;
|
||||||
|
this.setup_socket_realtime_unread_counts(force_socket);
|
||||||
|
}
|
||||||
}, this));
|
}, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -5257,9 +5261,8 @@
|
||||||
|
|
||||||
// this.socket.refresh_feeds = _.debounce(_.bind(this.force_feeds_refresh, this), 1000*10);
|
// this.socket.refresh_feeds = _.debounce(_.bind(this.force_feeds_refresh, this), 1000*10);
|
||||||
this.socket.on('connect', _.bind(function() {
|
this.socket.on('connect', _.bind(function() {
|
||||||
var active_feeds = _.compact(_.map(this.model.feeds, function(feed) { return feed.active && feed.id; }));
|
|
||||||
console.log(["Connected to pubsub", this.socket, active_feeds.length]);
|
console.log(["Connected to pubsub", this.socket, active_feeds.length]);
|
||||||
this.socket.emit('subscribe:feeds', active_feeds);
|
this.send_socket_active_feeds();
|
||||||
this.socket.on('feed:update', _.bind(function(feed_id, message) {
|
this.socket.on('feed:update', _.bind(function(feed_id, message) {
|
||||||
console.log(['Feed update', feed_id, message]);
|
console.log(['Feed update', feed_id, message]);
|
||||||
this.force_feeds_refresh(false, false, parseInt(feed_id, 10));
|
this.force_feeds_refresh(false, false, parseInt(feed_id, 10));
|
||||||
|
@ -5271,6 +5274,16 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
send_socket_active_feeds: function() {
|
||||||
|
if (!this.socket) return;
|
||||||
|
|
||||||
|
var active_feeds = _.compact(_.map(this.model.feeds, function(feed) {
|
||||||
|
return feed.active && feed.id;
|
||||||
|
}));
|
||||||
|
|
||||||
|
this.socket.emit('subscribe:feeds', active_feeds);
|
||||||
|
},
|
||||||
|
|
||||||
setup_feed_refresh: function(new_feeds) {
|
setup_feed_refresh: function(new_feeds) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var refresh_interval = this.constants.FEED_REFRESH_INTERVAL;
|
var refresh_interval = this.constants.FEED_REFRESH_INTERVAL;
|
||||||
|
|
|
@ -6,6 +6,7 @@ client = redis.createClient 6379, 'db01'
|
||||||
io.sockets.on 'connection', (socket) ->
|
io.sockets.on 'connection', (socket) ->
|
||||||
|
|
||||||
socket.on 'subscribe:feeds', (feeds) ->
|
socket.on 'subscribe:feeds', (feeds) ->
|
||||||
|
socket.subscribe?.end()
|
||||||
socket.subscribe = redis.createClient 6379, 'db01'
|
socket.subscribe = redis.createClient 6379, 'db01'
|
||||||
|
|
||||||
console.log "Subscribing to #{feeds.length} feeds"
|
console.log "Subscribing to #{feeds.length} feeds"
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
|
|
||||||
io.sockets.on('connection', function(socket) {
|
io.sockets.on('connection', function(socket) {
|
||||||
socket.on('subscribe:feeds', function(feeds) {
|
socket.on('subscribe:feeds', function(feeds) {
|
||||||
|
var _ref;
|
||||||
|
if ((_ref = socket.subscribe) != null) _ref.end();
|
||||||
socket.subscribe = redis.createClient(6379, 'db01');
|
socket.subscribe = redis.createClient(6379, 'db01');
|
||||||
console.log("Subscribing to " + feeds.length + " feeds");
|
console.log("Subscribing to " + feeds.length + " feeds");
|
||||||
socket.subscribe.subscribe(feeds);
|
socket.subscribe.subscribe(feeds);
|
||||||
|
|
|
@ -64,7 +64,6 @@ class FetchFeed:
|
||||||
settings.NEWSBLUR_URL
|
settings.NEWSBLUR_URL
|
||||||
)
|
)
|
||||||
if self.options.get('feed_xml'):
|
if self.options.get('feed_xml'):
|
||||||
feed_xml = self.options.get('feed_xml')
|
|
||||||
logging.debug(u' ---> [%-30s] ~FM~BKFeed has been fat pinged. Ignoring fat: %s' % (
|
logging.debug(u' ---> [%-30s] ~FM~BKFeed has been fat pinged. Ignoring fat: %s' % (
|
||||||
unicode(self.feed)[:30], len(feed_xml)))
|
unicode(self.feed)[:30], len(feed_xml)))
|
||||||
if self.options.get('fpf'):
|
if self.options.get('fpf'):
|
||||||
|
|
Loading…
Add table
Reference in a new issue