Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Stiveknx authored Mar 16, 2022
2 parents 7d191de + 2052d9e commit 6074e0c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Open in browser [http://localhost:8000/docs](http://localhost:8000/docs) and fol
Get sessionid:

```
curl -X 'GET' \
curl -X 'POST' \
'http://localhost:8000/auth/login' \
-H 'accept: application/json' \
-H 'Content-Type: application/x-www-form-urlencoded' \
Expand Down
2 changes: 1 addition & 1 deletion routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ async def timeline_feed(sessionid: str,
"""Get your timeline feed
"""
cl = clients.get(sessionid)
return cl.get_timeline_feed()
return cl.get_timeline_feed()
11 changes: 10 additions & 1 deletion storages.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from urllib import parse
from instagrapi import Client
from tinydb import TinyDB, Query
from tinydb.table import Document
import json

class ClientStorage:
Expand Down Expand Up @@ -30,7 +31,15 @@ def set(self, cl: Client) -> bool:
"""Set client settings
"""
key = parse.unquote(cl.sessionid.strip(" \""))
self.db.insert({'sessionid': key, 'settings': json.dumps(cl.get_settings())})
user_pkid = key.split(":")[0]

self.db.insert(Document({'sessionid': key, 'settings': json.dumps(cl.get_settings())}, doc_id=user_pkid))
return True

def set_custom(self, user_pkid, settings) -> bool:
"""Set client settings
"""
self.db.insert(Document({'sessionid': key, 'settings': settings}, doc_id=user_pkid))
return True

def close(self):
Expand Down

0 comments on commit 6074e0c

Please sign in to comment.