Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added application service sample #18058

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/18058.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add application service sample configuration file.
11 changes: 11 additions & 0 deletions docs/sample_application_service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
id: <id>
url: null
as_token: <as_token>
hs_token: <hs_token>
sender_localpart: <sender_localpart>
namespaces:
users:
- exclusive: false
regex: ".*"
aliases: []
rooms: []
2 changes: 2 additions & 0 deletions synapse/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,138 +25,139 @@
# partial one for unit test mocking.


import abc
import functools
import logging
from typing import TYPE_CHECKING, Callable, Dict, List, Optional, Type, TypeVar, cast

from typing_extensions import TypeAlias

from twisted.internet.interfaces import IOpenSSLContextFactory
from twisted.internet.tcp import Port
from twisted.python.threadpool import ThreadPool
from twisted.web.iweb import IPolicyForHTTPS
from twisted.web.resource import Resource

from synapse.api.auth import Auth
from synapse.api.auth.internal import InternalAuth
from synapse.api.auth_blocking import AuthBlocking
from synapse.api.filtering import Filtering
from synapse.api.ratelimiting import Ratelimiter, RequestRatelimiter
from synapse.appservice.api import ApplicationServiceApi
from synapse.appservice.scheduler import ApplicationServiceScheduler
from synapse.config.homeserver import HomeServerConfig
from synapse.crypto import context_factory
from synapse.crypto.context_factory import RegularPolicyForHTTPS
from synapse.crypto.keyring import Keyring
from synapse.events.builder import EventBuilderFactory
from synapse.events.presence_router import PresenceRouter
from synapse.events.utils import EventClientSerializer
from synapse.federation.federation_client import FederationClient
from synapse.federation.federation_server import (
FederationHandlerRegistry,
FederationServer,
)
from synapse.federation.send_queue import FederationRemoteSendQueue
from synapse.federation.sender import AbstractFederationSender, FederationSender
from synapse.federation.transport.client import TransportLayerClient
from synapse.handlers.account import AccountHandler
from synapse.handlers.account_data import AccountDataHandler
from synapse.handlers.account_validity import AccountValidityHandler
from synapse.handlers.admin import AdminHandler
from synapse.handlers.appservice import ApplicationServicesHandler
from synapse.handlers.auth import AuthHandler, PasswordAuthProvider
from synapse.handlers.cas import CasHandler
from synapse.handlers.deactivate_account import DeactivateAccountHandler
from synapse.handlers.delayed_events import DelayedEventsHandler
from synapse.handlers.device import DeviceHandler, DeviceWorkerHandler
from synapse.handlers.devicemessage import DeviceMessageHandler
from synapse.handlers.directory import DirectoryHandler
from synapse.handlers.e2e_keys import E2eKeysHandler
from synapse.handlers.e2e_room_keys import E2eRoomKeysHandler
from synapse.handlers.event_auth import EventAuthHandler
from synapse.handlers.events import EventHandler, EventStreamHandler
from synapse.handlers.federation import FederationHandler
from synapse.handlers.federation_event import FederationEventHandler
from synapse.handlers.identity import IdentityHandler
from synapse.handlers.initial_sync import InitialSyncHandler
from synapse.handlers.message import EventCreationHandler, MessageHandler
from synapse.handlers.pagination import PaginationHandler
from synapse.handlers.password_policy import PasswordPolicyHandler
from synapse.handlers.presence import (
BasePresenceHandler,
PresenceHandler,
WorkerPresenceHandler,
)
from synapse.handlers.profile import ProfileHandler
from synapse.handlers.push_rules import PushRulesHandler
from synapse.handlers.read_marker import ReadMarkerHandler
from synapse.handlers.receipts import ReceiptsHandler
from synapse.handlers.register import RegistrationHandler
from synapse.handlers.relations import RelationsHandler
from synapse.handlers.room import (
RoomContextHandler,
RoomCreationHandler,
RoomShutdownHandler,
TimestampLookupHandler,
)
from synapse.handlers.room_list import RoomListHandler
from synapse.handlers.room_member import (
RoomForgetterHandler,
RoomMemberHandler,
RoomMemberMasterHandler,
)
from synapse.handlers.room_member_worker import RoomMemberWorkerHandler
from synapse.handlers.room_summary import RoomSummaryHandler
from synapse.handlers.search import SearchHandler
from synapse.handlers.send_email import SendEmailHandler
from synapse.handlers.set_password import SetPasswordHandler
from synapse.handlers.sliding_sync import SlidingSyncHandler
from synapse.handlers.sso import SsoHandler
from synapse.handlers.stats import StatsHandler
from synapse.handlers.sync import SyncHandler
from synapse.handlers.typing import FollowerTypingHandler, TypingWriterHandler
from synapse.handlers.user_directory import UserDirectoryHandler
from synapse.handlers.worker_lock import WorkerLocksHandler
from synapse.http.client import (
InsecureInterceptableContextFactory,
ReplicationClient,
SimpleHttpClient,
)
from synapse.http.matrixfederationclient import MatrixFederationHttpClient
from synapse.media.media_repository import MediaRepository
from synapse.metrics import register_threadpool
from synapse.metrics.common_usage_metrics import CommonUsageMetricsManager
from synapse.module_api import ModuleApi
from synapse.module_api.callbacks import ModuleApiCallbacks
from synapse.notifier import Notifier, ReplicationNotifier
from synapse.push.bulk_push_rule_evaluator import BulkPushRuleEvaluator
from synapse.push.pusherpool import PusherPool
from synapse.replication.tcp.client import ReplicationDataHandler
from synapse.replication.tcp.external_cache import ExternalCache
from synapse.replication.tcp.handler import ReplicationCommandHandler
from synapse.replication.tcp.resource import ReplicationStreamer
from synapse.replication.tcp.streams import STREAMS_MAP, Stream
from synapse.rest.media.media_repository_resource import MediaRepositoryResource
from synapse.server_notices.server_notices_manager import ServerNoticesManager
from synapse.server_notices.server_notices_sender import ServerNoticesSender
from synapse.server_notices.worker_server_notices_sender import (
WorkerServerNoticesSender,
)
from synapse.state import StateHandler, StateResolutionHandler
from synapse.storage import Databases
from synapse.storage.controllers import StorageControllers
from synapse.streams.events import EventSources
from synapse.synapse_rust.rendezvous import RendezvousHandler
from synapse.types import DomainSpecificString, ISynapseReactor
from synapse.util import Clock
from synapse.util.distributor import Distributor
from synapse.util.macaroons import MacaroonGenerator
from synapse.util.ratelimitutils import FederationRateLimiter
from synapse.util.stringutils import random_string
from synapse.util.task_scheduler import TaskScheduler
from synapse.util.synapse_ascii import get_logo

