Confirmation email for FileDrop sender

Discussion in 'ActionScripts' started by David, Feb 1, 2020.

  1. David

    David Administrator
    Staff Member

    Joined:
    Dec 1, 2015
    Messages:
    781
    Likes Received:
    31
    Here is an other example of a User delivery Action Script which sends a confirmation email to the FileDrops sender when their files are successfully uploaded on the LF server.
    (Don't mistake this confirmation email with the download receipts which are being sent by LF server after the FileDrop recipient downloads the files)

    This Action script works on LF server v4.0.5 or higher.

    1) Action Script
    Create following Action script named i.e. "notification-email-to-filedrop-sender.rb" in "Admin > Configuration > Action Scripts" settings.
    Code:
    #!/usr/bin/env ruby
    require 'json'
    
    #set LF server senders email address and name
    lfsender="lfserver@domain.com"
    lfname="LiquidFiles"
    
    message_data = JSON.parse(File.read(ARGV[0]))
    filedropsender = message_data["sender"]
    subject = message_data["subject"]
    messageid = message_data["id"]
    filedroprecipients = message_data["recipients"]
    messagetxt = message_data["message"]
    timestamp=message_data["created_at"]
    
    #Notification email
    %x{/usr/sbin/sendmail -F #{lfname} -f #{lfsender} -t < /usr/bin/cat <<EOF
    Subject: Confirmation: #{subject}
    To:  #{filedropsender}
    
    This notification email confirms only you that your message ID: #{messageid} has been successfully uploaded to #{filedroprecipients}.
    This is not a download receipt.
    
    .
    EOF
    
    }

    2) Script Assignment
    Assign the script "notification-email-to-filedrop-sender.rb" to the required System FileDrop in "Admin > Configuration > Edit" with the "Delivery Action" selector.

    3) Testing
    Open the FileDrop in a browser and drop files. On the email of the sender you should receive that configured confirmation email. If something did not run well the LF appliance would send you an Email with script error.
     
    Andrew Jacobsen likes this.
  2. Andrew Jacobsen

    Andrew Jacobsen New Member

    Joined:
    Apr 12, 2018
    Messages:
    5
    Likes Received:
    0
    Thanks for the script, it worked first try. Scripts and their languages aren't my strength. How would I add a date/timestamp to the body of the email?
     
  3. David

    David Administrator
    Staff Member

    Joined:
    Dec 1, 2015
    Messages:
    781
    Likes Received:
    31
    You can read the time stamp from the message similarly like the sender address, subject and other attributes.

    i.e. define a variable: timestamp=message_data["message"]["created_at"]
    then add in the body of the email a row like this: Created at: #{timestamp}

    This should write date and time stamp when the files was dropped.
     
    Andrew Jacobsen likes this.

Share This Page