Beispiel #1
0
 def consume(self, event: Mapping[str, Any]) -> None:
     logging.debug("Received presence event: %s" % (event), )
     user_profile = get_user_profile_by_id(event["user_profile_id"])
     client = get_client(event["client"])
     log_time = timestamp_to_datetime(event["time"])
     status = event["status"]
     do_update_user_presence(user_profile, client, log_time, status)
Beispiel #2
0
 def consume(self, event):
     logging.info("Received event: %s" % (event),)
     user_profile = get_user_profile_by_id(event["user_profile_id"])
     client = get_client(event["client"])
     log_time = timestamp_to_datetime(event["time"])
     status = event["status"]
     do_update_user_presence(user_profile, client, log_time, status)
Beispiel #3
0
 def consume(self, event):
     logging.info("Received event: %s" % (event), )
     user_profile = get_user_profile_by_id(event["user_profile_id"])
     client = get_client(event["client"])
     log_time = timestamp_to_datetime(event["time"])
     status = event["status"]
     do_update_user_presence(user_profile, client, log_time, status)
Beispiel #4
0
 def consume(self, event: Mapping[str, Any]) -> None:
     logging.debug("Received presence event: %s" % (event),)
     user_profile = get_user_profile_by_id(event["user_profile_id"])
     client = get_client(event["client"])
     log_time = timestamp_to_datetime(event["time"])
     status = event["status"]
     do_update_user_presence(user_profile, client, log_time, status)
Beispiel #5
0
    def test_presence_events_diabled_on_larger_realm(self) -> None:
        # First check that normally the mocked function gets called.
        events: List[Mapping[str, Any]] = []
        with self.tornado_redirected_to_list(events, expected_num_events=1):
            do_update_user_presence(
                self.example_user("cordelia"),
                get_client("website"),
                timezone_now(),
                UserPresence.ACTIVE,
            )

        # Now check that if the realm has more than the USER_LIMIT_FOR_SENDING_PRESENCE_UPDATE_EVENTS
        # amount of active users, send_event doesn't get called.
        with self.tornado_redirected_to_list(events, expected_num_events=0):
            with self.settings(
                    USER_LIMIT_FOR_SENDING_PRESENCE_UPDATE_EVENTS=1):
                do_update_user_presence(
                    self.example_user("hamlet"),
                    get_client("website"),
                    timezone_now(),
                    UserPresence.ACTIVE,
                )
Beispiel #6
0
    def test_presence_events_diabled_on_larger_realm(self) -> None:
        # First check that normally the mocked function gets called.
        with mock.patch("zerver.lib.actions.send_event") as mock_send_event:
            do_update_user_presence(
                self.example_user("cordelia"),
                get_client("website"),
                timezone_now(),
                UserPresence.ACTIVE,
            )
        mock_send_event.assert_called_once()

        # Now check that if the realm has more than the USER_LIMIT_FOR_SENDING_PRESENCE_UPDATE_EVENTS
        # amount of active users, send_event doesn't get called.
        with mock.patch("zerver.lib.actions.send_event") as mock_send_event:
            with self.settings(
                    USER_LIMIT_FOR_SENDING_PRESENCE_UPDATE_EVENTS=1):
                do_update_user_presence(
                    self.example_user("hamlet"),
                    get_client("website"),
                    timezone_now(),
                    UserPresence.ACTIVE,
                )
        mock_send_event.assert_not_called()