[email] Add immediate response if email is in list
This commit is contained in:
parent
b2cafa81ac
commit
92f8ee6a11
|
@ -28,8 +28,6 @@ export class ErrorInterceptor implements HttpInterceptor {
|
||||||
return next.handle(request).pipe(
|
return next.handle(request).pipe(
|
||||||
catchError((err: HttpErrorResponse) => {
|
catchError((err: HttpErrorResponse) => {
|
||||||
if (err.error instanceof ProgressEvent) {
|
if (err.error instanceof ProgressEvent) {
|
||||||
// TODO Add spinner/overlay in app to prevent user input
|
|
||||||
console.log('Networkerror');
|
|
||||||
this.snackBar.openFromComponent(OverlayComponent, {
|
this.snackBar.openFromComponent(OverlayComponent, {
|
||||||
verticalPosition: 'top',
|
verticalPosition: 'top',
|
||||||
});
|
});
|
||||||
|
@ -42,8 +40,7 @@ export class ErrorInterceptor implements HttpInterceptor {
|
||||||
} else if (err.status === 404) {
|
} else if (err.status === 404) {
|
||||||
this.router.navigate(['/404']);
|
this.router.navigate(['/404']);
|
||||||
}
|
}
|
||||||
const error = err.error.message || err.statusText;
|
return throwError(err);
|
||||||
return throwError(error);
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,13 +58,15 @@ export class EmailBotCardComponent implements OnInit {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this.snackBar.open(
|
let errorMsg = 'Unknown error';
|
||||||
'Could not send e-mail to this address. Try again!',
|
if (error.status === 409) {
|
||||||
'Close',
|
errorMsg = 'E-Mail already in list.';
|
||||||
{
|
} else if (error.status === 502) {
|
||||||
duration: 2000,
|
errorMsg = 'Could not send e-mail to this address. Try again!';
|
||||||
}
|
}
|
||||||
);
|
this.snackBar.open(errorMsg, 'Close', {
|
||||||
|
duration: 2000,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,6 +196,9 @@ async def email_subscribe(
|
||||||
token,
|
token,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
|
subs = await EmailSubscribers.objects.filter(email=subscriber.email).all()
|
||||||
|
if subs:
|
||||||
|
raise HTTPException(status_code=status.HTTP_409_CONFLICT)
|
||||||
email.send_email(
|
email.send_email(
|
||||||
subscriber.email,
|
subscriber.email,
|
||||||
"Subscribe to Kibicara " + hood.name,
|
"Subscribe to Kibicara " + hood.name,
|
||||||
|
|
Loading…
Reference in a new issue