-
Notifications
You must be signed in to change notification settings - Fork 2
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
Clot.reject image #222
Clot.reject image #222
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just a couple quick comments:
if (rejectImageRequest.getRejectionReason() != null) { | ||
int uploaderId = db.select(SITE_IMAGES.UPLOADER_ID) | ||
.from(SITE_IMAGES) | ||
.where(SITE_IMAGES.ID.eq(imageId)) | ||
.fetchOne(0, int.class); | ||
|
||
UsersRecord user = db.selectFrom(USERS).where(USERS.ID.eq(uploaderId)).fetchOne(); | ||
String userEmail = user.getEmail(); | ||
String userFullName = | ||
AuthDatabaseOperations.getFullName(user.into(Users.class)); | ||
emailer.sendRejectImageEmail(userEmail, userFullName, rejectImageRequest.getRejectionReason()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ I think we should send a rejection email regardless of if a reason was added just so to keep users updated - we could probably just add a default rejection message. Also, can we check if the reason is an empty string as well so we don't accidentally send no message?
Sorry if the API spec wasn't clear about this - that's totally my bad
</tbody> | ||
</table> | ||
</td> | ||
</tr>a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just a few questions/clarifications
private EmailAttachment() {} | ||
|
||
private static String getFileExtension(String base64Image) { | ||
// Expected Base64 format: "data:image/{extension};base64,{imageData}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just cleanup comments throughout, the code is generally understandable when there are good naming conventions
private static String getFileExtension(String base64Image) { | ||
// Expected Base64 format: "data:image/{extension};base64,{imageData}" | ||
|
||
if (base64Image == null || base64Image.length() < 10) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the encoding length is 11 will it still be valid? If this is based on legacy code that's fine, just wondering if there's other ways to check image validity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah this is based on the s3requester legacy code, unsure of the reason behind 10
try { | ||
// Temporarily writes the image to disk to decode | ||
mimeType = getFileExtension(data); | ||
System.out.println(mimeType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to print this out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops good catch
@@ -0,0 +1,392 @@ | |||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit long. It's good for now, since we want to send this out. Just a follow up on our conversation to create a ticket for making email customization easier down the line
String userFullName = | ||
AuthDatabaseOperations.getFullName(user.into(Users.class)); | ||
emailer.sendRejectImageEmail(userEmail, userFullName, rejectImageRequest.getRejectionReason()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to notify people that their image was rejected/deleted even if a reason isn't provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess yes (#222 (comment))
private final String subjectImageRejected = | ||
PropertiesLoader.loadProperty("email_subject_image_rejected"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to load the email subject this way, we'll want to add this to server.properties.example
- you can simply match what we do for the other email subjects.
When the backend gets deployed to AWS, it'll copy the property name and value into the server.properties
and be available here; if you're really interested you can take a look at deploy.py
for more details
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the info, good catch! Ill add it
This is out of scope for this ticket, but I think it'd be a good idea to attach the image that was rejected to the email so the user knows which of their images got rejected, once we finish implementing email attachments as well - this'll probably be another ticket. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, great work here!
Why
Resolves #219
This allows the admins to send rejection email to the users who uploaded inappropriate images.
This PR
We added a new email template "RejectImageEmail.html" to be used for image rejection email.
Verification Steps
Note that it will only send email when a rejection reason is given. When a reason is not given, it will delete the user image in database by using deleteSiteImage without sending the email.