logger = logging.getLogger(__name__)

Check failure on line 160 in synapse/server.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (I001)

synapse/server.py:28:1: I001 Import block is un-sorted or un-formatted

if TYPE_CHECKING:
from txredisapi import ConnectionHandler
Expand Down Expand Up @@ -355,6 +356,7 @@

def setup(self) -> None:
logger.info("Setting up.")
logger.info(get_logo(self.version_string))
self.start_time = int(self.get_clock().time())
self.datastores = Databases(self.DATASTORE_CLASS, self)
logger.info("Finished setting up.")
Expand Down
12 changes: 12 additions & 0 deletions synapse/util/synapse_ascii.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SYNAPSE_LOGO = '''

Check failure on line 1 in synapse/util/synapse_ascii.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W291)

synapse/util/synapse_ascii.py:1:19: W291 Trailing whitespace
____

Check failure on line 2 in synapse/util/synapse_ascii.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W291)

synapse/util/synapse_ascii.py:2:7: W291 Trailing whitespace
/ ___| _ _ _ __ __ _ _ __ ___ ___

Check failure on line 3 in synapse/util/synapse_ascii.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W291)

synapse/util/synapse_ascii.py:3:41: W291 Trailing whitespace
\___ \| | | | '_ \ / _` | '_ \/ __|/ _ \\

Check failure on line 4 in synapse/util/synapse_ascii.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W605)

synapse/util/synapse_ascii.py:4:2: W605 Invalid escape sequence: `\_`

Check failure on line 4 in synapse/util/synapse_ascii.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W605)

synapse/util/synapse_ascii.py:4:7: W605 Invalid escape sequence: `\|`

Check failure on line 4 in synapse/util/synapse_ascii.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W605)

synapse/util/synapse_ascii.py:4:19: W605 Invalid escape sequence: `\ `

Check failure on line 4 in synapse/util/synapse_ascii.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W605)

synapse/util/synapse_ascii.py:4:31: W605 Invalid escape sequence: `\/`
___) | |_| | | | | (_| | |_) \__ \ __/

Check failure on line 5 in synapse/util/synapse_ascii.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W605)

synapse/util/synapse_ascii.py:5:32: W605 Invalid escape sequence: `\_`

Check failure on line 5 in synapse/util/synapse_ascii.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (W605)

synapse/util/synapse_ascii.py:5:36: W605 Invalid escape sequence: `\ `
|____/ \__, |_| |_|\__,_| .__/|___/\___|
|___/ |_|
'''

def get_logo(version: str) -> str:
"""Returns the Synapse ASCII art logo."""
return SYNAPSE_LOGO + "\t\t\t\t\t\t" + version + "\n"
Loading