Skip to content

Commit

Permalink
Système de post automatique sur Bluesky
Browse files Browse the repository at this point in the history
  • Loading branch information
Mopolo committed Mar 1, 2025
1 parent a9a29ae commit dd11edf
Show file tree
Hide file tree
Showing 21 changed files with 1,076 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ TWITTER_OAUTH_ACCESS_TOKEN_SECRET=
TWITTER_CONSUMER_KEY=
TWITTER_CONSUMER_SECRET=

BLUESKY_API_IDENTIFIER=
BLUESKY_API_APP_PASSWORD=

MAILCHIMP_API_KEY=xxx-yyyy
MAILCHIMP_MEMBERS_LIST=
MAILCHIMP_SUBSCRIBERS_LIST=
Expand Down
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
__DIR__ . '/sources',
__DIR__ . '/tests',
])
->exclude('cache/templates')
;

return (new PhpCsFixer\Config())
Expand Down
36 changes: 36 additions & 0 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ parameters:
app.badge_dir: "%kernel.project_dir%/htdocs/uploads/badges"
app.members_logo_dir: "%kernel.project_dir%/htdocs/uploads/members_logo"
app.general_meetings_dir: "%kernel.project_dir%/htdocs/uploads/general_meetings_reports"
bluesky.api.identifier: "%bluesky_api_identifier%"
bluesky.api.app_password: "%bluesky_api_app_password%"

services:
# service_name:
Expand All @@ -17,6 +19,10 @@ services:
_defaults:
public: true

_instanceof:
AppBundle\SocialNetwork\Transport:
tags: [ 'app.social_network.transport' ]

Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
public: false
arguments:
Expand Down Expand Up @@ -282,6 +288,11 @@ services:
factory: ["@ting", get]
arguments: [AppBundle\Association\Model\Repository\CompanyMemberRepository]

AppBundle\Event\Model\Repository\PlanningRepository:
class: AppBundle\Event\Model\Repository\PlanningRepository
factory: [ "@ting", get ]
arguments: [ AppBundle\Event\Model\Repository\PlanningRepository ]

AppBundle\Security\LegacyAuthenticator:
autowire: true

Expand Down Expand Up @@ -740,3 +751,28 @@ services:
arguments:
$httpClient: '@app.meetup.http_client'
$antennesCollection: '@AppBundle\Antennes\AntennesCollection'

app.bluesky.http_client:
class: GuzzleHttp\Client
arguments:
$config:
base_uri: https://bsky.social/

AppBundle\SocialNetwork\Bluesky\BlueskyTransport:
arguments:
$client: '@app.bluesky.http_client'
$apiIdentifier: '%bluesky.api.identifier%'
$apiAppPassword: '%bluesky.api.app_password%'

AppBundle\VideoNotifier\HistoryRepository:
arguments:
$connection: '@Doctrine\DBAL\Connection'

AppBundle\VideoNotifier\Engine:
arguments:
$transports: !tagged_iterator app.social_network.transport
$planningRepository: '@AppBundle\Event\Model\Repository\PlanningRepository'
$talkRepository: '@AppBundle\Event\Model\Repository\TalkRepository'
$eventRepository: '@AppBundle\Event\Model\Repository\EventRepository'
$speakerRepository: '@AppBundle\Event\Model\Repository\SpeakerRepository'
$historyRepository: '@AppBundle\VideoNotifier\HistoryRepository'
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"knpuniversity/oauth2-client-bundle": "^1.4",
"league/iso3166": "^4.0",
"league/oauth2-github": "^0.2.1",
"myclabs/php-enum": "^1.8",
"nojimage/twitter-text-php": "1.1.*",
"pacely/mailchimp-apiv3": "^1.0",
"pear/pear": "^1.10",
Expand All @@ -40,6 +41,8 @@
"setasign/fpdf": "^1.8",
"smarty/smarty": "^5.4",
"symfony/monolog-bundle": "*",
"symfony/polyfill-php80": "^1.31",
"symfony/string": "^5.4",
"symfony/symfony": "^4.4",
"twig/extensions": "^1.4",
"willdurand/geocoder": "^3.3",
Expand Down
166 changes: 165 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);


use Phinx\Migration\AbstractMigration;

class CreateVideoNotifierHistoryTable extends AbstractMigration
{
public function change(): void
{
$this->table('video_notifier_history')
->addColumn('talk_id', 'integer')
->addColumn('status_id_bluesky', 'string', [
'limit' => 30,
'null' => true,
])
->addColumn('status_id_mastodon', 'string', [
'limit' => 30,
'null' => true,
])
->addColumn('created_at', 'timestamp', [
'default' => 'CURRENT_TIMESTAMP',
'update' => ''
])
->create();
}
}
36 changes: 36 additions & 0 deletions sources/AppBundle/Command/VideoNotifierCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace AppBundle\Command;

use AppBundle\VideoNotifier\Engine;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

final class VideoNotifierCommand extends Command
{
private Engine $engine;

public function __construct(Engine $engine)
{
parent::__construct();

$this->engine = $engine;
}

protected function configure(): void
{
$this
->setName('plop')
;
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->engine->run();

return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
use CCMBenchmark\Ting\Repository\Repository;
use CCMBenchmark\Ting\Serializer\SerializerFactoryInterface;

/**
* @extends Repository<Planning>
*/
class PlanningRepository extends Repository implements MetadataInitializer
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SpeakerRepository extends Repository implements MetadataInitializer
public function getSpeakersByTalk(Talk $talk)
{
$query = $this->getPreparedQuery('SELECT c.conferencier_id, c.id_forum, c.civilite, c.nom, c.prenom, c.email,c.societe,
c.biographie, c.twitter, c.user_github, c.photo
c.biographie, c.twitter, c.user_github, c.photo, c.bluesky, c.mastodon
FROM afup_conferenciers c
LEFT JOIN afup_conferenciers_sessions cs ON cs.conferencier_id = c.conferencier_id
WHERE cs.session_id = :talkId
Expand Down
Loading

0 comments on commit dd11edf

Please sign in to comment.