Skip to content
Merged
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
20 changes: 15 additions & 5 deletions event/main_listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static function getSubscribedEvents()
* Constructor
*
* @param auth $auth
* @param config $config
* @param config $config
* @param db_text $config_text
* @param language $language
* @param template $template
Expand All @@ -104,12 +104,22 @@ public function __construct(auth $auth, config $config, db_text $config_text, la
*/
public function add_custom_sites($event)
{
$is_phpbb4 = phpbb_version_compare($this->config['version'], '4.0.0-a1', '>=');
$phpbb4_builtins = array_flip([
'applepodcasts', 'bluesky', 'bunny', 'mastodon', 'pastebin', 'threads', 'twitter',
]);

foreach ($this->custom_sites->get_collection() as $site)
{
$event['configurator']->MediaEmbed->defaultSites->add(
basename($site, ext::YML),
Yaml::parse(file_get_contents($site))
);
$name = basename($site, ext::YML);

// Skip built-in sites when running phpBB 4
if ($is_phpbb4 && isset($phpbb4_builtins[$name]))
{
continue;
}

$event['configurator']->MediaEmbed->defaultSites->add($name, Yaml::parseFile($site));
}
}

Expand Down
6 changes: 5 additions & 1 deletion tests/event/listener_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,14 @@ public function test_configure_media_embed($tag, $code, $id, $exists, $parse_url
{
$this->custom_sites->expects(self::once())
->method('get_collection')
->willReturn([__DIR__ . '/../fixtures/sites/ok.yml']);
->willReturn([
__DIR__ . '/../fixtures/sites/ok.yml',
__DIR__ . '/../fixtures/sites/bluesky.yml', // this is to test that phpbb4 filtering works
]);

// Update configs with test values
$this->config['media_embed_parse_urls'] = $parse_urls;
$this->config['version'] = '4.0.0'; // this is to test that phpbb4 filtering works

// Get the s9e configurator
$configurator = $this->container
Expand Down