Skip to content

Commit

Permalink
Merge pull request #38 from AplinkosMinisterija/mails-fixes
Browse files Browse the repository at this point in the history
mails
  • Loading branch information
ambrazasp authored May 13, 2024
2 parents c559a8d + 2344726 commit 2580ce8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
9 changes: 2 additions & 7 deletions services/forms.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,10 @@ export default class FormsService extends moleculer.Service {
form.objectName
);

if (
!emailCanBeSent() ||
!object?.name ||
[FormStatus.SUBMITTED].includes(form.status)
)
return;
if (!emailCanBeSent() || !object?.name) return;

// TODO: send email for admins / assignees.
if ([FormStatus.CREATED].includes(form.status)) {
if ([FormStatus.CREATED, FormStatus.SUBMITTED].includes(form.status)) {
return notifyOnFormUpdate(
NOTIFY_ADMIN_EMAIL,
form.status,
Expand Down
6 changes: 4 additions & 2 deletions services/requests.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,16 @@ export default class RequestsService extends moleculer.Service {
async sendNotificationOnStatusChange(request: Request) {
if (
!emailCanBeSent() ||
[RequestStatus.SUBMITTED, RequestStatus.APPROVED].includes(request.status)
[RequestStatus.APPROVED].includes(request.status)
) {
// Do not send when approved - when file will be generated email will be sent
return;
}

// TODO: send email for admins using settings.
if ([RequestStatus.CREATED].includes(request.status)) {
if (
[RequestStatus.CREATED, RequestStatus.SUBMITTED].includes(request.status)
) {
return notifyOnRequestUpdate(
NOTIFY_ADMIN_EMAIL,
request.status,
Expand Down
7 changes: 4 additions & 3 deletions utils/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ export function getObjectByCadastralId(
id: string | number,
fallbackItem?: object
) {
return fetch(
`https://dev.qgis.biip.lt/qgisserver/uetk_zuvinimas?SERVICE=WFS&REQUEST=GetFeature&TYPENAME=uetk_zuvinimas_info&OUTPUTFORMAT=application/json&FILTER=%3CFilter%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Ecadastral_id%3C/PropertyName%3E%3CLiteral%3E${id}%3C/Literal%3E%3C/PropertyIsEqualTo%3E%3C/Filter%3E`
)
const host = process.env.QGIS_SERVER_HOST || 'https://gis.biip.lt';
const url = `${host}/qgisserver/uetk_zuvinimas?SERVICE=WFS&REQUEST=GetFeature&TYPENAME=uetk_zuvinimas_info&OUTPUTFORMAT=application/json&FILTER=%3CFilter%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Ecadastral_id%3C/PropertyName%3E%3CLiteral%3E${id}%3C/Literal%3E%3C/PropertyIsEqualTo%3E%3C/Filter%3E`;

return fetch(url)
.then((r) => r.json())
.then((r) => r.features)
.then((r) => {
Expand Down

0 comments on commit 2580ce8

Please sign in to comment.