Compare commits
No commits in common. "v0.1.6" and "master" have entirely different histories.
25
CHANGELOG.md
25
CHANGELOG.md
@ -2,31 +2,6 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [0.1.6](https://gitea.cor.bz/corbz/relay/compare/v0.1.5...v0.1.6) (2025-05-22)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add proper logging with winston ([5ad6950](https://gitea.cor.bz/corbz/relay/commit/5ad695059e009d24aaf08b728300d9d50c45b2b3))
|
||||
* **bot:** boilerplate for adding interaction commands and event listeners ([cf8713c](https://gitea.cor.bz/corbz/relay/commit/cf8713c1bb44d9aa19a356e966a414dfe1ceb6bc))
|
||||
* **bot:** implement 'all' filter ([540de53](https://gitea.cor.bz/corbz/relay/commit/540de53cd0bcf2414924262a2ad680ca6ab2cd13))
|
||||
* **bot:** implement 'literal' filter ([755bf32](https://gitea.cor.bz/corbz/relay/commit/755bf327749798e56d5aa8e2dbdb89a38c28014f))
|
||||
* **bot:** implement filtering on published threshold param ([72fe545](https://gitea.cor.bz/corbz/relay/commit/72fe545211097a30692bf008ca42e45a728c82ac))
|
||||
* **bot:** regex filter implementation ([f294a75](https://gitea.cor.bz/corbz/relay/commit/f294a751dcebabbbb9e81f79a3b4b4e83d3fca07))
|
||||
* display colour preview in style table ([cc845d3](https://gitea.cor.bz/corbz/relay/commit/cc845d3adcd505c50d857a407568e80923327143))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **actions:** correct poorly written build command ([99e1b0e](https://gitea.cor.bz/corbz/relay/commit/99e1b0ef961b535315cfab5ca86f1ca72a79e863))
|
||||
* **api:** filter not deleting entries ([e81275c](https://gitea.cor.bz/corbz/relay/commit/e81275cf9f8c8875872be9431c1fa447c48f8faf))
|
||||
* **api:** filter post not accessing guildId correctly ([43f994f](https://gitea.cor.bz/corbz/relay/commit/43f994fd6c55827e1c82b1273c4c6ecf958b9429))
|
||||
* feed page - missing ordering params and row select functionality ([9b6eb86](https://gitea.cor.bz/corbz/relay/commit/9b6eb86cd8bdcaa00014416187f130b57831172e))
|
||||
* feed table - pointer events on 'style' header despite lack of ordering ([c0ddec1](https://gitea.cor.bz/corbz/relay/commit/c0ddec1c71313e3d499e7ee0161a14a85f9643d5))
|
||||
* fix bad logger import ([5303d81](https://gitea.cor.bz/corbz/relay/commit/5303d81b1973c9f80f0f4dc609d7e213564a7b15))
|
||||
* style colour being reset on edit modal ([fb76266](https://gitea.cor.bz/corbz/relay/commit/fb762662506bd98c3b7310befbeaf308b7805c6e))
|
||||
* style table search broken due to searching on unsearchable columns ([e5f04a2](https://gitea.cor.bz/corbz/relay/commit/e5f04a2c7daefde019414dc037d17cf3a79035c8))
|
||||
|
||||
### [0.1.5](https://gitea.cor.bz/corbz/relay/compare/v0.1.4...v0.1.5) (2025-05-09)
|
||||
|
||||
|
||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "relay",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "relay",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.5",
|
||||
"license": "GPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@floating-ui/dom": "^1.6.13",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "relay",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.5",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
|
@ -32,7 +32,7 @@ const HOST = process.env.HOST || "localhost";
|
||||
const PORT = process.env.PORT || 3000;
|
||||
|
||||
const server = app.listen(PORT, () => {
|
||||
logger.info(`Server is listening on http://${HOST}:${PORT}`);
|
||||
logger.info(`Server is listening on port http://${HOST}:${PORT}`);
|
||||
});
|
||||
|
||||
process.on("SIGINT", () => {
|
||||
|
@ -84,6 +84,7 @@ export const patch = async (request: Request, response: Response) => {
|
||||
};
|
||||
|
||||
const updateInputData: Prisma.FeedUncheckedUpdateInput = {
|
||||
id: Number(body.id),
|
||||
name: body.name,
|
||||
url: body.url,
|
||||
active: body.active,
|
||||
|
@ -1,14 +1,9 @@
|
||||
import { Request, Response } from "express";
|
||||
import prisma, { Prisma } from "@server/prisma";
|
||||
import { datatableRequest } from "@server/controllers/guild/api/dt.module";
|
||||
import { getLogger } from "@server/../log";
|
||||
|
||||
const logger = getLogger(__filename);
|
||||
|
||||
// TODO: this doesn't account for guild ID or permissions
|
||||
export const get = async (request: Request, response: Response) => {
|
||||
logger.info(`Getting filter: ${request.query.id}`);
|
||||
|
||||
if (!request.query.id) {
|
||||
response.status(400).json({ error: "missing 'id' query" });
|
||||
return;
|
||||
@ -27,81 +22,90 @@ export const get = async (request: Request, response: Response) => {
|
||||
};
|
||||
|
||||
export const post = async (request: Request, response: Response) => {
|
||||
logger.info(`Posting filter: ${request.body.value} - ${request.params.guildId}`);
|
||||
const guildId = request.params.guildId;
|
||||
const { name, value, matching_algorithm, is_insensitive, is_whitelist } = request.body;
|
||||
|
||||
const body = {
|
||||
...request.body,
|
||||
is_insensitive: request.body.is_insensitive === "on",
|
||||
is_whitelist: request.body.is_whitelist === "on"
|
||||
};
|
||||
|
||||
const createInputData: Prisma.FilterUncheckedCreateInput = {
|
||||
guild_id: request.params.guildId,
|
||||
name: body.name,
|
||||
value: body.value,
|
||||
matching_algorithm: body.matching_algorithm,
|
||||
is_insensitive: body.is_insensitive,
|
||||
is_whitelist: body.is_whitelist
|
||||
};
|
||||
let filter;
|
||||
|
||||
try {
|
||||
const createResponse = await prisma.filter.create({ data: createInputData });
|
||||
response.status(201).json(createResponse);
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
const isPrismaError = error instanceof Prisma.PrismaClientKnownRequestError;
|
||||
response.status(500).json({ error: isPrismaError ? error.message : error });
|
||||
filter = await prisma.filter.create({
|
||||
data: {
|
||||
name: name,
|
||||
guild_id: guildId,
|
||||
value: value,
|
||||
matching_algorithm: matching_algorithm,
|
||||
is_insensitive: is_insensitive === "on",
|
||||
is_whitelist: is_whitelist === "on"
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
response.status(500).json({ error: error.message });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
response.status(201).json(filter);
|
||||
};
|
||||
|
||||
export const patch = async (request: Request, response: Response) => {
|
||||
logger.info(`Patching filter: ${request.body.id} - ${request.params.guildId}`);
|
||||
const guildId = request.params.guildId;
|
||||
const { id, name, value, matching_algorithm, is_insensitive, is_whitelist } = request.body;
|
||||
|
||||
const body = {
|
||||
...request.body,
|
||||
is_insensitive: request.body.is_insensitive === "on",
|
||||
is_whitelist: request.body.is_whitelist === "on"
|
||||
};
|
||||
|
||||
const updateInputData: Prisma.FilterUncheckedUpdateInput = {
|
||||
guild_id: request.params.guildId,
|
||||
name: body.name,
|
||||
value: body.value,
|
||||
matching_algorithm: body.matching_algorithm,
|
||||
is_insensitive: body.is_insensitive,
|
||||
is_whitelist: body.is_whitelist
|
||||
};
|
||||
let filter;
|
||||
|
||||
try {
|
||||
const updateArgs = { where: { id: Number(body.id) }, data: updateInputData };
|
||||
const updateResponse = await prisma.filter.update(updateArgs);
|
||||
response.status(200).json(updateResponse);
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
const isPrismaError = error instanceof Prisma.PrismaClientKnownRequestError;
|
||||
response.status(500).json({ error: isPrismaError ? error.message : error });
|
||||
filter = await prisma.filter.update({
|
||||
where: { id: Number(id) },
|
||||
data: {
|
||||
name: name,
|
||||
guild_id: guildId,
|
||||
value: value,
|
||||
matching_algorithm: matching_algorithm,
|
||||
is_insensitive: is_insensitive === "on",
|
||||
is_whitelist: is_whitelist === "on"
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
response.status(500).json({ error: error.message });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
response.status(201).json(filter);
|
||||
};
|
||||
|
||||
export const del = async (request: Request, response: Response) => {
|
||||
logger.info(`Deleting filter(s): ${request.body.ids} - ${request.params.guildId}`);
|
||||
let { ids } = request.body;
|
||||
const guildId = request.params.guildId;
|
||||
|
||||
const ids = request.body.ids?.map((id: string) => Number(id));
|
||||
|
||||
if (!ids) {
|
||||
response.status(400).json({ error: "Couldn't parse ID's from request body" });
|
||||
if (!ids || !Array.isArray(ids)) {
|
||||
response.status(400).json({ error: "invalid request body" });
|
||||
return;
|
||||
}
|
||||
|
||||
ids = ids.map(id => Number(id));
|
||||
|
||||
try {
|
||||
const deleteArgs = { where: { guild_id: request.params.guildId, id: { in: ids } } };
|
||||
await prisma.filter.deleteMany(deleteArgs);
|
||||
response.status(204).send();
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
const isPrismaError = error instanceof Prisma.PrismaClientKnownRequestError;
|
||||
response.status(500).json({ error: isPrismaError ? error.message : error });
|
||||
await prisma.filter.deleteMany({ where: {
|
||||
id: { in: ids },
|
||||
guild_id: guildId
|
||||
}});
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
response.status(500).json({ error: error.message });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
response.status(204).json(null);
|
||||
};
|
||||
|
||||
export const datatable = async (request: Request, response: Response) => {
|
||||
@ -116,10 +120,13 @@ export const datatable = async (request: Request, response: Response) => {
|
||||
};
|
||||
|
||||
export const select = async (request: Request, response: Response) => {
|
||||
const guildId = request.params.guildId;
|
||||
const { search } = request.query;
|
||||
|
||||
const data = await prisma.filter.findMany({
|
||||
where: {
|
||||
guild_id: request.params.guildId,
|
||||
name: { contains: `${request.query.search}` }
|
||||
guild_id: guildId,
|
||||
name: { contains: `${search}` }
|
||||
}
|
||||
});
|
||||
|
||||
@ -132,7 +139,7 @@ export const select = async (request: Request, response: Response) => {
|
||||
title: filter.name
|
||||
}));
|
||||
|
||||
response.status(200).json(modifiedResults);
|
||||
response.json(modifiedResults);
|
||||
};
|
||||
|
||||
export default { get, post, patch, del, datatable, select };
|
@ -1,13 +1,9 @@
|
||||
import { Request, Response } from "express";
|
||||
import prisma, { Prisma } from "@server/prisma";
|
||||
import { datatableRequest } from "@server/controllers/guild/api/dt.module";
|
||||
import { getLogger } from "@server/../log";
|
||||
|
||||
const logger = getLogger(__filename);
|
||||
import { logger } from "@server/../log";
|
||||
|
||||
export const get = async (request: Request, response: Response) => {
|
||||
logger.info(`Getting style: ${request.query.id}`);
|
||||
|
||||
if (!request.query.id) {
|
||||
response.status(400).json({ error: "missing 'id' query" });
|
||||
return;
|
||||
@ -26,95 +22,121 @@ export const get = async (request: Request, response: Response) => {
|
||||
};
|
||||
|
||||
export const post = async (request: Request, response: Response) => {
|
||||
logger.info(`Posting style: ${request.body.colour} - ${request.params.guildId}`);
|
||||
const guildId = request.params.guildId;
|
||||
const {
|
||||
name,
|
||||
show_author,
|
||||
show_image,
|
||||
show_thumbnail,
|
||||
show_footer,
|
||||
show_timestamp,
|
||||
colour,
|
||||
title_mutator,
|
||||
description_mutator
|
||||
} = request.body;
|
||||
|
||||
const body = {
|
||||
...request.body,
|
||||
show_author: request.body.show_author === "on",
|
||||
show_image: request.body.show_image === "on",
|
||||
show_thumbnail: request.body.show_thumbnail === "on",
|
||||
show_footer: request.body.show_footer === "on",
|
||||
show_timestamp: request.body.show_timestamp === "on"
|
||||
};
|
||||
logger.debug("Style Post", request.body);
|
||||
|
||||
const createInputData: Prisma.MessageStyleUncheckedCreateInput = {
|
||||
guild_id: request.params.guildId,
|
||||
name: body.name,
|
||||
colour: body.colour,
|
||||
show_author: body.show_author,
|
||||
show_image: body.show_image,
|
||||
show_thumbnail: body.show_thumbnail,
|
||||
show_footer: body.show_footer,
|
||||
show_timestamp: body.show_timestamp,
|
||||
title_mutator: body.title_mutator || null,
|
||||
description_mutator: body.description_mutator || null
|
||||
};
|
||||
let style;
|
||||
|
||||
try {
|
||||
const createResponse = await prisma.messageStyle.create({ data: createInputData });
|
||||
response.status(201).json(createResponse);
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
const isPrismaError = error instanceof Prisma.PrismaClientKnownRequestError;
|
||||
response.status(500).json({ error: isPrismaError ? error.message : error });
|
||||
style = await prisma.messageStyle.create({
|
||||
data: {
|
||||
name: name,
|
||||
guild_id: guildId,
|
||||
show_author: show_author === "on",
|
||||
show_image: show_image === "on",
|
||||
show_thumbnail: show_thumbnail === "on",
|
||||
show_footer: show_footer === "on",
|
||||
show_timestamp: show_timestamp === "on",
|
||||
colour: colour,
|
||||
title_mutator: title_mutator || null,
|
||||
description_mutator: description_mutator || null
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
response.status(500).json({ error: error.message });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
response.status(201).json(style);
|
||||
};
|
||||
|
||||
export const patch = async (request: Request, response: Response) => {
|
||||
logger.info(`Patching style: ${request.body.id} - ${request.params.guildId}`);
|
||||
const guildId = request.params.guildId;
|
||||
const {
|
||||
id,
|
||||
name,
|
||||
show_author,
|
||||
show_image,
|
||||
show_thumbnail,
|
||||
show_footer,
|
||||
show_timestamp,
|
||||
colour,
|
||||
title_mutator,
|
||||
description_mutator
|
||||
} = request.body;
|
||||
|
||||
const body = {
|
||||
...request.body,
|
||||
show_author: request.body.show_author === "on",
|
||||
show_image: request.body.show_image === "on",
|
||||
show_thumbnail: request.body.show_thumbnail === "on",
|
||||
show_footer: request.body.show_footer === "on",
|
||||
show_timestamp: request.body.show_timestamp === "on"
|
||||
};
|
||||
|
||||
const updateInputData: Prisma.MessageStyleUncheckedUpdateInput = {
|
||||
guild_id: request.params.guildId,
|
||||
name: body.name,
|
||||
colour: body.colour,
|
||||
show_author: body.show_author,
|
||||
show_image: body.show_image,
|
||||
show_thumbnail: body.show_thumbnail,
|
||||
show_footer: body.show_footer,
|
||||
show_timestamp: body.show_timestamp,
|
||||
title_mutator: body.title_mutator || null,
|
||||
description_mutator: body.description_mutator || null
|
||||
};
|
||||
let style;
|
||||
|
||||
try {
|
||||
const updateArgs = { where: { id: Number(body.id) }, data: updateInputData };
|
||||
const updateResponse = await prisma.messageStyle.update(updateArgs);
|
||||
response.status(200).json(updateResponse);
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
const isPrismaError = error instanceof Prisma.PrismaClientKnownRequestError;
|
||||
response.status(500).json({ error: isPrismaError ? error.message : error });
|
||||
style = await prisma.messageStyle.update({
|
||||
where: { id: Number(id) },
|
||||
data: {
|
||||
name: name,
|
||||
guild_id: guildId,
|
||||
show_author: show_author === "on",
|
||||
show_image: show_image === "on",
|
||||
show_thumbnail: show_thumbnail === "on",
|
||||
show_footer: show_footer === "on",
|
||||
show_timestamp: show_timestamp === "on",
|
||||
colour: colour,
|
||||
title_mutator: title_mutator || null,
|
||||
description_mutator: description_mutator || null
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
response.status(500).json({ error: error.message });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
response.status(201).json(style);
|
||||
};
|
||||
|
||||
export const del = async (request: Request, response: Response) => {
|
||||
logger.info(`Deleting style(s): ${request.body.ids} - ${request.params.guildId}`)
|
||||
let { ids } = request.body;
|
||||
const guildId = request.params.guildId;
|
||||
|
||||
const ids = request.body.ids?.map((id: string) => Number(id));
|
||||
|
||||
if (!ids) {
|
||||
response.status(400).json({ error: "Couldn't parse ID's from request body" });
|
||||
if (!ids || !Array.isArray(ids)) {
|
||||
response.status(400).json({ error: "invalid request body" });
|
||||
return;
|
||||
}
|
||||
|
||||
ids = ids.map(id => Number(id));
|
||||
|
||||
try {
|
||||
const deleteArgs = { where: { guild_id: request.params.guildId, id: { in: ids } } };
|
||||
await prisma.messageStyle.deleteMany(deleteArgs);
|
||||
response.status(204).send();
|
||||
} catch (error) {
|
||||
logger.error(error);
|
||||
const isPrismaError = error instanceof Prisma.PrismaClientKnownRequestError;
|
||||
response.status(500).json({ error: isPrismaError ? error.message : error });
|
||||
await prisma.messageStyle.deleteMany({ where: {
|
||||
id: { in: ids },
|
||||
guild_id: guildId
|
||||
}});
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
response.status(500).json({ error: error.message });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
response.status(204).json(null);
|
||||
};
|
||||
|
||||
export const datatable = async (request: Request, response: Response) => {
|
||||
@ -129,10 +151,13 @@ export const datatable = async (request: Request, response: Response) => {
|
||||
};
|
||||
|
||||
export const select = async (request: Request, response: Response) => {
|
||||
const guildId = request.params.guildId;
|
||||
const { search } = request.query;
|
||||
|
||||
const data = await prisma.messageStyle.findMany({
|
||||
where: {
|
||||
guild_id: request.params.guildId,
|
||||
name: { contains: `${request.query.search}` }
|
||||
guild_id: guildId,
|
||||
name: { contains: `${search}` }
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user