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
2 changes: 2 additions & 0 deletions apps/publisher/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions apps/publisher/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/providers/test_instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading