Skip to content
Merged
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
8 changes: 8 additions & 0 deletions backend/utils/social.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ async def upsert_persona_from_twitter_profile(username: str, handle: str, uid: s
profile = await get_twitter_profile(handle)
profile['avatar'] = profile['avatar'].replace('_normal', '')
persona = get_persona_by_username_twitter_handle_db(username, handle)

if not persona:
persona = {
"name": profile["name"],
Expand All @@ -88,12 +89,19 @@ async def upsert_persona_from_twitter_profile(username: str, handle: str, uid: s
"private": False,
"created_at": datetime.now(timezone.utc),
}

# update profle
persona["twitter"] = {
"username": handle,
"avatar": profile["avatar"],
"connected_at": datetime.now(timezone.utc)
}

# publish automatically
persona["status"] = "approved"
persona["approved"] = True
persona["private"] = False

tweets = await get_twitter_timeline(handle)
tweets = [{'tweet': tweet['text'], 'posted_at': tweet['created_at']} for tweet in tweets['timeline']]
condensed_tweets = condense_tweets(tweets, persona["name"])
Expand Down