question

brian avatar image
brian asked

Distinguish Cloud Script Triggerer

Hi,

We would like to have a cloud script that behaves differently based on whether it is triggered from a scheduled task.

E.g.:

* If triggered by client API, control access by GetUserReadOnlyData

* If triggered by scheduled task, no access control is needed

I have noticed that the `context` parameter of a handler might be designed to suit this need, however, I failed to find detailed information on how `context` parameter is specified.

I have tried several ways of triggering a cloud script:

1. Trigger from Client API:

{ "playerProfile":null, "playStreamEvent":null, "triggeredByTask":null }

2. Trigger from Scheduled Task - Run CloudScript function once

{ "playerProfile":null, "playStreamEvent":null, "triggeredByTask": { "Name":null, "Id": "<TASK_ID>" }

3. Trigger from Scheduled Task - Run actions on each player in a segment

{
  playerProfile: { ... },

  playStreamEvent: null,

  triggeredByTask: null 
}

So, the question is, can I safely assume that when `playerProfile` object presents, the script must have been triggered from server side? (not triggered by ClientAPI or its resultant PlayStream event)

Thanks in advance!

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

The best thing to do would be to use the PlayStream event data (which is only present on the call if the script was run from an action trigger in PlayStream) to know that the script was called from PlayStream, and the triggeredByTask info for any task-originating calls. Alternately, you can also pass in static info as a parameter from actions and tasks.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.