MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / processThread

Function processThread

apps/web/services/discord/threads.ts:124–153  ·  view source on GitHub ↗
({
  thread,
  onboardingTimestamp,
  channel,
  token,
  logger,
}: {
  thread: DiscordThread;
  onboardingTimestamp: Date;
  channel: channels;
  token: string;
  logger: Logger;
})

Source from the content-addressed store, hash-verified

122}
123
124async function processThread({
125 thread,
126 onboardingTimestamp,
127 channel,
128 token,
129 logger,
130}: {
131 thread: DiscordThread;
132 onboardingTimestamp: Date;
133 channel: channels;
134 token: string;
135 logger: Logger;
136}) {
137 let linenThread = await findOrCreateThread(parseThread(thread, channel));
138
139 const messages = await crawlExistingThread({
140 thread: linenThread,
141 onboardingTimestamp,
142 token,
143 logger,
144 });
145
146 // persist thread with messages
147 await upsertThreadWithNewMessages({
148 channel,
149 thread: linenThread,
150 messages,
151 logger,
152 });
153}
154
155function parseThread(thread: DiscordThread, channel: channels) {
156 const date = thread.thread_metadata?.create_timestamp || Date.now();

Callers 2

getActiveThreadsFunction · 0.85
getArchivedThreadsFunction · 0.85

Calls 4

findOrCreateThreadFunction · 0.90
parseThreadFunction · 0.85
crawlExistingThreadFunction · 0.85

Tested by

no test coverage detected