-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9186 from QualitativeDataRepository/IQSS/9185-con…
…tact_email_updates IQSS/9185 contact email updates
- Loading branch information
Showing
14 changed files
with
332 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Contact Email Improvements | ||
|
||
Email sent from the contact forms to the contact(s) for a collection, dataset, or datafile can now optionally be cc'd to a support email address. The support email address can be changed from the default :SystemEmail address to a separate :SupportEmail address. When multiple contacts are listed, the system will now send one email to all contacts (with the optional cc if configured) instead of separate emails to each contact. Contact names with a comma that refer to Organizations will no longer have the name parts reversed in the email greeting. A new protected feedback API has been added. | ||
|
||
## Backward Incompatibilities | ||
|
||
When there are multiple contacts, the system will now send one email with all of the contacts in the To: header instead of sending one email to each contact (with no indication that others have been notified). | ||
|
||
## New JVM/MicroProfile Settings | ||
|
||
dataverse.mail.support-email - allows a separate email, distinct from the :SystemEmail to be used as the to address in emails from the contact form/ feedback api. | ||
dataverse.mail.cc-support-on-contact-emails - include the support email address as a CC: entry when contact/feedback emails are sent to the contacts for a collection, dataset, or datafile. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1618,6 +1618,8 @@ The fully expanded example above (without environment variables) looks like this | |
The people who need to review the dataset (often curators or journal editors) can check their notifications periodically via API to see if any new datasets have been submitted for review and need their attention. See the :ref:`Notifications` section for details. Alternatively, these curators can simply check their email or notifications to know when datasets have been submitted (or resubmitted) for review. | ||
|
||
.. _return-a-dataset: | ||
|
||
Return a Dataset to Author | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
|
@@ -1645,6 +1647,8 @@ The fully expanded example above (without environment variables) looks like this | |
The review process can sometimes resemble a tennis match, with the authors submitting and resubmitting the dataset over and over until the curators are satisfied. Each time the curators send a "reason for return" via API, that reason is persisted into the database, stored at the dataset version level. | ||
|
||
The :ref:`send-feedback` API call may be useful as a way to move the conversation to email. However, note that these emails go to contacts (versus authors) and there is no database record of the email contents. (:ref:`dataverse.mail.cc-support-on-contact-email` will send a copy of these emails to the support email address which would provide a record.) | ||
|
||
Link a Dataset | ||
~~~~~~~~~~~~~~ | ||
|
||
|
@@ -4497,3 +4501,29 @@ A curl example using allowing access to a dataset's metadata | |
Please see :ref:`dataverse.api.signature-secret` for the configuration option to add a shared secret, enabling extra | ||
security. | ||
.. _send-feedback: | ||
Send Feedback To Contact(s) | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
This API call allows sending an email to the contacts for a collection, dataset, or datafile or to the support email address when no object is specified. | ||
The call is protected by the normal /admin API protections (limited to localhost or requiring a separate key), but does not otherwise limit the sending of emails. | ||
Administrators should be sure only trusted applications have access to avoid the potential for spam. | ||
The call is a POST with a JSON object as input with four keys: | ||
- "targetId" - the id of the collection, dataset, or datafile. Persistent ids and collection aliases are not supported. (Optional) | ||
- "subject" - the email subject line | ||
- "body" - the email body to send | ||
- "fromEmail" - the email to list in the reply-to field. (Dataverse always sends mail from the system email, but does it "on behalf of" and with a reply-to for the specified user.) | ||
A curl example using an ``ID`` | ||
.. code-block:: bash | ||
export SERVER_URL=http://localhost | ||
export JSON='{"targetId":24, "subject":"Data Question", "body":"Please help me understand your data. Thank you!", "fromEmail":"[email protected]"}' | ||
curl -X POST -H 'Content-Type:application/json' -d "$JSON" $SERVER_URL/api/admin/feedback | ||
Note that this call could be useful in coordinating with dataset authors (assuming they are also contacts) as an alternative/addition to the functionality provided by :ref:`return-a-dataset`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,15 @@ | |
|
||
import edu.harvard.iq.dataverse.DataverseSession; | ||
import edu.harvard.iq.dataverse.DvObject; | ||
import edu.harvard.iq.dataverse.DvObjectServiceBean; | ||
import edu.harvard.iq.dataverse.MailServiceBean; | ||
import edu.harvard.iq.dataverse.SendFeedbackDialog; | ||
import edu.harvard.iq.dataverse.branding.BrandingUtil; | ||
import edu.harvard.iq.dataverse.feedback.Feedback; | ||
import edu.harvard.iq.dataverse.feedback.FeedbackUtil; | ||
import java.util.List; | ||
import edu.harvard.iq.dataverse.settings.JvmSettings; | ||
import edu.harvard.iq.dataverse.settings.SettingsServiceBean; | ||
import edu.harvard.iq.dataverse.util.MailUtil; | ||
|
||
import javax.ejb.EJB; | ||
import javax.json.Json; | ||
import javax.json.JsonArrayBuilder; | ||
|
@@ -17,34 +21,47 @@ | |
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.core.Response; | ||
import javax.ws.rs.core.Response.Status; | ||
|
||
@Path("admin/feedback") | ||
public class FeedbackApi extends AbstractApiBean { | ||
|
||
@EJB | ||
DvObjectServiceBean dvObjectSvc; | ||
|
||
@EJB MailServiceBean mailService; | ||
|
||
/** | ||
* This method mimics the contact form and sends an email to the contacts of the | ||
* specified Collection/Dataset/DataFile, optionally ccing the support email | ||
* address, or to the support email address when there is no target object. | ||
* | ||
* !!!!! This should not be moved outside the /admin path unless/until some form | ||
* of captcha or other spam-prevention mechanism is added. As is, it allows an | ||
* unauthenticated user (with access to the /admin api path) to send email from | ||
* anyone to any contacts in Dataverse. (It also does not do much to validate | ||
* user input (e.g. to strip potentially malicious html, etc.)!!!! | ||
**/ | ||
@POST | ||
public Response submitFeedback(JsonObject jsonObject) throws AddressException { | ||
JsonNumber jsonNumber = jsonObject.getJsonNumber("id"); | ||
DvObject recipient = null; | ||
JsonNumber jsonNumber = jsonObject.getJsonNumber("targetId"); | ||
DvObject feedbackTarget = null; | ||
if (jsonNumber != null) { | ||
recipient = dvObjectSvc.findDvObject(jsonNumber.longValue()); | ||
feedbackTarget = dvObjSvc.findDvObject(jsonNumber.longValue()); | ||
if(feedbackTarget==null) { | ||
return error(Status.BAD_REQUEST, "Feedback target object not found"); | ||
} | ||
} | ||
DataverseSession dataverseSession = null; | ||
String userMessage = jsonObject.getString("body"); | ||
String systemEmail = "[email protected]"; | ||
InternetAddress systemAddress = new InternetAddress(systemEmail); | ||
String systemEmail = JvmSettings.SUPPORT_EMAIL.lookupOptional().orElse(settingsSvc.getValueForKey(SettingsServiceBean.Key.SystemEmail)); | ||
InternetAddress systemAddress = MailUtil.parseSystemAddress(systemEmail); | ||
String userEmail = jsonObject.getString("fromEmail"); | ||
String messageSubject = jsonObject.getString("subject"); | ||
String baseUrl = systemConfig.getDataverseSiteUrl(); | ||
String installationBrandName = BrandingUtil.getInstallationBrandName(); | ||
String supportTeamName = BrandingUtil.getSupportTeamName(systemAddress); | ||
JsonArrayBuilder jab = Json.createArrayBuilder(); | ||
List<Feedback> feedbacks = FeedbackUtil.gatherFeedback(recipient, dataverseSession, messageSubject, userMessage, systemAddress, userEmail, baseUrl, installationBrandName, supportTeamName); | ||
feedbacks.forEach((feedback) -> { | ||
jab.add(feedback.toJsonObjectBuilder()); | ||
}); | ||
Feedback feedback = FeedbackUtil.gatherFeedback(feedbackTarget, dataverseSession, messageSubject, userMessage, systemAddress, userEmail, baseUrl, installationBrandName, supportTeamName, SendFeedbackDialog.ccSupport(feedbackTarget)); | ||
jab.add(feedback.toJsonObjectBuilder()); | ||
mailService.sendMail(feedback.getFromEmail(), feedback.getToEmail(), feedback.getCcEmail(), feedback.getSubject(), feedback.getBody()); | ||
return ok(jab); | ||
} | ||
} |
Oops, something went wrong.