过滤动作事件不准确

Filter action events not accurate

Google驱动Activity查询是否有任何变化?今天我注意到过滤器不能正常工作。

回复

我将一个文件上传到驱动器文件夹,当我查询该文件夹的 activity 时,该事件有更多信息,因此过滤器以一种奇怪的方式工作: 我的参数:

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

预期响应

我希望收到 "MOVE" o "DELETE" 事件,但是,我收到了 UPLOAD 事件。在这种情况下,因为我预计只有一个上传:

{
    "activities": []
}

实际响应

{
    "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"
        }
    ]
}

响应包含有关每个不相关细节的信息。可以看出,primaryActionDetail 是 "create" "upload",但尽管查询了 "delete"/"move" 操作,它仍会在查询中返回。有什么想法吗?

发生这种情况是因为 "actions" 中有一个 "move" 动作吗?如果是这样,我如何才能仅针对 primaryActionDetail 进行过滤?

注意事项:

将驱动器 API 从 v1 迁移到 v2,更改了单个操作在响应中的显示和分组方式。特别是在 v2 中,合并策略不会更改 DriveActivity 的输出,它将始终包含完整的参与者、目标和操作集。

方法

这里的一个好方法,正如 documentation 中所建议的那样,一旦返回 API 调用就过滤顶层。

[...] 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.

参考文献:

Drive API v2