From 94df77262dbb38e338ae6a7cf22fcabd3647ba9f Mon Sep 17 00:00:00 2001 From: Shaily Date: Mar 20 2018 13:50:01 +0000 Subject: Remove FMN handling --- diff --git a/hubs/backend/triage.py b/hubs/backend/triage.py index 7acb70d..9ca4857 100755 --- a/hubs/backend/triage.py +++ b/hubs/backend/triage.py @@ -47,15 +47,6 @@ def triage(msg): log.debug(" Dropping junk %r", topic) return - # Handle user notifications. - # XXX: use the proper topic pattern when it's chosen - if ".fmn.notification." in topic: - yield retask.task.Task(json.dumps({ - 'type': 'notification', - 'msg': msg, - })) - return # Notifications don't appear anywhere else, stop here. - # Handle FAS changes. if '.fas.group.member.' in topic: hub = hubs.models.Hub.by_name(msg["msg"]["group"], "team") diff --git a/hubs/backend/worker.py b/hubs/backend/worker.py index a493989..15992a4 100755 --- a/hubs/backend/worker.py +++ b/hubs/backend/worker.py @@ -121,15 +121,6 @@ def main(debug): item["idx"], "hub/{}".format(item["hub"]), ) - elif item_type == "notification": - hubs.feed.on_new_notification(item["msg"]) - username = fedmsg.meta.msg2agent(item["msg"]) - add_sse_task( - sse_queue, - "hubs:new-notification", - username, - "user/{}".format(username), - ) elif item_type == "sync-team-hub": with hubs.app.app.app_context(): # so url_for works affected_users = fas.sync_team_hub( diff --git a/hubs/tests/test_feed.py b/hubs/tests/test_feed.py index 0c38ced..b4877e5 100644 --- a/hubs/tests/test_feed.py +++ b/hubs/tests/test_feed.py @@ -7,9 +7,8 @@ from mock import MagicMock, Mock, patch from hubs.app import app from hubs.models import User, Hub, Association -from hubs.feed import ( - Notifications, Activity, add_notif_id, format_msgs, get_hubs_for_msg, - on_new_message, on_new_notification) +from hubs.feed import (Activity, add_notif_id, format_msgs, + get_hubs_for_msg, on_new_message) from hubs.tests import APPTest @@ -18,7 +17,6 @@ class FeedTest(APPTest): def setUp(self): super(FeedTest, self).setUp() self.feed_classes = [ - (Notifications, "notif"), (Activity, "activity"), ] @@ -67,9 +65,7 @@ class FeedTest(APPTest): feed.db.insert_one.assert_called_once() insert_call_args = feed.db.insert_one.call_args_list[0][0] inserted_msg = json.loads(insert_call_args[0]["msg"]) - if feed_class == Notifications: - self.assertIn("msg_ids", inserted_msg) - elif feed_class == Activity: + if feed_class == Activity: self.assertEqual(inserted_msg, msg) def test_length(self): @@ -100,28 +96,6 @@ class FeedTest(APPTest): self.assertEqual(feed.add.call_count, 2) feed.add.assert_called_with(msg) - @patch("hubs.feed.Notifications") - def test_on_new_notification(self, mock_notifications): - feed = Mock() - mock_notifications.return_value = feed - msg = {"msg_id": "testmsg"} - with patch("hubs.feed.fedmsg.meta.msg2agent") as msg2agent: - msg2agent.return_value = "ralph" - on_new_notification(msg) - msg2agent.assert_called() - stream = Hub.by_name("ralph", "stream") - mock_notifications.assert_called_with(stream.id) - feed.add.assert_called_with(msg) - - @patch("hubs.feed.Notifications") - def test_on_new_notification_unknown_user(self, mock_notifications): - with patch("hubs.feed.fedmsg.meta.msg2agent") as msg2agent: - msg2agent.return_value = "unknown_user" - on_new_notification({"msg_id": "testmsg"}) - msg2agent.assert_called() - # User does not exist, no feed instance should have been created. - mock_notifications.assert_not_called() - def test_add_notif_id(self): msg = { "msg_ids": { diff --git a/js/app/core/actions/sse.js b/js/app/core/actions/sse.js index fac58b3..ae77632 100644 --- a/js/app/core/actions/sse.js +++ b/js/app/core/actions/sse.js @@ -40,12 +40,10 @@ export function sseDisconnected(source) { export const WIDGET_NEEDS_UPDATE = 'WIDGET_NEEDS_UPDATE'; -export const NEW_NOTIFICATION = 'NEW_NOTIFICATION'; export const MESSAGE_TYPES = [ "hubs:widget-updated", "hubs:user-updated", "hubs:hub-updated", - "hubs:new-notification", ]; export function sseEvent(type, data) { @@ -68,13 +66,6 @@ export function sseEvent(type, data) { break; case "hubs:hub-updated": return dispatch(fetchHub()); - case "hubs:new-notification": - // TODO: implement the reducers for this action - const username = data; - return dispatch({ - type: NEW_NOTIFICATION, - username, - }); default: return; }