Skip to content

Commit

Permalink
bad idea fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dispherical committed Sep 22, 2024
1 parent 65326da commit 7ea2562
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sections/40-threads.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const utils = require("../utils");
const { createClient } = require("redis");

module.exports = {
title: "🧵 Top 5 most recently active threads",
Expand All @@ -7,7 +8,6 @@ module.exports = {
* @param {{app: import('@slack/bolt').App}} param1
*/
render: async function ({ app, client, prisma }) {

function reduceText(text, link) {
if (text.length <= 160) return text;
if (text.split("\n").length > 1)
Expand All @@ -29,15 +29,16 @@ module.exports = {
message.text &&
message.thread_ts,
)
.reduce(async (acc, message) => {
.reduce((acc, message) => {
let thread_ts = message.thread_ts;

if (
!acc.find((item) => item.thread_ts === thread_ts) &&
!acc.find((item) => item.channel === message.channel)
) {
const id = crypto.randomUUID().slice(0, 3);
await client.set(`url.${id}`, `https://hackclub.slack.com/archives/${message.channel}/p${message.ts.toString().replace(".", "")}`)
client.set(`url.${id}`, `https://hackclub.slack.com/archives/${message.channel}/p${message.ts.toString().replace(".", "")}`)
client.
acc.push({
thread_ts: thread_ts,
permalink: `https://l.hack.club/${id}`,
Expand Down

0 comments on commit 7ea2562

Please sign in to comment.