2018-11-09 16:48:01 +01:00
|
|
|
import {Injectable} from '@angular/core';
|
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";
|
2021-03-01 17:05:37 +01:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2018-11-09 16:48:01 +01:00
|
|
|
|
2022-02-24 17:42:05 +01:00
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
2018-11-09 16:48:01 +01:00
|
|
|
export class EmailService {
|
|
|
|
|
2019-06-03 15:20:36 +02:00
|
|
|
constructor(private http:HttpClient) {
|
2018-11-09 16:48:01 +01:00
|
|
|
}
|
2021-03-01 17:05:37 +01:00
|
|
|
|
|
|
|
notifyManagers(pid: string, role: "manager" | "subscriber", email: Email) {
|
2024-09-05 11:59:25 +02:00
|
|
|
return this.http.post(properties.adminToolsAPIURL + 'notifyManagers/' + pid + '/' + role, email, CustomOptions.getAuthOptions())
|
2021-03-01 17:05:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
notifyNewManager(email: Email) {
|
2024-09-05 11:59:25 +02:00
|
|
|
return this.http.post(properties.adminToolsAPIURL + 'notifyNewManager', email, CustomOptions.getAuthOptions())
|
[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
|
|
|
}
|
|
|
|
|
|
|
|
sendEmail(properties: EnvProperties, email: Email) {
|
2024-09-05 11:59:25 +02:00
|
|
|
return this.http.post(properties.adminToolsAPIURL + "sendMail/", email, CustomOptions.registryOptions());
|
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;
|
2024-09-05 11:59:25 +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
|
|
|
}
|