2018-12-10 14:25:41 +01:00
import { Email } from "./email" ;
2018-12-18 13:23:14 +01:00
import { Body } from "./body" ;
2020-11-19 18:13:27 +01:00
import { properties } from "../../../../environments/environment" ;
2018-12-10 14:25:41 +01:00
export class Composer {
private static noteBodySize = "14px" ;
private static noteFontSize = "11px" ;
2018-12-19 14:26:41 +01:00
private static subjectPrefix = "[OpenAIRE-Connect] " ;
2020-03-19 10:10:42 +01:00
private static closing = "OpenAIRE team" ;
2018-12-18 13:23:14 +01:00
private static openaireAddress = "<a href='https://www.openaire.eu'>www.openaire.eu</a><br>" ;
2018-12-19 14:26:41 +01:00
private static signature = Composer . closing + "<br>" + Composer . openaireAddress ;
2018-12-10 14:25:41 +01:00
2020-05-08 17:01:59 +02:00
private static ifYouAreNotResponsible ( mail ) : string {
2018-12-12 14:30:07 +01:00
return "If you are not responsible for this community, please "
2021-03-01 17:05:37 +01:00
+ "<a href='mailto:" + mail + "'>contact us</a>. " ;
2018-12-10 14:25:41 +01:00
}
2018-12-12 14:03:12 +01:00
private static manageNotificationSettings ( communityId : string ) : string {
2021-03-01 17:05:37 +01:00
return "Click <a href='" + properties . adminPortalURL + "/" + communityId + "/users/notifications"
2018-12-12 14:30:07 +01:00
+ communityId + "'>here</a> to manage your notification settings. " ;
2018-12-10 14:25:41 +01:00
}
2018-12-12 14:03:12 +01:00
private static youAreManagerOfTheCommunity ( communityId : string , communityName : string ) : string {
2018-12-12 14:30:07 +01:00
return "You are receiving this e-mail as manager of the community "
2020-12-09 14:49:28 +01:00
+ "<a href='https://" + ( properties . environment == "production" ? '' : 'beta.' ) + communityId + ".openaire.eu/'>" + communityName + "</a>. " ;
2018-12-10 14:25:41 +01:00
}
2021-03-01 17:05:37 +01:00
public static composeEmailForNewManager ( communityId : string , communityName : string ) : Email {
2018-12-10 14:25:41 +01:00
let email : Email = new Email ( ) ;
2018-12-19 14:26:41 +01:00
email . subject = this . subjectPrefix + communityName + ": Welcome new manager" ;
2018-12-10 14:25:41 +01:00
email . body = "<div style='font-size:" + this . noteBodySize + "'><p>Welcome to OpenAIRE Connect!</p>"
2023-06-27 11:08:58 +02:00
+ "<p>You are receiving this e-mail as you were assigned as manager of the <a href='https://beta."
+ communityId + ".openaire.eu/'>" + communityName + "</a> gateway. "
2018-12-10 14:25:41 +01:00
+ "In order to access the administration section of your community you must first login using one of the available options. "
2023-06-27 11:08:58 +02:00
+ "<br>The administrative rights are associated with the e-mail address that was used to send you this message."
2018-12-10 14:25:41 +01:00
+ " If you login with an account associated to a different email, please <a href='mailto:helpdesk@openaire.eu'>contact us</a>"
+ " or your colleagues, that already have access to the administration tool, to update your e-mail. <br>"
2023-06-27 11:08:58 +02:00
+ "If you do not know which is the email associated with your OpenAIRE account, you can follow the instructions of <a href='https://youtu.be/Z3ePc4ltJ4M?t=30'>this video (from 00:30 to 1:00).</a><br>"
+ "Once logged in, you can access the administration tool by clicking the \"Manage\" button that will be available in the top right corner of the gateway."
2018-12-10 14:25:41 +01:00
+ "</p>"
2018-12-12 14:03:12 +01:00
+ this . signature
2021-03-01 17:05:37 +01:00
+ "<p style='font-size:" + this . noteFontSize + "'>" + this . ifYouAreNotResponsible ( properties . admins [ 0 ] ) + "<p>"
2018-12-10 14:25:41 +01:00
+ "</div>" ;
return email ;
}
2019-12-03 13:50:39 +01:00
public static composeEmailForNewCommunity ( contactForm : any , admins : any ) : Email {
2019-04-10 20:55:17 +02:00
let email : Email = new Email ( ) ;
2020-06-11 19:03:03 +02:00
2020-10-23 20:04:56 +02:00
email . subject = "OpenAIRE - Connect" ;
2019-04-12 10:52:31 +02:00
email . body = "<div style='font-size:" + this . noteBodySize + "'>"
+ "<span><b>Name</b>: " + contactForm . name + "</span><br>"
+ "<span><b>Surname</b>: " + contactForm . surname + "</span><br>"
+ "<span><b>Email</b>: " + contactForm . email + "</span><br>"
+ "<span><b>Affiliation</b>: " + contactForm . affiliation + "</span><br>"
+ "<span><b>Community Name</b>: " + contactForm . community + "</span>"
+ "<p>" + contactForm . message + "</p>"
+ "</div>" ;
2019-04-10 20:55:17 +02:00
email . recipients = admins ;
return email ;
}
2020-03-16 14:09:46 +01:00
2022-02-24 17:42:05 +01:00
public static composeEmailForMonitor ( contactForm : any , admins : string [ ] ) : Email {
2020-06-11 19:03:03 +02:00
let email : Email = new Email ( ) ;
2020-10-23 19:46:13 +02:00
email . subject = "OpenAIRE - Monitor" ;
2020-06-11 19:03:03 +02:00
email . body = "<div style='font-size:" + this . noteBodySize + "'>"
+ "<span><b>Name</b>: " + contactForm . name + "</span><br>"
+ "<span><b>Surname</b>: " + contactForm . surname + "</span><br>"
+ "<span><b>Email</b>: " + contactForm . email + "</span><br>"
2020-06-23 22:50:46 +02:00
+ "<span><b>Job Title</b>: " + contactForm . job + "</span><br>"
+ "<span><b>Organization</b>: " + contactForm . organization + " (" + contactForm . organizationType + " )</span>"
2020-06-11 19:03:03 +02:00
+ "<p>" + contactForm . message + "</p>"
+ "</div>" ;
email . recipients = admins ;
return email ;
}
2022-10-03 12:39:35 +02:00
public static composeEmailForExplore ( contactForm : any , admins : any ) : Email {
let email : Email = new Email ( ) ;
email . subject = "OpenAIRE - Explore [" + properties . environment . toUpperCase ( ) + "]" ;
email . body = "<div style='font-size:" + this . noteBodySize + "'>"
+ "<span><b>Name</b>: " + contactForm . name + "</span><br>"
+ "<span><b>Surname</b>: " + contactForm . surname + "</span><br>"
+ "<span><b>Email</b>: " + contactForm . email + "</span><br>"
2023-01-10 01:25:03 +01:00
+ "<span><b>Affiliation</b>: " + ( contactForm . affiliation ? contactForm . affiliation : '-' ) + "</span><br>"
2022-10-03 12:39:35 +02:00
+ "<p>" + contactForm . message + "</p>"
+ "</div>" ;
2023-06-07 13:22:14 +02:00
email . recipients = admins ;
2022-10-03 12:39:35 +02:00
return email ;
}
2020-09-14 17:08:34 +02:00
public static composeEmailForUsageCounts ( contactForm : any , admins : any ) : Email {
let email : Email = new Email ( ) ;
2020-10-23 19:46:13 +02:00
email . subject = "OpenAIRE - UsageCounts" ;
2020-09-14 17:08:34 +02:00
email . body = "<div style='font-size:" + this . noteBodySize + "'>"
+ "<span><b>Name</b>: " + contactForm . name + "</span><br>"
+ "<span><b>Email</b>: " + contactForm . email + "</span><br>"
2020-10-09 18:36:09 +02:00
+ "<span><b>Affiliation</b>: " + contactForm . affiliation + "</span><br>"
+ "<span><b>Organization</b>: " + contactForm . organization + "</span>"
+ "<p>" + contactForm . description + "</p>"
+ "</div>" ;
email . recipients = admins ;
return email ;
}
public static composeEmailForGraph ( contactForm : any , admins : any ) : Email {
let email : Email = new Email ( ) ;
2020-10-23 20:04:56 +02:00
email . subject = "OpenAIRE - Research Graph" ;
2020-10-09 18:36:09 +02:00
email . body = "<div style='font-size:" + this . noteBodySize + "'>"
+ "<span><b>Name</b>: " + contactForm . name + "</span><br>"
+ "<span><b>Email</b>: " + contactForm . email + "</span><br>"
2020-09-14 17:08:34 +02:00
+ "<span><b>Affiliation</b>: " + contactForm . affiliation + "</span><br>"
+ "<span><b>Organization</b>: " + contactForm . organization + "</span>"
+ "<p>" + contactForm . description + "</p>"
+ "</div>" ;
email . recipients = admins ;
return email ;
}
2020-03-19 13:26:55 +01:00
public static composeEmailForFeedback ( info : { name : string , url : string , email : string , issues : any [ ] } , recipients : string [ ] ) : Email {
2020-03-19 10:10:42 +01:00
let email : Email = new Email ( ) ;
email . subject = 'Feedback report for ' + info . name ;
email . body = "<div style='font-size:" + this . noteBodySize + "'>"
+ "<p>A user" + ( ( info . email ) ? ( " with email " + info . email ) : "" ) + " has reported the following issue(s) for "
+ "<a href=\'" + info . url + "\'>" + info . name + "</a></p><ul>" ;
info . issues . forEach ( ( issue , index ) = > {
email . body += "<br><li><span><b><u>" + issue . field + "</u>: </b></span>" + issue . report + "</li>" ;
} ) ;
email . body += "</ul></div>" ;
email . recipients = recipients ;
return email ;
}
2023-02-17 18:08:44 +01:00
2023-02-18 09:52:24 +01:00
public static composeEmailForSdgsSuggestion ( info : { name : string , url : string , email : string , subjects : any [ ] } , recipients : string [ ] , subjectType : "sdg" | "fos" ) : Email {
let typeName : string = "" ;
if ( subjectType == "sdg" ) {
typeName = "Sustainable Development Goals (SDGs)" ;
} else {
2023-02-20 19:54:26 +01:00
typeName = "Fields of Science (FoS)" ;
2023-02-18 09:52:24 +01:00
}
2023-02-17 18:08:44 +01:00
let email : Email = new Email ( ) ;
email . subject = 'Feedback report for ' + info . name ;
email . body = "<div style='font-size:" + this . noteBodySize + "'>"
2023-02-18 09:52:24 +01:00
+ "<p>A user" + ( ( info . email ) ? ( " with email " + info . email ) : "" ) + " has reported the following " + typeName + " for "
2023-02-17 18:08:44 +01:00
+ "<a href=\'" + info . url + "\'>" + info . name + "</a></p><ul>" ;
2023-02-18 09:52:24 +01:00
if ( info . subjects && info . subjects . length > 0 ) {
info . subjects . forEach ( ( subject , index ) = > {
email . body += "<br><li><span><b>" + subject + "</b></span></li>" ;
} ) ;
} else {
email . body += "<br><b>No " + typeName + " selected</b>" ;
}
2023-02-17 18:08:44 +01:00
email . body += "</ul></div>" ;
email . recipients = recipients ;
return email ;
}
2020-03-16 14:09:46 +01:00
2020-03-19 13:26:55 +01:00
public static composeEmailForUserAfterFeedback ( recipients : string [ ] ) : Email {
let email : Email = new Email ( ) ;
email . subject = 'Feedback report received' ;
email . body = "<div style='font-size:" + this . noteBodySize + "'>"
+ "<p>This is an automated message to let you know that your feedback has been successfully received. Our graph experts will get back to you as soon as possible.</p><br>"
+ "Thank you for contacting OpenAIRE."
+ "</div>" ;
email . recipients = recipients ;
return email ;
}
2021-03-01 17:05:37 +01:00
public static composeEmailToInformOldManagersForTheNewOnes ( communityName : string , communityId : string ) : Email {
2018-12-12 14:03:12 +01:00
let email : Email = new Email ( ) ;
2018-12-10 14:25:41 +01:00
2018-12-19 14:26:41 +01:00
email . subject = this . subjectPrefix + communityName + ": Managers list notification" ;
2018-12-12 14:03:12 +01:00
email . body = "<div style='font-size:" + this . noteBodySize + "'>"
2018-12-10 14:25:41 +01:00
+ "<p>There are updates in the managers list for \"" + communityName + "\" community.<br>"
2021-03-01 17:05:37 +01:00
+ "The list of managers is: ((__managers__))</p>"
2018-12-12 14:03:12 +01:00
+ this . signature
+ "<p style='font-size:" + this . noteFontSize + "'>"
+ this . youAreManagerOfTheCommunity ( communityId , communityName )
2021-03-01 17:05:37 +01:00
+ this . ifYouAreNotResponsible ( properties . admins [ 0 ] )
2018-12-10 14:25:41 +01:00
+ "<br>"
2018-12-12 14:03:12 +01:00
+ this . manageNotificationSettings ( communityId )
+ "</p>"
2018-12-10 14:25:41 +01:00
+ "</div>" ;
return email ;
}
2018-12-13 12:38:29 +01:00
2021-03-01 17:05:37 +01:00
public static composeEmailToInformManagers ( communityName : string , communityId : string , subscriberName : string ) : Email {
2018-12-13 12:38:29 +01:00
let email : Email = new Email ( ) ;
2022-09-26 16:24:39 +02:00
email . subject = this . subjectPrefix + communityName + ": New Member notification" ;
2018-12-13 12:38:29 +01:00
email . body = "<div style='font-size" + this . noteBodySize + "'>"
2022-09-26 16:24:39 +02:00
+ "<p>There is a new member (" + subscriberName + ") for \"" + communityName + "\" community. Click "
2022-09-26 16:22:32 +02:00
+ "<a href='" + properties . adminPortalURL + "/" + communityId + "/users/member"
2022-09-26 16:24:39 +02:00
+ "'>here</a> to manage the members list. </p>"
2018-12-13 12:38:29 +01:00
+ this . signature
+ "<p style='font-size:" + this . noteFontSize + "'>"
+ this . youAreManagerOfTheCommunity ( communityId , communityName )
+ "<br>"
+ this . manageNotificationSettings ( communityId )
+ "</p>"
+ "</div>" ;
return email ;
}
2018-12-18 13:23:14 +01:00
2023-07-05 10:41:42 +02:00
public static composeEmailToReportCachingProcess ( report : any ) {
2023-06-07 13:22:14 +02:00
let email : Email = new Email ( ) ;
email . recipients = [ report . creator ] ;
email . subject = 'OpenAIRE | Monitor Dashboard - ' + report . name + '\'s caching process has been finished' ;
email . body = "<div style='font-size" + this . noteBodySize + "'>"
+ "<p>"
+ "<div>Success: " + report . success + "/" + report . total + "</div>"
+ "<div>Errors: " + report . errors . map ( error = > error . url + ' - ' + error . status ) . join ( '<br>' ) + "</div>"
+ "</p>"
+ "</div>" ;
return email ;
}
2018-12-18 13:23:14 +01:00
public static formatEmailBodyForInvitation ( body : Body ) : string {
let fromMessageAndName = "" ;
if ( body . fromName != "" ) {
fromMessageAndName = "<span>" + body . fromMessage + body . fromName + "</span>" ;
}
let formattedEmail = "<div style='font-size:" + this . noteBodySize + "'>"
+ body . paragraphs
+ "<p>" + body . signature + fromMessageAndName + "<br>"
+ this . openaireAddress
+ "</p>"
+ "</div>" ;
return formattedEmail ;
}
2020-05-08 13:10:40 +02:00
// TODO remove this after adding this on admin
2018-12-19 14:26:41 +01:00
public static initializeInvitationsBody ( communityId : string , communityTitle : string , fullname : string ) : Body {
2022-06-28 20:13:40 +02:00
let defaultMainBody = '<p>You are invited to join <a href="https://' + ( properties . environment == "production" ? '' : 'beta.' ) + communityId + '.openaire.eu/">'
2021-01-15 14:35:32 +01:00
+ communityTitle + '</a> dashboard.<br>' ;
2020-05-08 13:10:40 +02:00
if ( communityId !== 'covid-19' ) {
2021-01-15 14:35:32 +01:00
defaultMainBody += 'The purpose of this dashboard is to gather, link & monitor the research results related to your community.</p>'
2020-05-08 13:10:40 +02:00
+ '<p>The community dashboard is part of the <a href="https://connect.openaire.eu/">OpenAIRE-Connect</a> '
2020-12-09 14:49:28 +01:00
+ 'project.'
2020-05-08 13:10:40 +02:00
+ '</p>' ;
} else {
2021-01-15 14:35:32 +01:00
defaultMainBody += 'This is a dashboard that gathers, links & monitors research results related COVID-19 (multi-disciplinary) from authoritative OA sources around the world. ' +
2020-05-08 13:10:40 +02:00
'We have a community of experts moderating and curating the content.</p> ' +
'<p>What you can do:</p>' +
'<ul>' +
'<li>navigate in a linked open data space, a contextual discovery</li>' +
'<li>automatically deposit in Zenodo designated communities</li>' +
'<li>link research results among themselves and to projects</li>' +
'<li>join the team of experts to curate/moderate the traffic, mining, links to the data</li>' +
'</ul> ' +
'<p>The community dashboard is part of the<a href="https://connect.openaire.eu/"> OpenAIRE-Connect</a> project.</p>'
}
2018-12-19 14:26:41 +01:00
2022-06-28 20:13:40 +02:00
return { fromMessage : ", on behalf of " , fromName : fullname , paragraphs : defaultMainBody , signature : this.closing , note : "" } ;
2018-12-18 13:58:46 +01:00
}
2018-12-19 14:26:41 +01:00
public static initializeInvitationsEmail ( communityTitle : string ) {
let email : Email = new Email ( ) ;
2022-06-28 20:13:40 +02:00
return { body : "" , subject : this.subjectPrefix + communityTitle , recipients : [ ] } ;
2018-12-19 14:26:41 +01:00
}
2020-11-19 18:13:27 +01:00
public static composeEmailForMonitorDashboard ( name : string , recipient : string , role : "manager" | "member" ) {
let email : Email = new Email ( ) ;
email . subject = 'OpenAIRE Monitor Dashboard | ' + name ;
2021-02-12 12:31:12 +01:00
email . body = this . composeMessageForMonitorDashboard ( name , role ) ;
email . recipient = recipient ;
return email ;
}
public static composeMessageForMonitorDashboard ( name : string , role : "manager" | "member" , user : string = null , invitation : any = null ) {
2022-06-09 09:38:06 +02:00
let pdppLink = 'http://catalogue.openaire.eu/files/Personal%20Data%20Protection%20Policy%20for%20OpenAIRE%20Services%20April%202022.pdf' ;
2021-02-12 12:31:12 +01:00
let message = '<p>Dear ((__user__)),</p>' +
2020-11-19 18:13:27 +01:00
'<p>You have been invited to be a ' + role + ' of the OpenAIRE Monitor Dashboard for the ' + name + '.</p>' +
2021-02-12 12:31:12 +01:00
'<p>Click <a href="((__link__))" target="_blank">this URL</a> and use the verification code below to accept the invitation.</p>' +
2020-11-19 18:13:27 +01:00
'<p>The verification code is <b>((__code__))</b>.</p>' +
2022-06-09 09:38:06 +02:00
'<p>By logging in and using the service you accept and agree to the <a href="' + pdppLink + '" target="_blank">OpenAIRE personal data protection policy</a>.</p>' +
2020-11-19 18:13:27 +01:00
( role === "manager" ?
2021-02-12 12:31:12 +01:00
'<p>As a manager of the OpenAIRE Monitor Dashboard, you will have access to the administration part of the dashboard, ' +
'where you will be able to customize and manage the profile of the ' + name + '.</p>' :
'<p>As a member of the OpenAIRE Monitor Dashboard, you will have access to the restricted access areas of the profile for the ' + name + '.' ) +
2020-11-19 18:13:27 +01:00
'<p>Please contact us at <a href="mailto:' + properties . helpdeskEmail + '">' + properties . helpdeskEmail +
'</a> if you have any questions or concerns.</p>' +
'<p>Kind Regards<br>The OpenAIRE Team</p>' +
2021-02-12 12:31:12 +01:00
'<p><a href="' + properties . domain + '" target="_blank">OpenAIRE Monitor</a></p>' ;
if ( user ) {
message = message . replace ( '((__user__))' , user ) ;
}
if ( invitation ) {
message = message . replace ( '((__link__))' , invitation . link ) . replace ( '((__code__))' , invitation . code ) ;
}
return message ;
2020-11-19 18:13:27 +01:00
}
2021-01-21 16:15:53 +01:00
2021-03-02 11:08:19 +01:00
public static composeEmailForCommunityDashboard ( name : string , recipient : string ) {
2021-01-21 16:15:53 +01:00
let email : Email = new Email ( ) ;
2021-05-17 17:32:06 +02:00
email . subject = 'OpenAIRE Connect | ' + name ;
2021-03-02 11:08:19 +01:00
email . body = this . composeMessageForCommunityDashboard ( name ) ;
2021-02-12 12:31:12 +01:00
email . recipient = recipient ;
return email ;
}
2021-03-02 11:08:19 +01:00
public static composeMessageForCommunityDashboard ( name : string , user : string = null , invitation : any = null ) {
2021-02-12 12:31:12 +01:00
let message = '<p>Dear ((__user__)),</p>' +
2021-03-02 11:08:19 +01:00
'<p>You have been invited to be a manager of the OpenAIRE Research Community Dashboard for the ' + name + '.</p>' +
2021-02-12 12:31:12 +01:00
'<p>Click <a href="((__link__))" target="_blank">this URL</a> and use the verification code below to accept the invitation.</p>' +
2021-01-21 16:15:53 +01:00
'<p>The verification code is <b>((__code__))</b>.</p>' +
2021-03-02 11:08:19 +01:00
'<p>As a manager of the OpenAIRE Research Community Dashboard, you will have access to the administration part of the dashboard, ' +
'where you will be able to customize and manage the content of the ' + name + '.</p>' +
2021-01-21 16:15:53 +01:00
'<p>Please contact us at <a href="mailto:' + properties . helpdeskEmail + '">' + properties . helpdeskEmail +
'</a> if you have any questions or concerns.</p>' +
'<p>Kind Regards<br>The OpenAIRE Team</p>' +
2021-05-17 17:32:06 +02:00
'<p><a href="https://' + ( properties . environment == "production" ? '' : 'beta.' ) + 'connect.openaire.eu/" target="_blank">OpenAIRE Connect</a></p>' ;
2021-02-12 12:31:12 +01:00
if ( user ) {
message = message . replace ( '((__user__))' , user ) ;
}
if ( invitation ) {
message = message . replace ( '((__link__))' , invitation . link ) . replace ( '((__code__))' , invitation . code ) ;
}
return message ;
2021-01-21 16:15:53 +01:00
}
2018-12-10 14:25:41 +01:00
}