[email] Add immediate response if email is in list

This commit is contained in:
Cathy Hu 2020-09-11 18:40:35 +02:00
parent b2cafa81ac
commit 92f8ee6a11
3 changed files with 13 additions and 11 deletions

View file

@ -28,8 +28,6 @@ export class ErrorInterceptor implements HttpInterceptor {
return next.handle(request).pipe(
catchError((err: HttpErrorResponse) => {
if (err.error instanceof ProgressEvent) {
// TODO Add spinner/overlay in app to prevent user input
console.log('Networkerror');
this.snackBar.openFromComponent(OverlayComponent, {
verticalPosition: 'top',
});
@ -42,8 +40,7 @@ export class ErrorInterceptor implements HttpInterceptor {
} else if (err.status === 404) {
this.router.navigate(['/404']);
}
const error = err.error.message || err.statusText;
return throwError(error);
return throwError(err);
})
);
}

View file

@ -58,13 +58,15 @@ export class EmailBotCardComponent implements OnInit {
);
},
(error) => {
this.snackBar.open(
'Could not send e-mail to this address. Try again!',
'Close',
{
let errorMsg = 'Unknown error';
if (error.status === 409) {
errorMsg = 'E-Mail already in list.';
} else if (error.status === 502) {
errorMsg = 'Could not send e-mail to this address. Try again!';
}
this.snackBar.open(errorMsg, 'Close', {
duration: 2000,
}
);
});
}
);
}

View file

@ -196,6 +196,9 @@ async def email_subscribe(
token,
)
try:
subs = await EmailSubscribers.objects.filter(email=subscriber.email).all()
if subs:
raise HTTPException(status_code=status.HTTP_409_CONFLICT)
email.send_email(
subscriber.email,
"Subscribe to Kibicara " + hood.name,