Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉Source Facebook Marketing: use AdAccount('act_{id}') to find account instead of iterating #11751

Merged
merged 8 commits into from
Apr 15, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,7 @@ def account(self) -> AdAccount:
def _find_account(account_id: str) -> AdAccount:
"""Actual implementation of find account"""
try:
accounts = fb_user.User(fbid="me").get_ad_accounts()
for account in accounts:
if account["account_id"] == account_id:
return account
return AdAccount(f"act_{account_id}")
except FacebookRequestError as exc:
lazebnyi marked this conversation as resolved.
Show resolved Hide resolved
raise FacebookAPIException(f"Error: {exc.api_error_code()}, {exc.api_error_message()}") from exc

raise FacebookAPIException("Couldn't find account with id {}".format(account_id))