Miguel
Miguel

Reputation: 33

Filter action events not accurate

Have there been any changes to Google Drive Activity Queries? Today I have noticed that filters don't work properly.

To reply

I upload a file to a drive folder and when I query the activity of that folder the event has much more info and therefore filter's works in a weird way: My params:

{ 
   "ancestorName": "items/Folder_ID",
   "filter": "detail.action_detail_case:(MOVE DELETE)"
}

Expected Response

I expect to receive "MOVE" o "DELETE" events, however, I have received the UPLOAD event. In this case, as there has only been one upload I expect:

{
    "activities": []
}

Actual Response

{
    "activities": [
        {
            "primaryActionDetail": { "create": { "upload": {} } },
            "actors": [ { "user": { "knownUser": { } } } ],
            "actions": [
                {
                    "detail": { "create": { "upload": {} } }
                },
                {
                    "detail": { "edit": {} }
                },
                {
                    "detail": { "permissionChange": { "addedPermissions": [ { } ] } }
                },
                {
                    "detail": { "move": { "addedParents": [ { } ] } }
                }
            ],
            "targets": [
                {
                    "driveItem": {
                    }
                }
            ],
            "timestamp": "2020-04-15T10:36:58.686Z"
        }
    ]
}

The response has info about each detail that isn't relevant. As can be seen the primaryActionDetail is "create" "upload" but it is returned in the query despite having queried against "delete"/"move" actions. Any thoughts?

Does this happen because there is a "move" action in "actions"? If so, how could I filter only against primaryActionDetail?

Upvotes: 1

Views: 442

Answers (1)

Alessandro
Alessandro

Reputation: 2998

Considerations:

Migrating Drive API from v1 to v2, changed how single actions are displayed and grouped in the response. Specifically in v2, the consolidation strategy does not change the output for DriveActivity whic will always contain the full set of actors, targets, and actions.

Approach

A good approach here, as suggested in the documentation, would be filtering for the top level once the API call is returned.

[...] whether or not consolidation is enabled, it may be sufficient for many clients to look at only the top-level contents of a DriveActivity (i.e., the collective Actors and Targets with the primary ActionDetail) and ignore the detailed Actions in the response.

References:

Drive API v2

Upvotes: 0

Related Questions