Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBPIH-5822 email alert to requestor approvals email alerts #4299

Merged

Conversation

drodzewicz
Copy link
Collaborator

No description provided.

Comment getRecentComment() {
return comments?.sort({ a, b ->
b.dateCreated <=> a.dateCreated
}).find()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't .first() fit better here?
I believe find() should take some closure as an argument? I'm surprised that it works without anything

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?.first() even with null-safety operator throwns an exception.
I came across this stack post which suggests using find().
When calling find without any arguments it acts the same way as .find(true) which will resolve at first iteration

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drodzewicz I think you still need to have here a null-safety operator with find() too.

@@ -691,6 +691,8 @@ email.contactAdmin.message=Please contact your local OpenBoxes administrator wit
email.contactAdminReceiving.message=Please contact the receiver listed above or your local OpenBoxes administrator with any questions you have about the status of this item. If you see a quantity in the cancelled column, this means that the warehouse received fewer items than expected, possibly as a result of a data error or a loss during shipment. The receiver can explain the situation. If you have an OpenBoxes account, you can view the shipment via
email.thisLink.label=this link
email.requestReceived.message=You have received a new request from: {0}, created by: {1}. Click <a href="{2}">here</a> to review your requests pending your approval.
email.statusChange.message=Your request status has been updated to: {0}. Click <a href="{1}">here</a> to review your requests.
email.withComment.message=With comment:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know @jmiranda was not a big fan or adding some : or commas in the message itself, but I'm fine with that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a point, this should probably not be in the message label

</div>
<div>
<g:message code="email.withComment.message" />
<g:set var="comment" value="${requisition.recentComment}" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i assume we can't run into a NullPointerException here, because it would not be rendered if we don't have requisitoin?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

Comment on lines 248 to 252
if (requisition.status == RequisitionStatus.PENDING_APPROVAL) {
List<Person> recipients = resolveNotificationRecipients(requisition)
publishRequisitionPendingApprovalNotifications(requisition, recipients)
} else if (requisition.status in [RequisitionStatus.APPROVED, RequisitionStatus.REJECTED]) {
publishRequisitionStatusUpdateNotifications(requisition, requisition.requestedBy)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a big fan of using else, maybe this approach would be cleaner:

void publishRequisitionStatusTransitionNotifications(Requisition requisition) {
        if (requisition.status == RequisitionStatus.PENDING_APPROVAL) {
            List<Person> recipients = resolveNotificationRecipients(requisition)
            publishRequisitionPendingApprovalNotifications(requisition, recipients)
            return
        }

        if (requisition.status in [RequisitionStatus.APPROVED, RequisitionStatus.REJECTED]) {
            publishRequisitionStatusUpdateNotifications(requisition, requisition.requestedBy)
        }
    }

but I have nothing against leaving it as is

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead I went with an approach of switch/case

@drodzewicz drodzewicz force-pushed the OBPIH-5822-email-alert-to-requestor-approvals-email-alerts branch from 8e79d2a to f3a8f2d Compare September 27, 2023 13:04
Comment getRecentComment() {
return comments?.sort({ a, b ->
b.dateCreated <=> a.dateCreated
}).find()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@drodzewicz I think you still need to have here a null-safety operator with find() too.

@drodzewicz drodzewicz force-pushed the OBPIH-5822-email-alert-to-requestor-approvals-email-alerts branch from f3a8f2d to 6c57dcf Compare September 27, 2023 13:49
@drodzewicz drodzewicz force-pushed the OBPIH-5822-email-alert-to-requestor-approvals-email-alerts branch from 6c57dcf to 264d486 Compare September 28, 2023 13:05
@awalkowiak awalkowiak merged commit 365fc3a into develop Sep 29, 2023
3 checks passed
@awalkowiak awalkowiak deleted the OBPIH-5822-email-alert-to-requestor-approvals-email-alerts branch September 29, 2023 15:00
awalkowiak pushed a commit that referenced this pull request Oct 26, 2023
* OBPIH-5822 Added notificatin to requestor on request status change

* OBPIH-5822 Add recent comment to the status update mail notification

* OBPIH-5822 use find{true} instead of find() to get first element of a list

* OBPIH-5822 Change requisition id to identifier of success message on approve/reject request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants