Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the mimetype to the preview arrays #300

Merged
merged 3 commits into from
Nov 7, 2018

Conversation

nickvergessen
Copy link
Member

@tobiasKaminsky I guess a capability is needed, or will you just check for existance of the field?

@tobiasKaminsky
Copy link
Member

I guess a capability is needed, or will you just check for existance of the field?

I am not sure, ideally there would be a way so that client get informed, once every app version has this included, so that I can remove the legacy code.

Are capabilities the best way for this? They cannot be removed at all, or other apps might break?

@tobiasKaminsky
Copy link
Member

@nickvergessen can you update this to latest master? This fails due to unsafe-eval.

@tobiasKaminsky
Copy link
Member

Simple rebasing seems to be enough

@tobiasKaminsky
Copy link
Member

@nickvergessen objects is not documented here: https://github.com/nextcloud/activity/blob/master/docs/endpoint-v2.md

Can you clarify this on the following sample activity?

We have objects{}, but also object_id, object_name which are the same like one (the last) of objects{}?

objects{} holds the current path of the file? So on a deleted file it should be a path to trashbin?

{
    "activity_id": 12420,
    "app": "files",
    "type": "file_created",
    "user": "act",
    "subject": "You created New text file.txt, 1, 16098_021.jpg, 15088_062.jpg and 15088_006.jpg",
    "subject_rich": [
     "You created {file5}, {file4}, {file3}, {file2} and {file1}",
     {
      "file1": {
       "type": "file",
       "id": "71517",
       "name": "15088_006.jpg",
       "path": "15088_006.jpg",
       "link": "http:\/\/localhost\/nc\/index.php\/f\/71517"
      },
      "file2": {
       "type": "file",
       "id": "71524",
       "name": "15088_062.jpg",
       "path": "15088_062.jpg",
       "link": "http:\/\/localhost\/nc\/index.php\/f\/71524"
      },
      "file3": {
       "type": "file",
       "id": "71528",
       "name": "16098_021.jpg",
       "path": "16098_021.jpg",
       "link": "http:\/\/localhost\/nc\/index.php\/f\/71528"
      },
      "file4": {
       "type": "file",
       "id": "71591",
       "name": "1",
       "path": "1",
       "link": "http:\/\/localhost\/nc\/index.php\/f\/71591"
      },
      "file5": {
       "type": "file",
       "id": "71592",
       "name": "New text file.txt",
       "path": "New text file.txt",
       "link": "http:\/\/localhost\/nc\/index.php\/f\/71592"
      }
     }
    ],
    "message": "",
    "message_rich": [
     "",
     []
    ],
    "object_type": "files",
    "object_id": 71517,
    "object_name": "\/15088_006.jpg",
    "objects": {
     "71592": "\/New text file.txt",
     "71591": "\/1",
     "71528": "\/16098_021.jpg",
     "71524": "\/15088_062.jpg",
     "71517": "\/15088_006.jpg"
    },
    "link": "http:\/\/localhost\/nc\/index.php\/apps\/files\/?dir=\/",
    "icon": "http:\/\/localhost\/nc\/apps\/files\/img\/add-color.svg",
    "datetime": "2018-10-11T07:40:00+00:00",
    "previews": [
     {
      "link": "http:\/\/localhost\/nc\/index.php\/apps\/files\/?dir=\/&scrollto=New%20text%20file.txt",
      "source": "http:\/\/localhost\/nc\/index.php\/core\/preview.png?file=\/New%20text%20file.txt&c=7f213bf369552b877af417fc3e8e3b8b&x=150&y=150",
      "mimeType": "text\/plain",
      "isMimeTypeIcon": false,
      "fileId": 71592,
      "view": "files"
     },
     {
      "link": "http:\/\/localhost\/nc\/index.php\/apps\/files\/?dir=\/1.d1539330847&view=trashbin",
      "source": "http:\/\/localhost\/nc\/core\/img\/filetypes\/folder.svg",
      "mimeType": "dir",
      "isMimeTypeIcon": true,
      "fileId": 71591,
      "view": "trashbin"
     },
     {
      "link": "http:\/\/localhost\/nc\/index.php\/apps\/files\/?dir=\/&scrollto=16098_021.jpg",
      "source": "http:\/\/localhost\/nc\/index.php\/core\/preview.png?file=\/16098_021.jpg&c=9ecf3a82c89fda8872b04dbd5d0cb29f&x=150&y=150",
      "mimeType": "image\/jpeg",
      "isMimeTypeIcon": false,
      "fileId": 71528,
      "view": "files"
     },
     {
      "link": "http:\/\/localhost\/nc\/index.php\/apps\/files\/?dir=\/&scrollto=15088_062.jpg",
      "source": "http:\/\/localhost\/nc\/index.php\/core\/preview.png?file=\/15088_062.jpg&c=9de812362ff82f086e5ba6de73bea23b&x=150&y=150",
      "mimeType": "image\/jpeg",
      "isMimeTypeIcon": false,
      "fileId": 71524,
      "view": "files"
     },
     {
      "link": "http:\/\/localhost\/nc\/index.php\/apps\/files\/?dir=\/&scrollto=15088_006.jpg",
      "source": "http:\/\/localhost\/nc\/index.php\/core\/preview.png?file=\/15088_006.jpg&c=97fa0ab65c3e591d9ac41d0dcbad3eb8&x=150&y=150",
      "mimeType": "image\/jpeg",
      "isMimeTypeIcon": false,
      "fileId": 71517,
      "view": "files"
     }
    ]
   }

@tobiasKaminsky
Copy link
Member

@nickvergessen is there a way to backport this also to older version, e.g. those for Nc12/13? It would be a little nightmare to support both ways of preview fetching…

@MorrisJobke MorrisJobke mentioned this pull request Nov 6, 2018
29 tasks
@nickvergessen
Copy link
Member Author

No, just don't provide previews for 12/13/14

As for the object_* & objects{} information. That is the path of the moment when the activity happens. I guess the object_name should not be part of the API since it can/will change at least for files. But well, can't change the API and it was there when I started at OC back then.
That is also the reason why it is not documented, so people don't use it.

I will rebase this and fix the unit tests tomorrow, so we can get this in for 15

Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the feature/noid/better-preview-api branch from 19fc5e4 to 190f6c8 Compare November 7, 2018 11:24
@nickvergessen
Copy link
Member Author

Rebased and fixed unit tests
quick review @MorrisJobke ?

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code change makes sense 👍

@MorrisJobke MorrisJobke merged commit 39946fd into master Nov 7, 2018
@MorrisJobke MorrisJobke deleted the feature/noid/better-preview-api branch November 7, 2018 15:00
@nickvergessen nickvergessen mentioned this pull request Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants