member communication
This commit is contained in:
parent
2398084764
commit
93afdec274
1 changed files with 81 additions and 76 deletions
|
@ -462,88 +462,93 @@ router.get("/", async (req, res) => {
|
|||
}
|
||||
|
||||
// add communications
|
||||
const createCommunicationCommands:CreateCommunicationCommand[] = [];
|
||||
let havePreferred = false;
|
||||
if (queryResultElement.Mobiltelefon && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
||||
const createCommunicationMobile: CreateCommunicationCommand = {
|
||||
memberId: memberId,
|
||||
typeId: sCommTypesByName['SMS'],
|
||||
isSMSAlarming: false,
|
||||
city: "",
|
||||
email: "",
|
||||
mobile: queryResultElement.Mobiltelefon.trim(),
|
||||
preferred: false,
|
||||
street: "",
|
||||
streetNumber: 0,
|
||||
streetNumberAddition: "",
|
||||
if (!queryResultElement.verzogen) {
|
||||
const createCommunicationCommands: CreateCommunicationCommand[] = [];
|
||||
let havePreferred = false;
|
||||
if (queryResultElement.Mobiltelefon && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
||||
const createCommunicationMobile: CreateCommunicationCommand = {
|
||||
memberId: memberId,
|
||||
typeId: sCommTypesByName['SMS'],
|
||||
isSMSAlarming: false,
|
||||
city: "",
|
||||
email: "",
|
||||
mobile: queryResultElement.Mobiltelefon.trim(),
|
||||
postalCode: "",
|
||||
preferred: false,
|
||||
street: "",
|
||||
streetNumber: 0,
|
||||
streetNumberAddition: "",
|
||||
}
|
||||
createCommunicationCommands.push(createCommunicationMobile);
|
||||
}
|
||||
createCommunicationCommands.push(createCommunicationMobile);
|
||||
}
|
||||
if (queryResultElement.email && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
||||
const createCommunicationEmail: CreateCommunicationCommand = {
|
||||
memberId: memberId,
|
||||
typeId: sCommTypesByName['Email'],
|
||||
isSMSAlarming: false,
|
||||
city: "",
|
||||
email: queryResultElement.email,
|
||||
mobile: "",
|
||||
preferred: queryResultElement.EinladungNurPerEmail,
|
||||
street: "",
|
||||
streetNumber: 0,
|
||||
streetNumberAddition: "",
|
||||
if (queryResultElement.email && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
||||
const createCommunicationEmail: CreateCommunicationCommand = {
|
||||
memberId: memberId,
|
||||
typeId: sCommTypesByName['Email'],
|
||||
isSMSAlarming: false,
|
||||
city: "",
|
||||
email: queryResultElement.email,
|
||||
mobile: "",
|
||||
preferred: queryResultElement.EinladungNurPerEmail,
|
||||
postalCode: "",
|
||||
street: "",
|
||||
streetNumber: 0,
|
||||
streetNumberAddition: "",
|
||||
}
|
||||
if (createCommunicationEmail.preferred) {
|
||||
havePreferred = true;
|
||||
}
|
||||
createCommunicationCommands.push(createCommunicationEmail);
|
||||
}
|
||||
if (createCommunicationEmail.preferred) {
|
||||
havePreferred = true;
|
||||
if (queryResultElement.Mobiltelefon && queryResultElement.EinladungNurPerEmail && !queryResultElement.email && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
||||
const preferred = havePreferred === false;
|
||||
const createCommunicationWhatsApp: CreateCommunicationCommand = {
|
||||
memberId: memberId,
|
||||
typeId: sCommTypesByName['WhatsApp'],
|
||||
isSMSAlarming: false,
|
||||
city: "",
|
||||
email: "",
|
||||
mobile: queryResultElement.Mobiltelefon.trim(),
|
||||
postalCode: "",
|
||||
preferred: preferred,
|
||||
street: "",
|
||||
streetNumber: 0,
|
||||
streetNumberAddition: "",
|
||||
}
|
||||
if (createCommunicationWhatsApp.preferred) {
|
||||
havePreferred = true;
|
||||
}
|
||||
createCommunicationCommands.push(createCommunicationWhatsApp);
|
||||
}
|
||||
createCommunicationCommands.push(createCommunicationEmail);
|
||||
}
|
||||
if (queryResultElement.Mobiltelefon && queryResultElement.EinladungNurPerEmail && !queryResultElement.email && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
||||
const preferred = havePreferred === false;
|
||||
const createCommunicationWhatsApp: CreateCommunicationCommand = {
|
||||
memberId: memberId,
|
||||
typeId: sCommTypesByName['WhatsApp'],
|
||||
isSMSAlarming: false,
|
||||
city: "",
|
||||
email: "",
|
||||
mobile: queryResultElement.Mobiltelefon.trim(),
|
||||
preferred: preferred,
|
||||
street: "",
|
||||
streetNumber: 0,
|
||||
streetNumberAddition: "",
|
||||
if (queryResultElement.Ort && queryResultElement.street) {
|
||||
const preferred = havePreferred === false;
|
||||
const createCommunicationMail: CreateCommunicationCommand = {
|
||||
memberId: memberId,
|
||||
typeId: sCommTypesByName['Post'],
|
||||
isSMSAlarming: false,
|
||||
city: queryResultElement.Ort,
|
||||
email: "",
|
||||
mobile: "",
|
||||
preferred: preferred,
|
||||
postalCode: queryResultElement.PLZ,
|
||||
street: queryResultElement.street.trim(),
|
||||
streetNumber: queryResultElement.streetnumber,
|
||||
streetNumberAddition: queryResultElement.streetnumberaddition.trim(),
|
||||
}
|
||||
if (createCommunicationMail.preferred) {
|
||||
havePreferred = true;
|
||||
}
|
||||
createCommunicationCommands.push(createCommunicationMail);
|
||||
}
|
||||
if (createCommunicationWhatsApp.preferred) {
|
||||
havePreferred = true;
|
||||
}
|
||||
createCommunicationCommands.push(createCommunicationWhatsApp);
|
||||
}
|
||||
if (queryResultElement.Ort && queryResultElement.street) {
|
||||
const preferred = havePreferred === false;
|
||||
const createCommunicationMail: CreateCommunicationCommand = {
|
||||
memberId: memberId,
|
||||
typeId: sCommTypesByName['Post'],
|
||||
isSMSAlarming: false,
|
||||
city: queryResultElement.Ort,
|
||||
email: "",
|
||||
mobile: "",
|
||||
preferred: preferred,
|
||||
street: queryResultElement.street.trim(),
|
||||
streetNumber: queryResultElement.streetnumber,
|
||||
streetNumberAddition: queryResultElement.streetnumberaddition.trim(),
|
||||
}
|
||||
if (createCommunicationMail.preferred) {
|
||||
havePreferred = true;
|
||||
}
|
||||
createCommunicationCommands.push(createCommunicationMail);
|
||||
}
|
||||
|
||||
if (createCommunicationCommands.length > 0 && !havePreferred) {
|
||||
console.log(`No preferred communication for ${newMember.firstname} ${newMember.lastname}`)
|
||||
if (createCommunicationCommands.length > 0 && !havePreferred) {
|
||||
console.log(`No preferred communication for ${newMember.firstname} ${newMember.lastname}`)
|
||||
}
|
||||
for (const createCommunicationCommand of createCommunicationCommands) {
|
||||
console.log(`Adding communication for ${sCommTypesById[createCommunicationCommand.typeId]} to ${newMember.firstname} ${newMember.lastname}`)
|
||||
await CommunicationCommandHandler.create(createCommunicationCommand);
|
||||
}
|
||||
}
|
||||
for (const createCommunicationCommand of createCommunicationCommands) {
|
||||
console.log(`Adding communication for ${sCommTypesById[createCommunicationCommand.typeId]} to ${newMember.firstname} ${newMember.lastname}`)
|
||||
await CommunicationCommandHandler.create(createCommunicationCommand);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
res.sendStatus(200);
|
||||
|
|
Loading…
Reference in a new issue