Email notification of file shares From sharing user?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Email notification of file shares From sharing user?

Jered Floyd

OwnCloud Community,

Is there any way to configure OwnCloud to send the email notifications of external shares with a "From:" address of the sharing user, rather than an owncloud administrative address?  Or, at least, a "Reply-To"?  I get constant replies from outside users meaning to reply to the sharing user.

Thanks,
--Jered

_______________________________________________
User mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/user
Reply | Threaded
Open this post in threaded view
|

Re: Email notification of file shares From sharing user?

Jered Floyd

Sorry for the dumb question prior to actually inspecting the code -- I see that the system is configured so that it's supposed to do this!  However, it does not work when using an external auth (in my case, IMAP).

The problem is that the 'email' field of the oc_accounts table is not populated, nor can it be set by the user.  Additionally, a success message is displayed if the user attempts to change the email address, even though it does not take effect, due to an error in unchecked return types.

I've attached a patch that fixes the lack of an error message, but not one that addresses the underlying problem as I don't understand the system architecture well.  It appears that the reason setting the address fails is because the user is not given permissions to edit their account (by the GroupManager object) when the backend is IMAP.  I'm not sure the right way to go about fixing this problem.

Regards,
--Jered


--- UsersController.php    2018/01/28 12:15:31    1.1
+++ UsersController.php    2018/01/28 12:59:22
@@ -35,7 +35,6 @@
 use OCP\App\IAppManager;
 use OCP\AppFramework\Controller;
 use OCP\AppFramework\Http\DataResponse;
-use OCP\AppFramework\Http\JSONResponse;
 use OCP\AppFramework\Http\RedirectResponse;
 use OCP\AppFramework\Http\TemplateResponse;
 use OCP\AppFramework\Utility\ITimeFactory;
@@ -600,21 +599,21 @@
             );
         }
 
