Skip to content

Commit

Permalink
add private field to paste edits
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmTomahawkx committed Oct 4, 2023
1 parent a1cd2e8 commit 74eb3fe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions mystbin/backend/models/payloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class PastePatch(Struct):
new_files: list[PasteFile]
new_expires: datetime.datetime | None = None
new_password: str | None = None
private: bool | None = None


class PasteDelete(Struct):
Expand Down
1 change: 1 addition & 0 deletions mystbin/backend/routers/pastes.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ async def edit_paste(request: MystbinRequest) -> VariableResponse | Response:
new_expires=payload.new_expires,
new_password=payload.new_password,
files=payload.new_files,
private=payload.private
)
if paste == 404:
return VariableResponse(
Expand Down
6 changes: 4 additions & 2 deletions mystbin/backend/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ async def edit_paste(
new_expires: datetime.datetime | None = None,
new_password: str | None = None,
files: list[payloads.PasteFile] | None = None,
private: bool | None = None
) -> Literal[404] | None:
"""Puts the specified paste.
Parameters
Expand Down Expand Up @@ -436,12 +437,13 @@ async def edit_paste(
UPDATE pastes
SET last_edited = NOW() AT TIME ZONE 'UTC',
password = (SELECT crypt($3, gen_salt('bf')) WHERE $3 is not null),
expires = $4
expires = $4,
private = COALESCE($5, private)
WHERE id = $1 AND author_id = $2
RETURNING *
"""

resp = await self._do_query(query, paste_id, author, new_password, new_expires, conn=conn)
resp = await self._do_query(query, paste_id, author, new_password, new_expires, private, conn=conn)
if not resp:
return 404

Expand Down

0 comments on commit 74eb3fe

Please sign in to comment.