Uploaded image for project: 'Jira Service Management Data Center'
  1. Jira Service Management Data Center
  2. JSDSERVER-10992

Pasting different screenshot in Email creates an issue with duplicate image in description

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Low
    • None
    • 4.20.2
    • Email - Incoming
    • None

    Description

      Issue Summary

      Duplicating screenshots in the issue description

      Steps to Reproduce

      1. Configure Email Request for any Service Desk Project from the [Choose a request type for email requests]
      2. Have it checked under JSD->Email Requests as shown below
      3. Compose an email and attach two images using any screenshot tool for.e g lightshot
      4. Capture screenshot and use copy option to paste it to the email body content 
      5. Please note images capture would be having same name i.e image.png if view in the developer console.
      6. Send that email to appropriate email id configured above.
      7. As a result, Jira issue is created with two attachment i.e image.png and image-1.png, please note the suffice is added by Jira as par of fix in JSDSERVER-5054
      8. However, notice the description, it would contain duplicate image.png.

      Expected Results

      • The description should contain the correct images i.e image.png and image-1.png which are renamed by Jira itself.

      Actual Results

      • The duplicate image is added in description field

      Workaround

      • None at this of writing however,
      • Try to write a custom script in groovy to edit the description and correct the image name on Issue created event\
          • import com.atlassian.jira.component.ComponentAccessor
            import com.atlassian.jira.issue.attachment.Attachment
            import org.ofbiz.core.entity.GenericValue
            import com.atlassian.jira.ofbiz.OfBizDelegator
            import java.util.Randomdef issue = event.issue
            def attachmentManager = ComponentAccessor.getAttachmentManager()
            List<Attachment> attachments = attachmentManager.getAttachments(issue)
            void renameAttachment(attachmentID, newName){
            	OfBizDelegator delegator = ComponentAccessor.getComponentOfType(OfBizDelegator.class)
            	for(GenericValue attachment : delegator.findByField("FileAttachment", "id", attachmentID)){ 
            		attachment.setString("filename", newName)
            		attachment.store()
                } 
            }if(attachments.size()>1){
                ArrayList<String> fileNames = new ArrayList<String>()
             	for(attachment in attachments){
                    def filename = attachment.filename
                    if(fileNames.contains(filename)){
                        fileNames.add(filename)
                        Random random = new Random()
                        String newName = new Date().format('yyyyMMddhhmmssmmm').toString() + " " + random.next(10) + " " + filename
                     	fileNames.add(newName) //in case of multiple duplicatenames
                        try{
                           renameAttachment(attachment.id, newName) 
                        }catch(exc){
                            log.warn("Exception while trying to rename attachment: " + exc)
                        }     
                    }else{
            			fileNames.add(attachment.filename)
                    }
            	}
            }
            //x  
        • Check if any different app is available to capture the screenshot and rename it timestamp instead of static name i.e image.png

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              1ece1773342d Sandip Shrivastava
              Votes:
              5 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Backbone Issue Sync