Update comment.
This commit is contained in:
parent
1439139c19
commit
c3bcbc2681
BIN
dist/devranta-1.0.0-py3-none-any.whl
vendored
BIN
dist/devranta-1.0.0-py3-none-any.whl
vendored
Binary file not shown.
BIN
dist/devranta-1.0.0.tar.gz
vendored
BIN
dist/devranta-1.0.0.tar.gz
vendored
Binary file not shown.
@ -15,8 +15,6 @@ class Api:
|
|||||||
self.token_Key = None
|
self.token_Key = None
|
||||||
self.session = None
|
self.session = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def patch_auth(self, request_dict=None):
|
def patch_auth(self, request_dict=None):
|
||||||
auth_dict = {"app": self.app_id}
|
auth_dict = {"app": self.app_id}
|
||||||
if self.auth:
|
if self.auth:
|
||||||
@ -70,7 +68,7 @@ class Api:
|
|||||||
async def get_comments_from_user(self, username):
|
async def get_comments_from_user(self, username):
|
||||||
user_id = await self.get_user_id(username)
|
user_id = await self.get_user_id(username)
|
||||||
profile = await self.get_profile(user_id)
|
profile = await self.get_profile(user_id)
|
||||||
return profile.get('content',{}).get('content',{}).get('comments',[])
|
return profile.get("content", {}).get("content", {}).get("comments", [])
|
||||||
|
|
||||||
async def post_comment(self, rant_id, comment):
|
async def post_comment(self, rant_id, comment):
|
||||||
response = None
|
response = None
|
||||||
@ -92,7 +90,6 @@ class Api:
|
|||||||
)
|
)
|
||||||
obj = await response.json()
|
obj = await response.json()
|
||||||
|
|
||||||
print(obj)
|
|
||||||
if not obj.get("success"):
|
if not obj.get("success"):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -140,7 +137,6 @@ class Api:
|
|||||||
if not obj.get("success"):
|
if not obj.get("success"):
|
||||||
return
|
return
|
||||||
return obj.get("rants", [])
|
return obj.get("rants", [])
|
||||||
|
|
||||||
|
|
||||||
async def get_user_id(self, username):
|
async def get_user_id(self, username):
|
||||||
response = None
|
response = None
|
||||||
@ -156,7 +152,20 @@ class Api:
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
async def mentions(self):
|
async def mentions(self):
|
||||||
return [notif for notif in (await self.notifs) if notif['type'] == "comment_mention"]
|
return [
|
||||||
|
notif for notif in (await self.notifs) if notif["type"] == "comment_mention"
|
||||||
|
]
|
||||||
|
|
||||||
|
async def update_comment(self, comment_id, comment):
|
||||||
|
response = None
|
||||||
|
if not await self.ensure_login():
|
||||||
|
return None
|
||||||
|
async with self as session:
|
||||||
|
response = await session.get(
|
||||||
|
url=self.patch_url(f"comments/{comment_id}"),
|
||||||
|
data=self.patch_auth({"comment": comment}),
|
||||||
|
)
|
||||||
|
return await response.get("success", False)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
async def notifs(self):
|
async def notifs(self):
|
||||||
@ -168,4 +177,3 @@ class Api:
|
|||||||
url=self.patch_url("users/me/notif-feed"), params=self.patch_auth()
|
url=self.patch_url("users/me/notif-feed"), params=self.patch_auth()
|
||||||
)
|
)
|
||||||
return (await response.json()).get("data", {}).get("items", [])
|
return (await response.json()).get("data", {}).get("items", [])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user