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
|
// add communications
|
||||||
const createCommunicationCommands:CreateCommunicationCommand[] = [];
|
if (!queryResultElement.verzogen) {
|
||||||
let havePreferred = false;
|
const createCommunicationCommands: CreateCommunicationCommand[] = [];
|
||||||
if (queryResultElement.Mobiltelefon && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
let havePreferred = false;
|
||||||
const createCommunicationMobile: CreateCommunicationCommand = {
|
if (queryResultElement.Mobiltelefon && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
||||||
memberId: memberId,
|
const createCommunicationMobile: CreateCommunicationCommand = {
|
||||||
typeId: sCommTypesByName['SMS'],
|
memberId: memberId,
|
||||||
isSMSAlarming: false,
|
typeId: sCommTypesByName['SMS'],
|
||||||
city: "",
|
isSMSAlarming: false,
|
||||||
email: "",
|
city: "",
|
||||||
mobile: queryResultElement.Mobiltelefon.trim(),
|
email: "",
|
||||||
preferred: false,
|
mobile: queryResultElement.Mobiltelefon.trim(),
|
||||||
street: "",
|
postalCode: "",
|
||||||
streetNumber: 0,
|
preferred: false,
|
||||||
streetNumberAddition: "",
|
street: "",
|
||||||
|
streetNumber: 0,
|
||||||
|
streetNumberAddition: "",
|
||||||
|
}
|
||||||
|
createCommunicationCommands.push(createCommunicationMobile);
|
||||||
}
|
}
|
||||||
createCommunicationCommands.push(createCommunicationMobile);
|
if (queryResultElement.email && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
||||||
}
|
const createCommunicationEmail: CreateCommunicationCommand = {
|
||||||
if (queryResultElement.email && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
memberId: memberId,
|
||||||
const createCommunicationEmail: CreateCommunicationCommand = {
|
typeId: sCommTypesByName['Email'],
|
||||||
memberId: memberId,
|
isSMSAlarming: false,
|
||||||
typeId: sCommTypesByName['Email'],
|
city: "",
|
||||||
isSMSAlarming: false,
|
email: queryResultElement.email,
|
||||||
city: "",
|
mobile: "",
|
||||||
email: queryResultElement.email,
|
preferred: queryResultElement.EinladungNurPerEmail,
|
||||||
mobile: "",
|
postalCode: "",
|
||||||
preferred: queryResultElement.EinladungNurPerEmail,
|
street: "",
|
||||||
street: "",
|
streetNumber: 0,
|
||||||
streetNumber: 0,
|
streetNumberAddition: "",
|
||||||
streetNumberAddition: "",
|
}
|
||||||
|
if (createCommunicationEmail.preferred) {
|
||||||
|
havePreferred = true;
|
||||||
|
}
|
||||||
|
createCommunicationCommands.push(createCommunicationEmail);
|
||||||
}
|
}
|
||||||
if (createCommunicationEmail.preferred) {
|
if (queryResultElement.Mobiltelefon && queryResultElement.EinladungNurPerEmail && !queryResultElement.email && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
||||||
havePreferred = true;
|
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.Ort && queryResultElement.street) {
|
||||||
}
|
const preferred = havePreferred === false;
|
||||||
if (queryResultElement.Mobiltelefon && queryResultElement.EinladungNurPerEmail && !queryResultElement.email && !queryResultElement.verstorben && !queryResultElement.verzogenDatum) {
|
const createCommunicationMail: CreateCommunicationCommand = {
|
||||||
const preferred = havePreferred === false;
|
memberId: memberId,
|
||||||
const createCommunicationWhatsApp: CreateCommunicationCommand = {
|
typeId: sCommTypesByName['Post'],
|
||||||
memberId: memberId,
|
isSMSAlarming: false,
|
||||||
typeId: sCommTypesByName['WhatsApp'],
|
city: queryResultElement.Ort,
|
||||||
isSMSAlarming: false,
|
email: "",
|
||||||
city: "",
|
mobile: "",
|
||||||
email: "",
|
preferred: preferred,
|
||||||
mobile: queryResultElement.Mobiltelefon.trim(),
|
postalCode: queryResultElement.PLZ,
|
||||||
preferred: preferred,
|
street: queryResultElement.street.trim(),
|
||||||
street: "",
|
streetNumber: queryResultElement.streetnumber,
|
||||||
streetNumber: 0,
|
streetNumberAddition: queryResultElement.streetnumberaddition.trim(),
|
||||||
streetNumberAddition: "",
|
}
|
||||||
|
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) {
|
if (createCommunicationCommands.length > 0 && !havePreferred) {
|
||||||
console.log(`No preferred communication for ${newMember.firstname} ${newMember.lastname}`)
|
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);
|
res.sendStatus(200);
|
||||||
|
|
Loading…
Reference in a new issue