nextcloud/text

Redirect to files app when opening direct editing from desktop client

開放

#585 建立於 2020年1月18日

 (4 則留言) (1 個反應) (0 位負責人)JavaScript (125 個分叉)auto 404
1. to developenhancementgood first issuephp

倉庫指標

星標
 (644 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

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.

貢獻者指南