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

Method update

apps/web/services/threads/index.ts:92–156  ·  view source on GitHub ↗
({
    id,
    state,
    title,
    pinned,
    accountId,
    channelId,
    resolutionId,
    externalThreadId,
  }: UpdateType)

Source from the content-addressed store, hash-verified

90 }
91
92 static async update({
93 id,
94 state,
95 title,
96 pinned,
97 accountId,
98 channelId,
99 resolutionId,
100 externalThreadId,
101 }: UpdateType) {
102 const exist = await prisma.threads.findFirst({
103 where: { id, channel: { accountId, id: channelId } },
104 });
105 if (!exist) {
106 return null;
107 }
108 const thread = await prisma.threads.update({
109 include: {
110 channel: { select: { accountId: true } },
111 messages: true,
112 },
113 where: { id },
114 data: {
115 pinned,
116 ...(title && { title, slug: slugify(title) }),
117 ...(state && {
118 state,
119 closeAt: state === ThreadState.CLOSE ? new Date().getTime() : null,
120 }),
121 resolutionId,
122 externalThreadId,
123 },
124 });
125
126 if (exist.state !== thread.state) {
127 if (thread.state === ThreadState.CLOSE) {
128 await eventThreadClosed({
129 accountId: accountId || thread.channel.accountId!,
130 channelId: thread.channelId,
131 threadId: id,
132 });
133 } else if (thread.state === ThreadState.OPEN) {
134 await eventThreadReopened({
135 accountId: accountId || thread.channel.accountId!,
136 channelId: thread.channelId,
137 threadId: id,
138 });
139 }
140 }
141
142 const serialized = serializeThread(thread);
143
144 await eventThreadUpdated({
145 communityId: accountId || thread.channel.accountId!,
146 channelId: thread.channelId,
147 messageId: thread.id,
148 threadId: thread.id,
149 imitationId: thread.id,

Callers 15

generateHashFunction · 0.45
buildSentAtForThreadsFunction · 0.45
buildPagesFunction · 0.45
processUploadFunction · 0.45
updateThreadFunction · 0.45
setThreadExternalIdFunction · 0.45
updateMessageFunction · 0.45
setMessageExternalIdFunction · 0.45
taskFunction · 0.45
slugifyTaskFunction · 0.45
taskFunction · 0.45

Calls 5

slugifyFunction · 0.90
eventThreadClosedFunction · 0.90
eventThreadReopenedFunction · 0.90
serializeThreadFunction · 0.90
eventThreadUpdatedFunction · 0.90

Tested by

no test coverage detected