From 0a4c5816eef4dcce795bb053f40466d2c9b81f89 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Sat, 20 May 2017 01:17:23 +0530 Subject: [PATCH] Register the change under user's name when saving the document (cherry picked from commit 0f086cfe87294a62f6ae0501c1b55a5011ed71a3) Signed-off-by: Andras Timar --- lib/Controller/WopiController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php index 72f5b57e..e2a32272 100644 --- a/lib/Controller/WopiController.php +++ b/lib/Controller/WopiController.php @@ -177,6 +177,14 @@ class WopiController extends Controller { // Setup the FS which is needed to emit hooks (versioning). \OC_Util::tearDownFS(); \OC_Util::setupFS($res['owner']); + + // Set the user to register the change under his name + $editor = \OC::$server->getUserManager()->get($res['editor']); + if (is_null($editor)) { + throw new \OC\User\NoUserException("User " . $res['editor'] . "not found."); + } + \OC::$server->getUserSession()->setUser($editor); + $file->putContent($content); return new JSONResponse(); } catch (\Exception $e) {