From 6e8a3d205969c9be54675b5e3033c7fddc8a82e6 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Jun 21 2017 13:41:17 +0000 Subject: A Feed widget is linked to its hub, not to a username --- diff --git a/hubs/widgets/feed/__init__.py b/hubs/widgets/feed/__init__.py index f8ed081..730150d 100644 --- a/hubs/widgets/feed/__init__.py +++ b/hubs/widgets/feed/__init__.py @@ -20,12 +20,6 @@ class Feed(Widget): position = "left" parameters = [ { - "name": "username", - "label": "User name", - "default": None, - "validator": validators.Username, - "help": "A user name.", - }, { "name": "message_limit", "label": "Message limit", "default": 20, @@ -44,7 +38,6 @@ class BaseView(WidgetView): def get_context(self, instance, *args, **kwargs): # Avoid circular import from hubs.app import app - username = instance.config["username"] sse_url = app.config['SSE_URL'] + username return dict( title=self.widget.label, @@ -60,7 +53,6 @@ class ExistingView(WidgetView): json = True def get_context(self, instance, *args, **kwargs): - username = instance.config["username"] get_data = GetData(instance) existing = get_data() return { diff --git a/hubs/widgets/feed/functions.py b/hubs/widgets/feed/functions.py index afe2836..da6d8df 100644 --- a/hubs/widgets/feed/functions.py +++ b/hubs/widgets/feed/functions.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals, absolute_import -import flask import fedmsg.meta from hubs.feed import Activity, format_msg @@ -12,8 +11,8 @@ class GetData(CachedFunction): """Get the feed data from Redis and aggregate it.""" def execute(self): - username = self.instance.config["username"] - feed = Activity(username) + hub_name = self.instance.hub.name + feed = Activity(hub_name) raw_msgs = feed.get() # TODO: paging? msgs = fedmsg.meta.conglomerate(raw_msgs) msgs = [format_msg(msg) for msg in msgs] @@ -23,5 +22,5 @@ class GetData(CachedFunction): def should_invalidate(self, message): if "_hubs" not in message: return False - username = self.instance.config["username"] - return (username in message["_hubs"]) + hub_name = self.instance.hub.name + return (hub_name in message["_hubs"])