diff --git a/src/app/pages/community/community-edit-form/community-edit-form.component.ts b/src/app/pages/community/community-edit-form/community-edit-form.component.ts index aacf613..5f4f39b 100644 --- a/src/app/pages/community/community-edit-form/community-edit-form.component.ts +++ b/src/app/pages/community/community-edit-form/community-edit-form.component.ts @@ -46,6 +46,8 @@ export class CommunityEditFormComponent implements OnInit{ public email: Email; + public emailToInform: Email; + public properties:EnvProperties = null; constructor (private route: ActivatedRoute, @@ -65,6 +67,7 @@ export class CommunityEditFormComponent implements OnInit{ this.communityId = communityId['communityId']; this.email = {body: "", subject: "", recipients: []}; + this.emailToInform = {body: "", subject: "", recipients: []}; if(!Session.isLoggedIn()){ console.info(this._router.url); @@ -155,6 +158,8 @@ export class CommunityEditFormComponent implements OnInit{ console.log("New managers in component: " + newManagers); if (newManagers !== null) { this.sendMailToNewManagers(newManagers); + console.log("Old managers in component: " + this.firstVersionOfManagers); + this.informOldManagersForTheNewOnes(this.firstVersionOfManagers); for (let i = 0; i < newManagers.length; i++) { console.log(newManagers[i]); this._subscribeService.subscribeToCommunity(this.communityId, newManagers[i], this.properties.adminToolsAPIURL).subscribe( @@ -222,11 +227,15 @@ export class CommunityEditFormComponent implements OnInit{ }, error => console.log(error) ); - // console.log("Stelnei mail"); } private informOldManagersForTheNewOnes(managers: any) { - + this._emailService.sendEmail("http://scoobydoo.di.uoa.gr:8080/uoa-admin-tools/notifyForNewManagers/"+ this.communityId, this.composeEmailToInformOldManagersForTheNewOnes(this.community.title, this.communityId, this.firstVersionOfManagers)).subscribe( + res => { + console.log("The email has been sent successfully!") + }, + error => console.log(error) + ); } // TODO find the right place to write it @@ -243,8 +252,15 @@ export class CommunityEditFormComponent implements OnInit{ } // TODO find the right place to write it - private composeEmailToInformOldManagersForTheNewOnes() { + private composeEmailToInformOldManagersForTheNewOnes(communityName: string, communityId: string, firstVersionOfManagers: any) : Email { + this.emailToInform.subject = "[OpenAIRE-Connect]" + communityName + ": New subscriber notification"; + this.emailToInform.body = "

There is a new subscriber for " + communityName + + "community. Click here to manage the subscibers list.



" + + "OpenAIRE team
"+ "www.openaire.eu"; + this.emailToInform.recipients = firstVersionOfManagers; + return this.emailToInform; } private subscribeNewManagers(newManagers: string[]): boolean {