Post update

This commit is contained in:
simonwt 2026-04-07 23:37:55 +01:00
parent 1995e0479f
commit a42a3b65d9
9 changed files with 116 additions and 17 deletions

View file

@ -1,7 +1,8 @@
from .update import update
from .create import create
from .get import get
from .listbybranch import listbybranch
from .listbyuserprofile import listbyuserprofile
from .create import create
from .listall import listall
from .listpublic import listpublic
from .listremoved import listremoved

View file

@ -0,0 +1,12 @@
def update(API, payload: dict) -> dict:
"""
Updates an existing post in the API.
Args:
payload (dict): The data for the post update.
Returns:
dict: The post data.
"""
post_data = API.make_request("PUT", "content", "post/update", data=payload, authenticate=True)
return post_data

View file

@ -1 +1,2 @@
from .create_post import create_post
from .create_post import create_post
from .update_post import update_post

View file

@ -0,0 +1,37 @@
from trustcafeapiwrapper.utils import get_post_pksk, get_parent_pksk_from_path
def update_post(parent_path, post_path, post_text, blur_label=None, card_url=None, collaborative=False):
"""
Updates an existing post.
Args:
post_slug (str): The slug of the post to update.
post_text (str): The new text for the post.
parent_path (str, optional): The parent path for the post. Defaults to '/'.
blur_label (str, optional): The blur label for the post. Defaults to None.
card_url (str, optional): The card URL for the post. Defaults to None.
collaborative (bool, optional): Whether the post is collaborative. Defaults to False.
Returns:
dict: The updated post data.
"""
parent_pksk = get_parent_pksk_from_path(parent_path)
post_pksk = get_post_pksk(parent_pksk, post_path)
payload = {
"key": {
"pk": post_pksk.get('pk', None),
"sk": post_pksk.get('sk', None)
},
"postSlug": post_path.strip('/post/'),
"blurLabel": blur_label,
"cardUrl": card_url,
"postText": post_text,
"collaborative": collaborative,
}
return {
"job_function": "post.update",
"payload": payload
}