LiquidFiles Documentation

Message Parameters Actionscripts adds the ability to programatically change Message Parameters using Actionscripts. This can be used for instance to automatically disable authentication of a message if any recipient matches "". Or you can automatically set the private message flag if the subject contains "secret". Set the Expires After to 365 days from now if the recipient matches "".

Please see the following as a video walkthrough of Message Authorization override using Actionscripts.

You can install or upload scripts by going to Admin → Configuration → Actionscripts. Please see the Actionscript Installation instruction for more details. When you have installed the script, you can enable the Message Parameters Actionscript on a per group basis in Admin → Groups.

When the script is executed, it will be exectured similar to:

your_actionscript.ext filedata.json

The filedata file (which in reality will be a randomized filename), will have content like the following JSON output:

    "bccs": [""],
    "subject":"Example Message Subject",
    "message":"Example Message Body",
    "authorization_description":"Anyone (with access to the randomized link) can access",
        "filename":"01-12345 our drawings1of2.pdf",
        "filename":"01-12345 our drawings2of2.pdf",

Please see the Message API for a description of each field. The only difference from the Message API is that there's no URL and instead there's a "system_file" for each attachment. It's this "system_file" parameter you can use to process files.

The parameters you can change using the Message Parameters Actionscript are:

  • recipients, ccs, bccs — Array of recipients, ccs, bccs
  • authorization — expects a numeric value 0-4
  • private_message — true or false
  • expires_after — numeric value
  • expires_at — date on the format YYYY-MM-DD
  • subject — string
  • error — will return an error to the user and will prevent the message to send.

Please note that the message will still need to pass validation, so if you have configured that the expires_at can be max 180 days in the future, and the Actionscript sets expires_at to 365 days in the future, the validation will fail and there will be an error presented to the user.

The output from the script needs to be in JSON format like:

{"authorization": 0,
"private_message": true,
"expires_after": 10,
"expires_at": "2020-02-20",
"subject": "My new Subject",
"error": "You cannot send this message because..."}

You only need to include the parameters you wish to change. If there's no parameters and no output, the message will not change.

If there's any output to STDERR or the exit code is not zero (0), an error message will be sent with the output to the configured System Alert email address. You can use this for debugging.

Please see the following example Actionscript that will override the message authorization and set it to 0 (unauthenticated) if any recipient matches

#!/usr/bin/env ruby
require 'json'

message_data = JSON.parse([0]))

authorization = message_data["message"]["authorization"]
message_data["message"]["recipients"].each do |recipient|
  authorization = 0 if recipient.match(/@trusted\.com/)

puts %{{"authorization": #{authorization}}}

If you examine the script, you can see that the script parses the JSON output from the messagedata file. It will then iterate over each recipient. If any recipient matches, it will set the authorization for the message to 0, meaning no authentication. If no recipient matches, it will use the previous authorization from the message.

Another example script:

#!/usr/bin/env ruby
require 'json'

message_data = JSON.parse([0]))

untrusted_error = false
if message_data["message"]["authorization"] = 0
  message_data["message"]["recipients"].each do |recipient|
    if recipient.match(/@untrusted\.com/)
      untrusted_error = true

if untrusted_error
  puts '{"error": "You are not allowed to set no authentication when sending to"}'

In this example, there will be an error message if any recipient matches, and no authentication is set on the message. If you wanted to, you could have overwritten the authorization to something else instead.

Yes Another example script:

#!/usr/bin/env ruby
require 'json'

message_data = JSON.parse([0]))

if message_data["message"]["subject"].match(/secret/i) || message_data["message"]["message"].match(/secret/i)
  bcc = (message_data["message"]["bccs"] + [""]).to_json
  puts %{{"authorization": 3, "private_message": true, "bccs": #{bccs}}}

In this example, the authorization will be set to Only Specified Recipients, it sets the private message flag and adds "" if either the subject or message matches "secret".