const program = Effect.gen(function* () {
const channel = yield* getChannelById(ctx, {
userOrganizationId: ctx.user.defaultOrganizationId!,
channelId: args.channelId,
});
const destination = yield* getDestinationById(ctx, {
userOrganizationId: ctx.user.defaultOrganizationId!,
destinationId: args.destinationId,
});
const matcher = Match.value({ channel, args, destination }).pipe(
// infobip text message
Match.when(
{
channel: {
type: "infobip:whatsapp",
},
args: {
infobip: {
whatsappTextMessage: (x) => !!x,
},
},
},
({ channel, destination, args }) => {
// send infobip text message
return sendInfobipTextMessage(ctx, {
textMessage: args.infobip.whatsappTextMessage,
channel,
destination,
userId: ctx.user._id,
});
},
),
// ...
);
return yield* Effect.asVoid(matcher);
});
const program = Effect.gen(function* () {
const channel = yield* getChannelById(ctx, {
userOrganizationId: ctx.user.defaultOrganizationId!,
channelId: args.channelId,
});
const destination = yield* getDestinationById(ctx, {
userOrganizationId: ctx.user.defaultOrganizationId!,
destinationId: args.destinationId,
});
const matcher = Match.value({ channel, args, destination }).pipe(
// infobip text message
Match.when(
{
channel: {
type: "infobip:whatsapp",
},
args: {
infobip: {
whatsappTextMessage: (x) => !!x,
},
},
},
({ channel, destination, args }) => {
// send infobip text message
return sendInfobipTextMessage(ctx, {
textMessage: args.infobip.whatsappTextMessage,
channel,
destination,
userId: ctx.user._id,
});
},
),
// ...
);
return yield* Effect.asVoid(matcher);
});