2021-07-01 02:21:16 +02:00
|
|
|
import { LogType } from "../../../data/LogType";
|
2021-07-25 14:32:08 +02:00
|
|
|
import { differenceToString, getScalarDifference } from "../../../utils";
|
2021-08-18 01:51:42 +03:00
|
|
|
import { channelToTemplateSafeChannel } from "../../../utils/templateSafeObjects";
|
2021-07-01 02:21:16 +02:00
|
|
|
import { logsEvt } from "../types";
|
2021-08-18 01:51:42 +03:00
|
|
|
import { logThreadCreate } from "../logFunctions/logThreadCreate";
|
|
|
|
import { logThreadDelete } from "../logFunctions/logThreadDelete";
|
|
|
|
import { logThreadUpdate } from "../logFunctions/logThreadUpdate";
|
2021-07-01 02:21:16 +02:00
|
|
|
|
|
|
|
export const LogsThreadCreateEvt = logsEvt({
|
|
|
|
event: "threadCreate",
|
|
|
|
|
|
|
|
async listener(meta) {
|
2021-08-18 01:51:42 +03:00
|
|
|
logThreadCreate(meta.pluginData, {
|
|
|
|
thread: meta.args.thread,
|
2021-07-01 02:21:16 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export const LogsThreadDeleteEvt = logsEvt({
|
|
|
|
event: "threadDelete",
|
|
|
|
|
|
|
|
async listener(meta) {
|
2021-08-18 01:51:42 +03:00
|
|
|
logThreadDelete(meta.pluginData, {
|
|
|
|
thread: meta.args.thread,
|
2021-07-01 02:21:16 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export const LogsThreadUpdateEvt = logsEvt({
|
|
|
|
event: "threadUpdate",
|
|
|
|
|
|
|
|
async listener(meta) {
|
2021-07-01 04:40:39 +02:00
|
|
|
const diff = getScalarDifference(meta.args.oldThread, meta.args.newThread, ["messageCount", "archiveTimestamp"]);
|
|
|
|
const differenceString = differenceToString(diff);
|
|
|
|
|
2021-08-18 01:51:42 +03:00
|
|
|
logThreadUpdate(meta.pluginData, {
|
|
|
|
oldThread: meta.args.oldThread,
|
|
|
|
newThread: meta.args.newThread,
|
|
|
|
differenceString,
|
|
|
|
});
|
2021-07-01 02:21:16 +02:00
|
|
|
},
|
|
|
|
});
|