-        // admins can set email without verification
-        if ($mailAddress === '' || $this->isAdmin) {
-            $this->setEmailAddress($userId, $mailAddress);
-            return new DataResponse(
-                [
-                    'status' => 'success',
-                    'data' => [
-                        'message' => (string)$this->l10n->t('Email has been changed successfully.')
-                    ]
-                ],
-                Http::STATUS_OK
-            );
-        }
-
         try {
+            // admins can set email without verification
+            if ($mailAddress === '' || $this->isAdmin) {
+                $this->setEmailAddress($userId, $mailAddress);
+                return new DataResponse(
+                    [
+                        'status' => 'success',
+                        'data' => [
+                            'message' => (string)$this->l10n->t('Email has been changed successfully.')
+                        ]
+                    ],
+                    Http::STATUS_OK
+                );
+            }
+           
             if ($this->sendEmail($userId, $mailAddress)) {
                 return new DataResponse(
                     [
@@ -794,6 +793,7 @@
      *
      * @param string $id
       * @param string $mailAddress
+     * @throws \Exception
       */
     public function setEmailAddress($id, $mailAddress) {
         $user = $this->userManager->get($id);
@@ -805,10 +805,9 @@
                 $this->config->deleteUserValue($id, 'owncloud', 'changeMail');
             }
         } else {
-            return new JSONResponse([
-                'error' => 'cannotSetEmailAddress',
-                'message' => 'Cannot set email address for user'
-            ], HTTP::STATUS_NOT_FOUND);
+            throw new \Exception($this->l10n->t(
+                'Cannot set email address for user.'
+            ));
         }
     }
 
@@ -843,7 +842,12 @@
         $splittedToken = explode(':', $this->config->getUserValue($userId, 'owncloud', 'changeMail', null));
         $mailAddress = $splittedToken[2];
 
-        $this->setEmailAddress($userId, $mailAddress);
+        try {
+            $this->setEmailAddress($userId, $mailAddress);
+        } catch (\Exception $e) {
+            $this->log->error($e->getMessage(), ['app' => 'settings']);
+            return new RedirectResponse($this->urlGenerator->linkToRoute('settings.SettingsPage.getPersonal', ['changestatus' => 'error']));
+        }
 
         if ($oldEmailAddress !== null && $oldEmailAddress !== '') {
             $tmpl = new \OC_Template('settings', 'changemail/notify');



----- On Jan 26, 2018, at 2:53 PM, Jered Floyd <[hidden email]> wrote:

OwnCloud Community,

Is there any way to configure OwnCloud to send the email notifications of external shares with a "From:" address of the sharing user, rather than an owncloud administrative address?  Or, at least, a "Reply-To"?  I get constant replies from outside users meaning to reply to the sharing user.

Thanks,
--Jered

_______________________________________________
User mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/user


_______________________________________________
User mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/user
Reply | Threaded
Open this post in threaded view
|

Re: Email notification of file shares From sharing user?

Emil Lefherz

Hi Jered,

sounds like you're on the right tracks. Could you please open an issue in https://github.com/owncloud/core/issues? It would be nice if we could get this into the core.

Thanks,

Emil
ownCloud Community Management


On 28.01.2018 14:05, Jered Floyd wrote:

Sorry for the dumb question prior to actually inspecting the code -- I see that the system is configured so that it's supposed to do this!  However, it does not work when using an external auth (in my case, IMAP).

The problem is that the 'email' field of the oc_accounts table is not populated, nor can it be set by the user.  Additionally, a success message is displayed if the user attempts to change the email address, even though it does not take effect, due to an error in unchecked return types.

I've attached a patch that fixes the lack of an error message, but not one that addresses the underlying problem as I don't understand the system architecture well.  It appears that the reason setting the address fails is because the user is not given permissions to edit their account (by the GroupManager object) when the backend is IMAP.  I'm not sure the right way to go about fixing this problem.

Regards,
--Jered


--- UsersController.php    2018/01/28 12:15:31    1.1
+++ UsersController.php    2018/01/28 12:59:22
@@ -35,7 +35,6 @@
 use OCP\App\IAppManager;
 use OCP\AppFramework\Controller;
 use OCP\AppFramework\Http\DataResponse;
-use OCP\AppFramework\Http\JSONResponse;
 use OCP\AppFramework\Http\RedirectResponse;
 use OCP\AppFramework\Http\TemplateResponse;
 use OCP\AppFramework\Utility\ITimeFactory;
@@ -600,21 +599,21 @@
             );
         }
 
-        // admins can set email without verification
-        if ($mailAddress === '' || $this->isAdmin) {
-            $this->setEmailAddress($userId, $mailAddress);
-            return new DataResponse(
-                [
-                    'status' => 'success',
-                    'data' => [
-                        'message' => (string)$this->l10n->t('Email has been changed successfully.')
-                    ]
-                ],
-                Http::STATUS_OK
-            );
-        }
-
         try {
+            // admins can set email without verification
+            if ($mailAddress === '' || $this->isAdmin) {
+                $this->setEmailAddress($userId, $mailAddress);
+                return new DataResponse(
+                    [
+                        'status' => 'success',
+                        'data' => [
+                            'message' => (string)$this->l10n->t('Email has been changed successfully.')
+                        ]
+                    ],
+                    Http::STATUS_OK
+                );
+            }
+           
             if ($this->sendEmail($userId, $mailAddress)) {
                 return new DataResponse(
                     [
@@ -794,6 +793,7 @@
      *
      * @param string $id
       * @param string $mailAddress
+     * @throws \Exception
       */
     public function setEmailAddress($id, $mailAddress) {
         $user = $this->userManager->get($id);
@@ -805,10 +805,9 @@
                 $this->config->deleteUserValue($id, 'owncloud', 'changeMail');
             }
         } else {
-            return new JSONResponse([
-                'error' => 'cannotSetEmailAddress',
-                'message' => 'Cannot set email address for user'
-            ], HTTP::STATUS_NOT_FOUND);
+            throw new \Exception($this->l10n->t(
+                'Cannot set email address for user.'
+            ));
         }
     }
 
@@ -843,7 +842,12 @@
         $splittedToken = explode(':', $this->config->getUserValue($userId, 'owncloud', 'changeMail', null));
         $mailAddress = $splittedToken[2];
 
-        $this->setEmailAddress($userId, $mailAddress);
+        try {
+            $this->setEmailAddress($userId, $mailAddress);
+        } catch (\Exception $e) {
+            $this->log->error($e->getMessage(), ['app' => 'settings']);
+            return new RedirectResponse($this->urlGenerator->linkToRoute('settings.SettingsPage.getPersonal', ['changestatus' => 'error']));
+        }
 
         if ($oldEmailAddress !== null && $oldEmailAddress !== '') {
             $tmpl = new \OC_Template('settings', 'changemail/notify');



----- On Jan 26, 2018, at 2:53 PM, Jered Floyd [hidden email] wrote:

OwnCloud Community,

Is there any way to configure OwnCloud to send the email notifications of external shares with a "From:" address of the sharing user, rather than an owncloud administrative address?  Or, at least, a "Reply-To"?  I get constant replies from outside users meaning to reply to the sharing user.

Thanks,
--Jered

_______________________________________________
User mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/user



_______________________________________________
User mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/user


_______________________________________________
User mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/user