Skip to content

Instantly share code, notes, and snippets.

@iaindooley
Last active February 5, 2019 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iaindooley/722e1b89ec47bd653a93b21650810e5d to your computer and use it in GitHub Desktop.
Save iaindooley/722e1b89ec47bd653a93b21650810e5d to your computer and use it in GitHub Desktop.
Mirror attached file
function mirrorAttachedFile(notification)
{
var notif = new Notification(notification);
if(notif.member().notTrellinator())
{
var file = notif.attachedLink();
file.card().cardsLinkedInAttachments().first().attachLink({name: file.text(),link: file.link()});
}
}
@fogolin
Copy link

fogolin commented Feb 1, 2019

Works great for all kinds of files, except for Images (jpg, png). Here is how way I got it to work:

function mirrorAttachedFile(notification){
  var notif = new Notification(notification);
  if(notif.member().notTrellinator()) {
    try {
      var file = notif.attachedFile();
    } catch(e) {
      var file = notif.attachedLink();
    }
    file.card().cardsLinkedInAttachments().first().attachLink({name: file.text(),link: file.link()});
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment