summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-05-15 19:56:55 +0500
committerilotterytea <iltsu@alright.party>2025-05-15 19:56:55 +0500
commit98e7d4bcb8fdf99d97f95be2fb0cc18a0543808b (patch)
tree27e7899153f52db4d838018f3d86ad5defc6c8c6
parent7a247f38ae73e982eb4fd91517320877eec2f3f9 (diff)
upd: more emote data fields in json responses
-rw-r--r--public/emotes/upload.php31
-rw-r--r--src/emote.php2
2 files changed, 21 insertions, 12 deletions
diff --git a/public/emotes/upload.php b/public/emotes/upload.php
index df64d0f..644e4b6 100644
--- a/public/emotes/upload.php
+++ b/public/emotes/upload.php
@@ -475,6 +475,7 @@ if ($is_manual) {
}
$tags = str_safe($_POST["tags"] ?? "", null);
+$tags_processed = [];
if (!empty($tags) && TAGS_ENABLE) {
$tags = explode(" ", $tags);
@@ -505,21 +506,33 @@ if (!empty($tags) && TAGS_ENABLE) {
$db->prepare("INSERT INTO tag_assigns(tag_id, emote_id) VALUES (?, ?)")->execute([$tag_id, $id]);
$count++;
+ array_push($tags_processed, $tag);
}
}
+$emote_data = [
+ "id" => $id,
+ "code" => $code,
+ "visibility" => $visibility,
+ "uploaded_by" => match ($uploaded_by == null) {
+ true => null,
+ false => [
+ "id" => $uploaded_by,
+ "username" => $uploader_name
+ ]
+ },
+ "notes" => $notes,
+ "source" => $source,
+ "tags" => $tags_processed
+];
+
if (ACCOUNT_LOG_ACTIONS && $uploaded_by != null) {
$db->prepare("INSERT INTO actions(user_id, action_type, action_payload) VALUES (?, ?, ?)")
->execute([
$uploaded_by,
"EMOTE_CREATE",
json_encode([
- "emote" => [
- "id" => $id,
- "code" => $code,
- "visibility" => $visibility,
- "uploaded_by" => $uploaded_by,
- ]
+ "emote" => $emote_data
])
]);
}
@@ -531,11 +544,7 @@ if (CLIENT_REQUIRES_JSON) {
json_response([
"status_code" => 201,
"message" => null,
- "data" => [
- "id" => $id,
- "code" => $code,
- "uploaded_by" => $uploaded_by
- ]
+ "data" => $emote_data
], 201);
exit;
}
diff --git a/src/emote.php b/src/emote.php
index 7e589e4..74db4ca 100644
--- a/src/emote.php
+++ b/src/emote.php
@@ -83,7 +83,7 @@ function fetch_all_emotes_from_emoteset(PDO &$db, string $emote_set_id, string $
{
// fetching emotes
$sql = "SELECT
- e.id, e.created_at,
+ e.id, e.created_at, e.visibility,
CASE
WHEN esc.code IS NOT NULL THEN esc.code
ELSE e.code