Skip to content

API: No way to retrieve events later than a certain point  #405

Closed as not planned

Description

@dragotin

The current API only takes the parameters page number and number of entries to influence the subset of entries returned.

For a client that is not suitable. We need an API that provides all new entries that came after a certain point of time. That can either be done through ID or timestamp. The client needs a way to specify a number of events to be returned at a time (already there), but also a way to query how many new entries are new after a certain point.

This blocks owncloud/client#3732, owncloud/client#3728

Activity

  1. DeepDiver1975 commented on Oct 8, 2015

    @DeepDiver1975
    Contributor

    For a client that is not suitable. We need an API that provides all new entries that came after a certain point of time.

    Reading this I assume you intend to store the activities locally in the clients and want to check in a given interval for new activities - right?

    So basically this would be an activity sync mechanism.

  2. nickvergessen commented on Oct 8, 2015

    @nickvergessen
    Contributor

    Don't really care too much, which route we go. Either OCS or WebDAV

    OCS has the pro that it exists already, con it needs to be adjusted a lot to allow starting by timestamp and more, so we either break the existing endpoint or need to make a new one, so the already-existing benefit is gone.

    Anyone with power please make the call.

  3. DeepDiver1975 commented on Oct 8, 2015

    @DeepDiver1975
    Contributor

    Don't really care too much, which route we go. Either OCS or WebDAV

    Protocol is to be choosen at a later stage - for now I want to understand the client's expectations and it's operations.

    @dragotin

  4. dragotin commented on Oct 8, 2015

    @dragotin
    Author

    I was thinking about this:

    • Client maintains a local storage of the events to be able to display them quickly and also in offline mode
    • From that local storage, client can find out the latest event it knows, ie. the highest timestamp, or maybe better id.
    • to fetch new events from the server, it sends the last known highest timestamp along and the server returns the new events that came after that.
    • To not get completely flooded client sends a maximum of events per call, and server replies accordingly with that amount maximum. If there are more that has to be indicated somehow.

    But maybe I misunderstood the API completely?

  5. nickvergessen commented on Oct 8, 2015

    @nickvergessen
    Contributor

    Well the current API is like a paged search. Just like you would get from a book or in the web ui.
    However the local storing and offline thing makes sense to me and I also see no other way then having a "I know everything up to activity #X" approach.

  6. karlitschek commented on Oct 8, 2015

    @karlitschek

    @nickvergessen OCS please. Let's stay at the current route with the current API unless a change is absolutely necessary.

  7. nickvergessen commented on Oct 30, 2015

    @nickvergessen
    Contributor

    Endpoint

    1. Specify the last known ID
    2. Sorts ascending
    3. Header specifies the first known ID (in case the given one was pruned (time))
    4. Header specifies if there are more activities (only bool, not a number or something)
    5. Client reads header from 3 and throws away all activities before it.
    6. Client reads header from 4 and then calls again with the newest ID from the previous call

    Questions

    • What happens when disabling an activity type in the personal settings? There might be invalid activities in the middle, that need to be deleted, but the server does not know which activities are in the client that should be deleted as well.
      • Should we also send a list of "activity types to keep", and the client drops activities that are not set anymore?
      • Enabling a type is not that big of a problem, because the server may not have stored the action, but it can happen that an activity is in the WebUI which the client is missing, because it didn't sync back then. But I'd say "sorry, this setting may not be retro-active"

    Request for all activities

    GET /cloud/activity
    

    With type filter

    GET /cloud/activity/:filter
    

    Parameters

    Name Type Description
    since int (Optional) The integer ID of the last activity that you’ve seen.
    limit int (Optional) How many activities should be returned (Default: 50)
    object_type string (Optional) Allows to filter the activities to a given object. May only appear together with object_id
    object_id string (Optional) Allows to filter the activities to a given object. May only appear together with object_type
    sort string - asc or desc Should activities be given ascending or descending (from the since) (Default: desc)

    Status

    Status Code Response Description
    200 OK [{Activity element}(,{Activity element})] Activities
    304 Not Modified [] No new activities
    403 Forbidden The offset activity belongs to a different user
    404 Not Found The filter is unknown

    Headers

    Link for the next request

    Already includes all parameters

    Link: <http(s)://localhost/ocs/v1.php/cloud/activity?since=364>; rel="next"
    

    First known activity

    In case the since parameter was not known, the header gives the first known activity ID

    X-Activity-First-Known: 370
    

    Activity element

    Field name Type Value description
    activity_id int Autoincrement value from the database
    timestamp int UNIX timestamp of the activity
    app string App that created the activity (e.g. 'files', 'files_sharing', etc.)
    type string For most files related activities this is the action that was performed on the file/folder (e.g. 'file_changed', 'file_created' (same is used for both, file and folder)), other apps use other strings (e.g. 'announcementcenter')
    user string (Optional) User ID of the user that triggered/created this activity (can also be empty in case of public link/remote share action)
    affecteduser string User ID of the user that received this activity (always the same)
    subject string Untranslated arbitrary subject (e.g. 'changed_self', 'changed_by')
    subjectparams array Array with one array per parameter, each parameter array has the key 'type' and 'value'. Value is an array-of-parameters in case of type collection and a string otherwise
    message string (Optional) Untranslated arbitrary message (unused by core apps)
    messageparams array See subjectparams
    link string (Optional) A full URL pointing to a suitable location (e.g. 'http://localhost/ownCloud/master/core/index.php/apps/files/?dir=%2Ffolder' in case the folder got created)
    object_type string (Optional) Type of the object this activity is about (e.g. 'files' is used for files and folders)
    object_id string (Optional) ID of the object this activity is about (e.g. ID in the file cache is used for files and folders)
    object_name string (Optional) Name of the object this activity is about (e.g. for files it's the relative path to the user's root: '/folder/.travis.yml')
    subjectformatted array
    subjectformatted.trimmed string Short version of the subject (only filename instead of path, etc. You changed abc.txt)
    subjectformatted.full string Long version of the subject (e.g. You changed path/to/file/abc.txt)
    subjectformatted.markup array
    subjectformatted.markup.trimmed string Short version of the subject (only filename instead of path, etc. You changed <a class="filename has-tooltip" href="/ownCloud/master/core/index.php/apps/files?dir=%2Ffolder&scrollto=abc.txt" title="in path/to/file">abc.txt</a>)
    subjectformatted.markup.full string Short version of the subject (e.g. You changed <a class="filename has-tooltip" href="/ownCloud/master/core/index.php/apps/files?dir=%2Ffolder&scrollto=abc.txt">path/to/fileabc.txt</a>)
    messageformatted array See subjectformatted and it's children (unused by core apps, values can be very long)
    activity_ids array of int (Optional) Array of activity_ids that have been grouped into this activity

    In case the endpoint returns more fields, they should be ignored and are deprecated (only for backwards compatibility usage) or internal.

    Example

      {
        "activity_id": 1,
        "timestamp": 1446137950,
        "app": "files",
        "type": "file_deleted",
        "user": "admin",
        "affecteduser": "admin",
        "subject": "deleted_self",
        "subjectparams": [
          {
            "value": "\/welcome.txt",
            "type": "file"
          }
        ],
        "message": "",
        "messageparams": [
    
        ],
        "link": "",
        "object_type": "files",
        "object_id": 3,
        "object_name": "\/welcome.txt",
        "subjectformatted": {
          "trimmed": "You deleted welcome.txt",
          "full": "You deleted path/to/file/welcome.txt",
          "markup": {
            "trimmed": "You deleted <a class=\"filename\" href=\"\/ownCloud\/master\/core\/index.php\/apps\/files?dir=%2F&scrollto=welcome.txt.d1446137950&view=trashbin\" title="in path/to/file">welcome.txt<\/a>",
            "full": "You deleted <a class=\"filename\" href=\"\/ownCloud\/master\/core\/index.php\/apps\/files?dir=%2F&scrollto=welcome.txt.d1446137950&view=trashbin\"path/to/file/>welcome.txt<\/a>"
          }
        },
        "messageformatted": {
          "trimmed": "",
          "full": "",
          "markup": {
            "trimmed": "",
            "full": ""
          }
        }
      }

    Usages

    • Web UI uses subjectformatted.markup.trimmed and messageformatted.markup.trimmed
    • RSS feed uses subjectformatted.full and messageformatted.full

    Notes

    The endpoint does not yet output that information

  8. DeepDiver1975 commented on Oct 30, 2015

    @DeepDiver1975
    Contributor

    THX @nickvergessen

    We need to specify the url parameters of the request as well.

    May I suggest to add some example code like https://developer.github.com/v3/repos/#get ? THX

  9. nickvergessen commented on Oct 30, 2015

    @nickvergessen
    Contributor

    Updated

  10. dragotin commented on Nov 2, 2015

    @dragotin
    Author

    Nice, this looks reasonable.

    Some questions/remarks:

    • How do we specify how many results come back with a call to the new api?
    • I don't think using headers here is nice. Can we add the next-link and the there-is-more to the json doc?
    • What is the difference between trimmed and full for message and subject?
    • We should not duplicate the strings with markups in the result. Let's use an Accept header to let each client specify the format it wants back.
    • I think object_type and object_name are redundant, as they are already there as "subjectparams". How about adding the object_id to the subject params as well?
  11. DeepDiver1975 commented on Nov 3, 2015

    @DeepDiver1975
    Contributor

    I don't think using headers here is nice. Can we add the next-link and the there-is-more to the json doc?

    this approach follows a common standard - https://tools.ietf.org/html/rfc5988 - used by e.g. Github as well

  12. DeepDiver1975 commented on Nov 3, 2015

    @DeepDiver1975
    Contributor

    We should not duplicate the strings with markups in the result. Let's use an Accept header to let each client specify the format it wants back.

    Accept is to specify the full body format - not individual elements

  13. nickvergessen commented on Nov 3, 2015

    @nickvergessen
    Contributor
    • How do we specify how many results come back with a call to the new api?

    Missed it, added now:

    Name Type Description
    limit int (Optional) How many activities should be returned (Default: 50)
    • I don't think using headers here is nice. Can we add the next-link and the there-is-more to the json doc?

    Well then we need to wrap the result once more, because stuff can not be added to the meta setion, resulting in: ocs > data > activities > element+

    • What is the difference between trimmed and full for message and subject?

    As per description above:

    • trimmed - Short version of the subject (only filename instead of path, etc. You changed abc.txt)
    • full - Long version of the subject (e.g. You changed path/to/file/abc.txt)
    • We should not duplicate the strings with markups in the result. Let's use an Accept header to let each client specify the format it wants back.

    Not possible, because the header is used by OCS to decide if json or xml is to be returned.

    • I think object_type and object_name are redundant, as they are already there as "subjectparams". How about adding the object_id to the subject params as well?

    No, only in some cases. When stuff is grouped (instead of a single activity) or when there are more parameters, they are not equal anymore. But yes, object_id will most likely be added to the path for future activities

  14. 18 remaining items

  15. karlitschek commented on Feb 23, 2016

    @karlitschek

    agreed. let restart this for 9.1

  16. dragotin commented on Mar 9, 2016

    @dragotin
    Author

    @karlitschek mentioned something about a public standard that could be used here.

  17. MTRichards commented on Apr 1, 2016

    @MTRichards
    Contributor

    In the interim between 9 and 9.1, a draft standard from W3C emerged. There is the opportunity to use this standard for this activity stream, rather than implementing our own. As it is in draft, we can put in feature requests.
    Note: Types of activity stream are defined by W3C, and we need to correlate ownCloud values to W3C pre-defined types.

    Plan for oC

    • Support the old API with the new W3C API, and also introduce a way to jump back and fetch activities from a certain time.

    Any other W3C API specification support is for a version 2.0.

  18. MTRichards commented on Apr 1, 2016

    @MTRichards
    Contributor

    Estimation: 2 weeks

  19. modified the milestones: , on May 30, 2016
  20. PVince81 commented on Apr 6, 2017

    @PVince81
    Contributor

    I'm moving this to backlog for now until this gets rescheduled.

    cc @guruz to recheck this old requirement

    cc @pmaier1

  21. modified the milestones: backlog, 10.0 on Apr 6, 2017
  22. removed their assignment
    on Apr 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions