Add a type hints for service notices to the HomeServer object. (#9675)

This commit is contained in:
Patrick Cloke 2021-03-24 06:48:46 -04:00 committed by GitHub
parent e550ab17ad
commit 7e8dc9934e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 52 additions and 40 deletions

View file

@ -13,13 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from typing import Any
from typing import TYPE_CHECKING, Any, Set
from synapse.api.errors import SynapseError
from synapse.api.urls import ConsentURIBuilder
from synapse.config import ConfigError
from synapse.types import get_localpart_from_id
if TYPE_CHECKING:
from synapse.server import HomeServer
logger = logging.getLogger(__name__)
@ -28,16 +31,11 @@ class ConsentServerNotices:
privacy policy consent, and sends one if we do.
"""
def __init__(self, hs):
"""
Args:
hs (synapse.server.HomeServer):
"""
def __init__(self, hs: "HomeServer"):
self._server_notices_manager = hs.get_server_notices_manager()
self._store = hs.get_datastore()
self._users_in_progress = set()
self._users_in_progress = set() # type: Set[str]
self._current_consent_version = hs.config.user_consent_version
self._server_notice_content = hs.config.user_consent_server_notice_content
@ -73,6 +71,10 @@ class ConsentServerNotices:
try:
u = await self._store.get_user_by_id(user_id)
# The user doesn't exist.
if u is None:
return
if u["is_guest"] and not self._send_to_guests:
# don't send to guests
return