diff --git a/litecord/blueprints/read_states.py b/litecord/blueprints/read_states.py
index 5df255a..5c216e7 100644
--- a/litecord/blueprints/read_states.py
+++ b/litecord/blueprints/read_states.py
@@ -18,12 +18,13 @@ along with this program. If not, see .
"""
-from quart import Blueprint, current_app as app, jsonify
-from ..auth import token_check
-from ..enums import ChannelType
-from ..common.channels import channel_ack
+from quart import Blueprint, current_app as app, jsonify, request
+from litecord.auth import token_check
+from litecord.common.channels import channel_ack
from litecord.errors import GuildNotFound
from litecord.blueprints.checks import channel_check, guild_check
+from litecord.schemas import validate, BULK_ACK
+from litecord.enums import ChannelType, GUILD_CHANS
bp = Blueprint("read_states", __name__)
@@ -50,6 +51,23 @@ async def ack_channel(channel_id, message_id):
)
+@bp.route("/read-states/ack-bulk", methods=["POST"])
+async def bulk_ack():
+ """Acknowledge multiple channels in a row"""
+ user_id = await token_check()
+ j = validate(await request.get_json(), BULK_ACK)
+ for ack_request in j:
+ channel_id, message_id = ack_request["channel_id"], ack_request["message_id"]
+ ctype, guild_id = await channel_check(user_id, channel_id)
+ if ctype not in GUILD_CHANS:
+ guild_id = None
+
+ await channel_ack(user_id, channel_id, guild_id, message_id)
+
+ # TODO: validate if this is the correct response
+ return "", 204
+
+
@bp.route("/channels//messages/ack", methods=["DELETE"])
async def delete_read_state(channel_id):
"""Delete the read state of a channel."""
diff --git a/litecord/schemas.py b/litecord/schemas.py
index 3ba1f4c..0f28a0a 100644
--- a/litecord/schemas.py
+++ b/litecord/schemas.py
@@ -619,3 +619,16 @@ BULK_DELETE = {
"schema": {"coerce": int},
}
}
+
+BULK_ACK = {
+ "read_states": {
+ "type": "list",
+ "required": True,
+ "minlength": 0,
+ "maxlength": 100,
+ "schema": {
+ "channel_id": {"coerce": int},
+ "message_id": {"coerce": int},
+ },
+ }
+}