({
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;
})
| 164 | }; |
| 165 | |
| 166 | export 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 | } |
no test coverage detected