Added mutation key to features.
Main / build-and-push-docker-image (20.x) (push) Successful in 3m32s

This commit is contained in:
2025-12-10 19:39:15 -05:00
parent 465fbf96c9
commit 2050e61706
9 changed files with 84 additions and 27 deletions
+17 -9
View File
@@ -12,12 +12,14 @@ const composer = new Composer<Context>();
const feature = composer.chatType(["group", "supergroup"]);
const mutationKey = process.env.GRAPHQL_MUTATION_KEY || "";
/**
* What triggers this feature and adds to the log when it has been triggered.
* The trigger is anytime an embedded url is detected.
*/
feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
await urql.mutation(increment, { trigger: true });
await urql.mutation(increment, { trigger: true, mutationKey });
if (ctx.chat && ctx.msg) {
const groupName = ctx.chat?.title;
@@ -49,7 +51,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
deletedLinks++;
await urql
.mutation(increment, { link: true })
.mutation(increment, { link: true, mutationKey })
.toPromise()
.then(async () => {
if (ctx.msg) {
@@ -69,7 +71,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
deletedLinks++;
await urql
.mutation(increment, { link: true })
.mutation(increment, { link: true, mutationKey })
.toPromise()
.then(async () => {
if (ctx.msg) {
@@ -89,7 +91,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
deletedLinks++;
await urql
.mutation(increment, { link: true })
.mutation(increment, { link: true, mutationKey })
.toPromise()
.then(async () => {
if (ctx.msg) {
@@ -114,7 +116,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
deletedLinks++;
await urql
.mutation(increment, { link: true })
.mutation(increment, { link: true, mutationKey })
.toPromise()
.then(async () => {
if (ctx.msg) {
@@ -134,7 +136,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
deletedLinks++;
await urql
.mutation(increment, { link: true })
.mutation(increment, { link: true, mutationKey })
.toPromise()
.then(async () => {
if (ctx.msg) {
@@ -154,7 +156,7 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
deletedLinks++;
await urql
.mutation(increment, { link: true })
.mutation(increment, { link: true, mutationKey })
.toPromise()
.then(async () => {
if (ctx.msg) {
@@ -169,12 +171,18 @@ feature.on("message::url", logHandle("embed-check"), async (ctx: Context) => {
if (deletedLinks) {
return await urql
.mutation(addGroup, { groupID, groupName, groupUsername })
.mutation(addGroup, {
groupID,
groupName,
groupUsername,
mutationKey
})
.toPromise()
.then(() =>
urql.mutation(incrementGroup, {
groupID,
linksDeleted: deletedLinks
linksDeleted: deletedLinks,
mutationKey
})
);
}