mirror of https://gitlab.com/litecord/litecord.git
add route to fetch notes from singular users
This commit is contained in:
parent
de357dd524
commit
ad6643421d
|
|
@ -23,6 +23,7 @@ from litecord.auth import token_check
|
|||
from litecord.schemas import validate, USER_SETTINGS, GUILD_SETTINGS
|
||||
from litecord.blueprints.checks import guild_check
|
||||
from litecord.pubsub.user import dispatch_user
|
||||
from litecord.errors import UserNotFound
|
||||
|
||||
bp = Blueprint("users_settings", __name__)
|
||||
|
||||
|
|
@ -129,6 +130,26 @@ async def patch_guild_settings(guild_id: int):
|
|||
return jsonify(settings)
|
||||
|
||||
|
||||
@bp.route("/@me/notes/<int:target_id>", methods=["GET"])
|
||||
async def get_note(target_id: int):
|
||||
"""Get a single note from a user."""
|
||||
user_id = await token_check()
|
||||
note = await app.db.fetchval(
|
||||
"""
|
||||
SELECT note
|
||||
FROM notes
|
||||
WHERE user_id = $1 AND target_id = $2
|
||||
""",
|
||||
user_id,
|
||||
target_id,
|
||||
)
|
||||
|
||||
if note is None:
|
||||
raise UserNotFound()
|
||||
|
||||
return jsonify({"user_id": user_id, "note_user_id": target_id, "note": note})
|
||||
|
||||
|
||||
@bp.route("/@me/notes/<int:target_id>", methods=["PUT"])
|
||||
async def put_note(target_id: int):
|
||||
"""Put a note to a user.
|
||||
|
|
|
|||
|
|
@ -142,6 +142,10 @@ class WebhookNotFound(NotFound):
|
|||
error_code = 10015
|
||||
|
||||
|
||||
class UserNotFound(NotFound):
|
||||
error_code = 10013
|
||||
|
||||
|
||||
class Ratelimited(LitecordError):
|
||||
status_code = 429
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue