MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / resolvePush

Function resolvePush

apps/web/services/push/index.ts:166–216  ·  view source on GitHub ↗
({
  channel,
  userId,
  event,
  communityId,
}: {
  channel: {
    id: string;
    memberships: {
      archived: boolean | null;
      user: {
        id: string;
        authsId: string | null;
      };
    }[];
    type: ChannelType | null;
  } | null;
  userId: string | undefined;
  event: any;
  communityId: string;
})

Source from the content-addressed store, hash-verified

164};
165
166export function resolvePush({
167 channel,
168 userId,
169 event,
170 communityId,
171}: {
172 channel: {
173 id: string;
174 memberships: {
175 archived: boolean | null;
176 user: {
177 id: string;
178 authsId: string | null;
179 };
180 }[];
181 type: ChannelType | null;
182 } | null;
183 userId: string | undefined;
184 event: any;
185 communityId: string;
186}) {
187 const promises: Promise<any>[] = [];
188
189 if (channel?.type === ChannelType.DM) {
190 channel.memberships.forEach((member) => {
191 if (member.user.id !== userId && member.user.authsId) {
192 promises.push(pushUser({ ...event, userId: member.user.authsId }));
193 }
194 });
195 } else if (channel?.type === ChannelType.PRIVATE) {
196 channel.memberships.forEach((member) => {
197 if (
198 member.user.id !== userId &&
199 member.user.authsId &&
200 !member.archived
201 ) {
202 promises.push(pushUser({ ...event, userId: member.user.authsId }));
203 }
204 });
205 } else {
206 promises.push(
207 ...[
208 // public push
209 push(event),
210 pushChannel(event),
211 pushCommunity({ ...event, communityId }),
212 ]
213 );
214 }
215 return promises;
216}

Callers 2

eventNewThreadFunction · 0.90
eventNewMessageFunction · 0.90

Calls 4

pushUserFunction · 0.85
pushFunction · 0.85
pushChannelFunction · 0.85
pushCommunityFunction · 0.85

Tested by

no test coverage detected