258 lines
9.4 KiB
YAML
258 lines
9.4 KiB
YAML
services:
|
|
# HTTP client for Telegram
|
|
app.http.telegram_client:
|
|
class: GuzzleHttp\Client
|
|
arguments: [{ timeout: 3.0 }]
|
|
tags:
|
|
- { name: csa_guzzle.client }
|
|
|
|
# HTTP client for Point API
|
|
app.http.point_client:
|
|
class: GuzzleHttp\Client
|
|
autowiring_types: GuzzleHttp\ClientInterface
|
|
arguments: [ { base_uri: '%point_base_url%', timeout: 5.0 } ]
|
|
tags:
|
|
- { name: csa_guzzle.client }
|
|
|
|
|
|
# Point API clients
|
|
# Abstract API client with common dependency
|
|
app.point.abstract_api:
|
|
abstract: true
|
|
autowire: true
|
|
# User
|
|
app.point.api_user:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Api\UserApi
|
|
parent: app.point.abstract_api
|
|
autowire: true
|
|
tags:
|
|
- { name: monolog.logger, channel: point_user_api }
|
|
# Post
|
|
app.point.api_post:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Api\PostApi
|
|
parent: app.point.abstract_api
|
|
autowire: true
|
|
tags:
|
|
- { name: monolog.logger, channel: point_post_api }
|
|
|
|
|
|
# Point subscription manager
|
|
app.point.subscriptions_manager:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\SubscriptionsManager
|
|
# TODO deal with autowire for EventDispatcherInterface
|
|
arguments:
|
|
- '@event_dispatcher'
|
|
- '@logger'
|
|
- '@app.point.subscription_repository'
|
|
- '@app.point.subscription_record_repository'
|
|
tags:
|
|
- { name: monolog.logger, channel: subscribers_update }
|
|
|
|
|
|
# Console commands
|
|
# Subsribers update
|
|
app.point.update_subscribers_command:
|
|
class: Skobkin\Bundle\PointToolsBundle\Command\UpdateSubscriptionsCommand
|
|
#autowire: []
|
|
calls:
|
|
- [setLogger, ['@logger']]
|
|
- [setEntityManager, ['@doctrine.orm.entity_manager']]
|
|
- [setUserRepository, ['@app.point.user_repository']]
|
|
- [setApiClient, ['@app.point.api_user']]
|
|
- [setApiDelay, ['%point_api_delay%']]
|
|
- [setSubscriptionManager, ['@app.point.subscriptions_manager']]
|
|
tags:
|
|
- { name: console.command }
|
|
- { name: monolog.logger, channel: subscribers_update }
|
|
# Restore users removed by error
|
|
app.point.restore_users:
|
|
class: Skobkin\Bundle\PointToolsBundle\Command\RestoreRemovedUsersCommand
|
|
calls:
|
|
- [setDependencies, ['@logger', '@doctrine.orm.entity_manager', '@app.point.user_repository', '@app.point.api_user', '%point_api_delay%']]
|
|
tags:
|
|
- { name: console.command }
|
|
# Webhook management
|
|
app.telegram.webhook_command:
|
|
class: Skobkin\Bundle\PointToolsBundle\Command\TelegramWebHookCommand
|
|
#autowire: []
|
|
calls:
|
|
- [setClient, ['@app.telegram.bot_client']]
|
|
- [setRouter, ['@router']]
|
|
- [setToken, ['%telegram_token%']]
|
|
tags: [{ name: console.command }]
|
|
# Send message
|
|
app.telegram.send_message:
|
|
class: Skobkin\Bundle\PointToolsBundle\Command\TelegramSendMessageCommand
|
|
#autowire: []
|
|
calls:
|
|
- [setMessenger, ['@app.telegram.message_sender']]
|
|
- [setLogChatId, ['%telegram_log_chat_id%']]
|
|
tags: [{ name: console.command }]
|
|
|
|
|
|
# Entity repositories as services
|
|
# User
|
|
app.point.user_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\UserRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\User']
|
|
# Subscription
|
|
app.point.subscription_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Subscription']
|
|
# Subscription record/event
|
|
app.point.subscription_record_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\SubscriptionEventRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\SubscriptionEvent']
|
|
# Post repository
|
|
app.point.post_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\Blogs\PostRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Post']
|
|
# Comment repository
|
|
app.point.comment_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\Blogs\CommentRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Comment']
|
|
# Tag repository
|
|
app.point.tag_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\Blogs\TagRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\Tag']
|
|
# File repository
|
|
app.point.file_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\Blogs\FileRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Blogs\File']
|
|
# Telegram Account repository
|
|
app.point.telegram_account_repository:
|
|
class: Skobkin\Bundle\PointToolsBundle\Repository\Telegram\AccountRepository
|
|
factory: 'doctrine:getRepository'
|
|
arguments: ['Skobkin\Bundle\PointToolsBundle\Entity\Telegram\Account']
|
|
|
|
|
|
# Factories
|
|
# Abstract factory
|
|
app.point.abstract_factory:
|
|
abstract: true
|
|
autowire: true
|
|
# User
|
|
app.point.user_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\UserFactory
|
|
parent: app.point.abstract_factory
|
|
autowire: true
|
|
# Comment
|
|
app.point.comment_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\CommentFactory
|
|
parent: app.point.abstract_factory
|
|
autowire: true
|
|
# Tag
|
|
app.point.tag_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\TagFactory
|
|
parent: app.point.abstract_factory
|
|
autowire: true
|
|
# File
|
|
app.point.file_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\FileFactory
|
|
parent: app.point.abstract_factory
|
|
autowire: true
|
|
# Post
|
|
app.point.post_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Blogs\PostFactory
|
|
parent: app.point.abstract_factory
|
|
autowire: true
|
|
# Telegram account
|
|
app.telegram.telegram_account_factory:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Factory\Telegram\AccountFactory
|
|
parent: app.point.abstract_factory
|
|
autowire: true
|
|
|
|
|
|
# Custom Markdown parser
|
|
app.point.markdown_parser:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Markdown\PointParser
|
|
arguments: [[], '@router']
|
|
tags:
|
|
- { name: markdown.parser }
|
|
|
|
|
|
# Event listeners
|
|
# User name changed in Doctrine
|
|
app.event_listener.users_updated:
|
|
class: Skobkin\Bundle\PointToolsBundle\EventListener\UsersUpdatedSubscriber
|
|
arguments: ['@event_dispatcher']
|
|
tags:
|
|
- { name: doctrine.event_subscriber, connection: default }
|
|
# User renaming
|
|
app.event_listener.users_renamed_notifier:
|
|
class: Skobkin\Bundle\PointToolsBundle\EventListener\UsersRenamedListener
|
|
autowire: true
|
|
tags:
|
|
- { name: kernel.event_listener, event: app.users.renamed }
|
|
# User subscribers updated
|
|
app.event_listener.user_subscribers_updated:
|
|
class: Skobkin\Bundle\PointToolsBundle\EventListener\UserSubscribersUpdatedListener
|
|
autowire: true
|
|
tags:
|
|
- { name: kernel.event_listener, event: app.user.subscribers_updated }
|
|
|
|
|
|
# Twig extensions
|
|
app.twig.point_users_extension:
|
|
class: Skobkin\Bundle\PointToolsBundle\Twig\PointUrlExtension
|
|
public: false
|
|
arguments:
|
|
- '%point_domain%'
|
|
- '%point_scheme%'
|
|
- '%point_base_url%'
|
|
tags:
|
|
- { name: twig.extension }
|
|
|
|
|
|
# Telegram services
|
|
# Bot API client
|
|
app.telegram.bot_client:
|
|
class: unreal4u\TelegramAPI\TgLog
|
|
autowiring_types: unreal4u\TelegramAPI\TgLog
|
|
arguments: ['%telegram_token%', '@logger', '@app.http.telegram_client']
|
|
# Logger API client
|
|
app.telegram.logger_client:
|
|
class: unreal4u\TelegramAPI\TgLog
|
|
arguments: ['%telegram_token%', null, '@app.http.telegram_client']
|
|
|
|
# Monolog handler
|
|
app.log.telegram_handler:
|
|
class: unreal4u\MonologHandler
|
|
arguments:
|
|
- '@app.telegram.logger_client'
|
|
- '%telegram_log_chat_id%'
|
|
- 'error'
|
|
|
|
# User notifier
|
|
app.telegram.notifier:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\Notifier
|
|
autowire: true
|
|
|
|
# Message sender
|
|
app.telegram.message_sender:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\MessageSender
|
|
autowire: true
|
|
# Common incoming message processor
|
|
app.telegram.update_dispatcher:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\IncomingUpdateDispatcher
|
|
autowire: true
|
|
# InlineQuery processor
|
|
app.telegram.inline_query_processor:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\InlineQueryProcessor
|
|
lazy: true
|
|
autowire: true
|
|
# Private message processor
|
|
app.telegram.private_message_processor:
|
|
class: Skobkin\Bundle\PointToolsBundle\Service\Telegram\PrivateMessageProcessor
|
|
lazy: true
|
|
autowire: true
|
|
calls:
|
|
- [setPointUserId, ['%point_id%']]
|