Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/richdocuments.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Db/WopiMapper.php')
-rw-r--r--lib/Db/WopiMapper.php22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/Db/WopiMapper.php b/lib/Db/WopiMapper.php
index 056c6078..eeea8041 100644
--- a/lib/Db/WopiMapper.php
+++ b/lib/Db/WopiMapper.php
@@ -64,7 +64,7 @@ class WopiMapper extends Mapper {
* @param int $templateDestination
* @return Wopi
*/
- public function generateFileToken($fileId, $owner, $editor, $version, $updatable, $serverHost, $guestDisplayname, $templateDestination = 0, $hideDownload = false, $direct = false, $templateId = 0, $share = null, $tokenType = Wopi::TOKEN_TYPE_USER) {
+ public function generateFileToken($fileId, $owner, $editor, $version, $updatable, $serverHost, $guestDisplayname = null, $templateDestination = 0, $hideDownload = false, $direct = false, $templateId = 0, $share = null) {
$token = $this->random->generate(32, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
$wopi = Wopi::fromParams([
@@ -84,7 +84,25 @@ class WopiMapper extends Mapper {
'remoteServer' => '',
'remoteServerToken' => '',
'share' => $share,
- 'tokenType' => $tokenType
+ 'tokenType' => $guestDisplayname === null ? Wopi::TOKEN_TYPE_USER : Wopi::TOKEN_TYPE_GUEST
+ ]);
+
+ /** @var Wopi $wopi */
+ $wopi = $this->insert($wopi);
+
+ return $wopi;
+ }
+
+ public function generateInitiatorToken($uid, $remoteServer) {
+ $token = $this->random->generate(32, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS);
+
+ $wopi = Wopi::fromParams([
+ 'fileid' => 0,
+ 'editorUid' => $uid,
+ 'token' => $token,
+ 'expiry' => $this->timeFactory->getTime() + self::TOKEN_LIFETIME_SECONDS,
+ 'remoteServer' => $remoteServer,
+ 'tokenType' => Wopi::TOKEN_TYPE_INITIATOR
]);
/** @var Wopi $wopi */