diff --git a/apps/publisher/engine.py b/apps/publisher/engine.py index f3924b33..9389e3ae 100644 --- a/apps/publisher/engine.py +++ b/apps/publisher/engine.py @@ -82,6 +82,8 @@ def _resolve_publish_credentials(account): "Bluesky PDS URL failed SSRF check for account %s", account.id, ) + elif platform == "facebook": + credentials["page_id"] = account.account_platform_id elif platform == "instagram": credentials["ig_user_id"] = account.account_platform_id diff --git a/apps/publisher/tests.py b/apps/publisher/tests.py index 8abfdc18..5eb7a818 100644 --- a/apps/publisher/tests.py +++ b/apps/publisher/tests.py @@ -197,6 +197,17 @@ def test_does_not_inject_author_for_other_platforms(self, _mock_creds, mock_get_ class ResolvePublishCredentialsTest(SimpleTestCase): + @patch("apps.publisher.engine.resolve_platform_credentials", return_value={"client_id": "id"}) + def test_facebook_credentials_include_selected_page_id(self, _mock_resolve): + account = MagicMock() + account.platform = "facebook" + account.account_platform_id = "page-1" + account.workspace.organization_id = "org-1" + + credentials = _resolve_publish_credentials(account) + + self.assertEqual(credentials["page_id"], "page-1") + @patch("apps.publisher.engine.resolve_platform_credentials", return_value={"client_id": "id"}) def test_instagram_credentials_include_selected_ig_user_id(self, _mock_resolve): account = MagicMock() diff --git a/tests/providers/test_instagram.py b/tests/providers/test_instagram.py index 3d66d182..1bf0393c 100644 --- a/tests/providers/test_instagram.py +++ b/tests/providers/test_instagram.py @@ -200,8 +200,8 @@ def test_instagram_media_metrics_use_current_metrics_and_field_fallbacks(): metrics = provider.get_post_metrics("page-token", "ig-media-1") - assert metrics.video_views == 250 - assert metrics.reach == 400 + assert metrics.video_views == 400 + assert metrics.reach == 250 assert metrics.likes == 12 assert metrics.comments == 3 assert metrics.saves == 5