Update comment.

This commit is contained in:
retoor 2024-12-03 18:49:12 +01:00
parent 1439139c19
commit c3bcbc2681
3 changed files with 15 additions and 7 deletions

Binary file not shown.

Binary file not shown.

View File

@ -15,8 +15,6 @@ class Api:
self.token_Key = None
self.session = None
def patch_auth(self, request_dict=None):
auth_dict = {"app": self.app_id}
if self.auth:
@ -70,7 +68,7 @@ class Api:
async def get_comments_from_user(self, username):
user_id = await self.get_user_id(username)
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):
response = None
@ -92,7 +90,6 @@ class Api:
)
obj = await response.json()
print(obj)
if not obj.get("success"):
return None
@ -140,7 +137,6 @@ class Api:
if not obj.get("success"):
return
return obj.get("rants", [])
async def get_user_id(self, username):
response = None
@ -156,7 +152,20 @@ class Api:
@property
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
async def notifs(self):
@ -168,4 +177,3 @@ class Api:
url=self.patch_url("users/me/notif-feed"), params=self.patch_auth()
)
return (await response.json()).get("data", {}).get("items", [])