nextcloud/text

Redirect to files app when opening direct editing from desktop client

Open

#585 opened on Jan 18, 2020

View on GitHub
 (4 comments) (1 reaction) (0 assignees)JavaScript (125 forks)auto 404
1. to developenhancementgood first issuephp

Repository metrics

Stars
 (644 stars)
PR merge metrics
 (PR metrics pending)

Description

This is a challenging https://github.com/nextcloud/text/labels/good%20first%20issue if you...

  • want to learn how the desktop client integrates with the text app
  • have some basic knowledge of php

If you would like some guidance ping @max-nextcloud or join the public text channel.

Problem

Direct editing is a mechanism we use so that from clients (mobile and desktop) you can open a file with a context menu click in your browser so you can collaborate using apps that support it instead of opening the file locally.

This works fine however in cases where the user is already logged in to an instance and has access to the file we want to redirect them to the files app directly. Direct editing has some technical limitations as it is stripped down to also work with only a one time token, so in case possible the forward will result in a better user experience and more functionality.

Here would be a few pointers, to make testing easier one can use the following curl statement to generate a link that the desktop client would open in the browser:

curl --request POST \
  --url 'https://admin:admin@nextcloud.local/ocs/v2.php/apps/files/api/v1/directEditing/open?editorId=text&creatorId=textdocument&format=json' \
  --header 'Content-Type: multipart/form-data' \
  --header 'OCS-APIRequest: true' \
  --form path=/test.md

The goal would be to check if the user is logged in and has access to the requested file. In this case it may not open the existing "direct editing" UI, but instead just redirect using the internal file link (e.g. /index.php/f/12345 for the file id 12345)

Note the implementation of this is likely better suited in the server repository.

Code pointers

https://github.com/nextcloud/server/blob/master/apps/files/lib/Controller/DirectEditingViewController.php#L42-L48 is the entrypoint of the URL that is opened in the browser then, which triggers https://github.com/nextcloud/text/blob/8cdb2d22fc42c60e03f480b1ddecfe328dbaaf42/lib/DirectEditing/TextDirectEditor.php#L151 for the text app.

Additional Context

This would go well together with #3819 if you also want to work with the client side.

Contributor guide