File size: 677 Bytes
345855e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# publisher/account_manager.py

from publisher.oauth.storage import load_tokens

SUPPORTED = [
    "youtube",
    "tiktok",
    "meta"
]


def connected_accounts(user_id):

    accounts = []

    for p in SUPPORTED:
        token = load_tokens(user_id, p)
        if token:
            accounts.append({
                "platform": p,
                "token": token
            })

    return accounts


def choose_platforms(strategy, accounts):

    if strategy == "all":
        return accounts

    if strategy == "short_video":
        return [
            a for a in accounts
            if a["platform"] in ["youtube", "tiktok", "meta"]
        ]

    return accounts[:1]