2018-11-09 16:48:01 +01:00
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {Http, Response, Headers, RequestOptions} from '@angular/http';
|
2019-06-03 15:20:36 +02:00
|
|
|
import {HttpClient} from "@angular/common/http";
|
2018-11-09 16:48:01 +01:00
|
|
|
import {Email} from './email';
|
2018-11-14 12:20:26 +01:00
|
|
|
import {CustomOptions} from '../../services/servicesUtils/customOptions.class';
|
2019-04-11 13:26:02 +02:00
|
|
|
import {EmailRecaptcha} from "../entities/EmailRecaptcha";
|
2020-03-19 10:10:42 +01:00
|
|
|
import {Observable} from "rxjs";
|
[Trunk | Library]:
1. community.service.ts: Mark unused method "isSubscribedToCommunity()" as "deprecated" (This service calls community API - made in Italy, not uoa-admin-tools - made in Greece).
2. connectSubscriber.guard.ts: Call "isSubscribedToCommunity()" method from "subscribe.service.ts" (not "community.service.ts").
3. curator.service.ts: getCurators(properties: EnvProperties, url: string) --> getCurators(properties: EnvProperties, emails: string): Build path for request in service.
4. email.service.ts: Build request path in service
a. sendEmail(url: string, email: Email) --> sendEmail(properties: EnvProperties, email: Email)
b. contact(url: string, email: Email, recaptcha: string = null) --> contact(properties: EnvProperties, email: Email, recaptcha: string = null)
c. Create method "notifyForNewManagers(properties: EnvProperties, communityId: string, email: Email)" (sendEmail was used for everything).
5. subscribe.service.ts:
a. subscribeToCommunity(pid: string, email: string, url: string) --> subscribeToCommunity(properties: EnvProperties, pid: string, email: string)
b. unSubscribeToCommunity(pid: string, email: string, url: string) --> unSubscribeToCommunity(properties: EnvProperties, pid: string, email: string)
6. layout.service.ts: getLayout(communityId: string, url: string) --> getLayout(properties: EnvProperties, communityId: string): Build path for request in service.
7. feedback.component.ts: In method "contact" from "emailService", build request path in service.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58420 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-07 16:57:26 +02:00
|
|
|
import {EnvProperties} from "../properties/env-properties";
|
2018-11-09 16:48:01 +01:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class EmailService {
|
|
|
|
|
2019-06-03 15:20:36 +02:00
|
|
|
constructor(private http:HttpClient) {
|
2018-11-09 16:48:01 +01:00
|
|
|
}
|
|
|
|
|
2020-04-08 13:25:41 +02:00
|
|
|
notifyForNewManagers(properties: EnvProperties, pid: string, email: Email) {
|
[Trunk | Library]:
1. community.service.ts: Mark unused method "isSubscribedToCommunity()" as "deprecated" (This service calls community API - made in Italy, not uoa-admin-tools - made in Greece).
2. connectSubscriber.guard.ts: Call "isSubscribedToCommunity()" method from "subscribe.service.ts" (not "community.service.ts").
3. curator.service.ts: getCurators(properties: EnvProperties, url: string) --> getCurators(properties: EnvProperties, emails: string): Build path for request in service.
4. email.service.ts: Build request path in service
a. sendEmail(url: string, email: Email) --> sendEmail(properties: EnvProperties, email: Email)
b. contact(url: string, email: Email, recaptcha: string = null) --> contact(properties: EnvProperties, email: Email, recaptcha: string = null)
c. Create method "notifyForNewManagers(properties: EnvProperties, communityId: string, email: Email)" (sendEmail was used for everything).
5. subscribe.service.ts:
a. subscribeToCommunity(pid: string, email: string, url: string) --> subscribeToCommunity(properties: EnvProperties, pid: string, email: string)
b. unSubscribeToCommunity(pid: string, email: string, url: string) --> unSubscribeToCommunity(properties: EnvProperties, pid: string, email: string)
6. layout.service.ts: getLayout(communityId: string, url: string) --> getLayout(properties: EnvProperties, communityId: string): Build path for request in service.
7. feedback.component.ts: In method "contact" from "emailService", build request path in service.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58420 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-07 16:57:26 +02:00
|
|
|
let body = JSON.stringify(email);
|
|
|
|
|
2020-04-08 13:25:41 +02:00
|
|
|
return this.http.post(properties.adminToolsAPIURL + "/notifyForNewSubscribers/" + pid, body, CustomOptions.getAuthOptionsWithBody());
|
[Trunk | Library]:
1. community.service.ts: Mark unused method "isSubscribedToCommunity()" as "deprecated" (This service calls community API - made in Italy, not uoa-admin-tools - made in Greece).
2. connectSubscriber.guard.ts: Call "isSubscribedToCommunity()" method from "subscribe.service.ts" (not "community.service.ts").
3. curator.service.ts: getCurators(properties: EnvProperties, url: string) --> getCurators(properties: EnvProperties, emails: string): Build path for request in service.
4. email.service.ts: Build request path in service
a. sendEmail(url: string, email: Email) --> sendEmail(properties: EnvProperties, email: Email)
b. contact(url: string, email: Email, recaptcha: string = null) --> contact(properties: EnvProperties, email: Email, recaptcha: string = null)
c. Create method "notifyForNewManagers(properties: EnvProperties, communityId: string, email: Email)" (sendEmail was used for everything).
5. subscribe.service.ts:
a. subscribeToCommunity(pid: string, email: string, url: string) --> subscribeToCommunity(properties: EnvProperties, pid: string, email: string)
b. unSubscribeToCommunity(pid: string, email: string, url: string) --> unSubscribeToCommunity(properties: EnvProperties, pid: string, email: string)
6. layout.service.ts: getLayout(communityId: string, url: string) --> getLayout(properties: EnvProperties, communityId: string): Build path for request in service.
7. feedback.component.ts: In method "contact" from "emailService", build request path in service.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58420 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-07 16:57:26 +02:00
|
|
|
//.map(request => request.json());
|
|
|
|
}
|
|
|
|
|
|
|
|
sendEmail(properties: EnvProperties, email: Email) {
|
2018-11-09 16:48:01 +01:00
|
|
|
let body = JSON.stringify(email);
|
|
|
|
|
[Trunk | Library]:
1. community.service.ts: Mark unused method "isSubscribedToCommunity()" as "deprecated" (This service calls community API - made in Italy, not uoa-admin-tools - made in Greece).
2. connectSubscriber.guard.ts: Call "isSubscribedToCommunity()" method from "subscribe.service.ts" (not "community.service.ts").
3. curator.service.ts: getCurators(properties: EnvProperties, url: string) --> getCurators(properties: EnvProperties, emails: string): Build path for request in service.
4. email.service.ts: Build request path in service
a. sendEmail(url: string, email: Email) --> sendEmail(properties: EnvProperties, email: Email)
b. contact(url: string, email: Email, recaptcha: string = null) --> contact(properties: EnvProperties, email: Email, recaptcha: string = null)
c. Create method "notifyForNewManagers(properties: EnvProperties, communityId: string, email: Email)" (sendEmail was used for everything).
5. subscribe.service.ts:
a. subscribeToCommunity(pid: string, email: string, url: string) --> subscribeToCommunity(properties: EnvProperties, pid: string, email: string)
b. unSubscribeToCommunity(pid: string, email: string, url: string) --> unSubscribeToCommunity(properties: EnvProperties, pid: string, email: string)
6. layout.service.ts: getLayout(communityId: string, url: string) --> getLayout(properties: EnvProperties, communityId: string): Build path for request in service.
7. feedback.component.ts: In method "contact" from "emailService", build request path in service.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58420 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-07 16:57:26 +02:00
|
|
|
return this.http.post(properties.adminToolsAPIURL + "/sendMail/", body, CustomOptions.getAuthOptionsWithBody());
|
2019-06-03 15:20:36 +02:00
|
|
|
//.map(request => request.json());
|
2018-11-09 16:48:01 +01:00
|
|
|
}
|
|
|
|
|
[Trunk | Library]:
1. community.service.ts: Mark unused method "isSubscribedToCommunity()" as "deprecated" (This service calls community API - made in Italy, not uoa-admin-tools - made in Greece).
2. connectSubscriber.guard.ts: Call "isSubscribedToCommunity()" method from "subscribe.service.ts" (not "community.service.ts").
3. curator.service.ts: getCurators(properties: EnvProperties, url: string) --> getCurators(properties: EnvProperties, emails: string): Build path for request in service.
4. email.service.ts: Build request path in service
a. sendEmail(url: string, email: Email) --> sendEmail(properties: EnvProperties, email: Email)
b. contact(url: string, email: Email, recaptcha: string = null) --> contact(properties: EnvProperties, email: Email, recaptcha: string = null)
c. Create method "notifyForNewManagers(properties: EnvProperties, communityId: string, email: Email)" (sendEmail was used for everything).
5. subscribe.service.ts:
a. subscribeToCommunity(pid: string, email: string, url: string) --> subscribeToCommunity(properties: EnvProperties, pid: string, email: string)
b. unSubscribeToCommunity(pid: string, email: string, url: string) --> unSubscribeToCommunity(properties: EnvProperties, pid: string, email: string)
6. layout.service.ts: getLayout(communityId: string, url: string) --> getLayout(properties: EnvProperties, communityId: string): Build path for request in service.
7. feedback.component.ts: In method "contact" from "emailService", build request path in service.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58420 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-07 16:57:26 +02:00
|
|
|
contact(properties: EnvProperties, email: Email, recaptcha: string = null):Observable<boolean> {
|
2019-04-11 13:26:02 +02:00
|
|
|
const data: EmailRecaptcha = new EmailRecaptcha();
|
|
|
|
data.email = email;
|
|
|
|
data.recaptcha = recaptcha;
|
[Trunk | Library]:
1. community.service.ts: Mark unused method "isSubscribedToCommunity()" as "deprecated" (This service calls community API - made in Italy, not uoa-admin-tools - made in Greece).
2. connectSubscriber.guard.ts: Call "isSubscribedToCommunity()" method from "subscribe.service.ts" (not "community.service.ts").
3. curator.service.ts: getCurators(properties: EnvProperties, url: string) --> getCurators(properties: EnvProperties, emails: string): Build path for request in service.
4. email.service.ts: Build request path in service
a. sendEmail(url: string, email: Email) --> sendEmail(properties: EnvProperties, email: Email)
b. contact(url: string, email: Email, recaptcha: string = null) --> contact(properties: EnvProperties, email: Email, recaptcha: string = null)
c. Create method "notifyForNewManagers(properties: EnvProperties, communityId: string, email: Email)" (sendEmail was used for everything).
5. subscribe.service.ts:
a. subscribeToCommunity(pid: string, email: string, url: string) --> subscribeToCommunity(properties: EnvProperties, pid: string, email: string)
b. unSubscribeToCommunity(pid: string, email: string, url: string) --> unSubscribeToCommunity(properties: EnvProperties, pid: string, email: string)
6. layout.service.ts: getLayout(communityId: string, url: string) --> getLayout(properties: EnvProperties, communityId: string): Build path for request in service.
7. feedback.component.ts: In method "contact" from "emailService", build request path in service.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58420 d315682c-612b-4755-9ff5-7f18f6832af3
2020-04-07 16:57:26 +02:00
|
|
|
return this.http.post<boolean>(properties.adminToolsAPIURL + '/contact', data);
|
2019-04-11 13:26:02 +02:00
|
|
|
}
|
|
|
|
|
2018-11-09 16:48:01 +01:00
|
|
|
}
|