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.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
@ -141,7 +138,6 @@ class Api:
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
async with self as session: async with self as session:
@ -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", [])