2022-05-17 23:14:52 +02:00
|
|
|
import logging
|
2023-07-16 15:09:08 +02:00
|
|
|
import click
|
2022-05-17 23:14:52 +02:00
|
|
|
|
2023-07-16 15:09:08 +02:00
|
|
|
from mobilizon_reshare.config.command import CommandConfig
|
|
|
|
from mobilizon_reshare.main.publish import select_and_publish, publish_by_mobilizon_id
|
2022-05-17 23:14:52 +02:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
2022-03-22 21:16:34 +01:00
|
|
|
|
|
|
|
|
2023-07-16 15:09:08 +02:00
|
|
|
async def publish_command(event_mobilizon_id: click.UUID, platform: str, command_config: CommandConfig):
|
2022-03-22 21:16:34 +01:00
|
|
|
"""
|
2022-05-17 23:14:52 +02:00
|
|
|
Select an event with the current configured strategy
|
|
|
|
and publish it to all active platforms.
|
2022-03-22 21:16:34 +01:00
|
|
|
"""
|
2023-07-16 15:09:08 +02:00
|
|
|
if event_mobilizon_id is not None:
|
|
|
|
report = await publish_by_mobilizon_id(
|
|
|
|
event_mobilizon_id,
|
|
|
|
command_config,
|
|
|
|
[platform] if platform is not None else None,
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
report = await select_and_publish(command_config)
|
2022-05-17 23:14:52 +02:00
|
|
|
return 0 if report and report.successful else 1
|