main
py 21 lines 628 Bytes
Raw
1 from helpers.api import ApiHandler, Input, Output, Request, Response
2 from plugins._pin_to_top.helpers.pins import toggle_pin
3
4
5 class TogglePin(ApiHandler):
6 """Toggle one chat or task pin."""
7
8 async def process(self, input: Input, request: Request) -> Output:
9 try:
10 pinned, timestamp = toggle_pin(
11 str(input.get("kind", "")),
12 str(input.get("item_id", "")),
13 )
14 except ValueError as error:
15 return Response(str(error), 400)
16
17 return {
18 "ok": True,
19 "pinned": pinned,
20 "timestamp": timestamp,
21 }