Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/notifications-admin-settings.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*! third party licenses: js/vendor.LICENSE.txt */
import{r,a as h,o as d,w as l,b as u,e as _,h as E,t as c,f as m,F as S,i as N,v as L,j as g,c as b}from"./style-CuI75DCK.chunk.mjs";import{_ as v,t as n,N as A,c as y,v as D,a as I,s as w,l as M}from"./_plugin-vue_export-helper-DKkIhHsV.chunk.mjs";import{N as k}from"./NcSettingsSection-CtSg7lH8-8ZOwf6a-.chunk.mjs";const s={EMAIL_SEND_OFF:0,EMAIL_SEND_HOURLY:1,EMAIL_SEND_3HOURLY:2,EMAIL_SEND_DAILY:3,EMAIL_SEND_WEEKLY:4},x={name:"AdminSettings",components:{NcCheckboxRadioSwitch:A,NcSettingsSection:k},data(){return{batchtime_options:[{text:n("notifications","Never"),value:s.EMAIL_SEND_OFF},{text:n("notifications","1 hour"),value:s.EMAIL_SEND_HOURLY},{text:n("notifications","3 hours"),value:s.EMAIL_SEND_3HOURLY},{text:n("notifications","1 day"),value:s.EMAIL_SEND_DAILY},{text:n("notifications","1 week"),value:s.EMAIL_SEND_WEEKLY}],config:M("notifications","config")}},methods:{t:n,async updateSettings(){try{const e=new FormData;e.append("batchSetting",this.config.setting_batchtime),e.append("soundNotification",this.config.sound_notification?"yes":"no"),e.append("soundTalk",this.config.sound_talk?"yes":"no"),await y.post(D("apps/notifications/api/v2/settings/admin"),e),I(n("notifications","Your settings have been updated."))}catch(e){w(n("notifications","An error occurred while updating your settings.")),console.error(e)}}}},U={for:"notify_setting_batchtime",class:"notification-frequency__label"},V=["value"];function Y(e,i,O,R,a,o){const f=r("NcCheckboxRadioSwitch"),p=r("NcSettingsSection");return d(),h(p,{name:o.t("notifications","Notifications defaults"),description:o.t("notifications","Configure the default notification settings for new users")},{default:l(()=>[u("p",null,[u("label",U,c(o.t("notifications","Send email reminders about unhandled notifications after:")),1),E(u("select",{id:"notify_setting_batchtime","onUpdate:modelValue":i[0]||(i[0]=t=>a.config.setting_batchtime=t),class:"notification-frequency__select",onChange:i[1]||(i[1]=t=>o.updateSettings())},[(d(!0),m(S,null,N(a.batchtime_options,t=>(d(),m("option",{key:t.value,value:t.value},c(t.text),9,V))),128))],544),[[L,a.config.setting_batchtime]])]),_(f,{modelValue:a.config.sound_notification,"onUpdate:modelValue":[i[2]||(i[2]=t=>a.config.sound_notification=t),o.updateSettings]},{default:l(()=>[g(c(o.t("notifications","Play sound when a new notification arrives")),1)]),_:1},8,["modelValue","onUpdate:modelValue"]),_(f,{modelValue:a.config.sound_talk,"onUpdate:modelValue":[i[3]||(i[3]=t=>a.config.sound_talk=t),o.updateSettings]},{default:l(()=>[g(c(o.t("notifications","Play sound when a call started (requires Nextcloud Talk)")),1)]),_:1},8,["modelValue","onUpdate:modelValue"])]),_:1},8,["name","description"])}const F=v(x,[["render",Y]]);b(F).mount("#notifications-admin-settings");
import{r as _,a as h,o as d,w as l,b as u,e as r,h as E,t as c,f as m,F as S,i as N,v as L,j as g,c as b}from"./style-CuI75DCK.chunk.mjs";import{_ as v,t as n,N as A,c as y,v as D,a as I,s as w,l as M}from"./_plugin-vue_export-helper-DKkIhHsV.chunk.mjs";import{N as k}from"./NcSettingsSection-CtSg7lH8-8ZOwf6a-.chunk.mjs";const s={EMAIL_SEND_OFF:0,EMAIL_SEND_HOURLY:1,EMAIL_SEND_3HOURLY:2,EMAIL_SEND_DAILY:3,EMAIL_SEND_WEEKLY:4},x={name:"AdminSettings",components:{NcCheckboxRadioSwitch:A,NcSettingsSection:k},data(){return{batchtime_options:[{text:n("notifications","Never"),value:s.EMAIL_SEND_OFF},{text:n("notifications","1 hour"),value:s.EMAIL_SEND_HOURLY},{text:n("notifications","3 hours"),value:s.EMAIL_SEND_3HOURLY},{text:n("notifications","1 day"),value:s.EMAIL_SEND_DAILY},{text:n("notifications","1 week"),value:s.EMAIL_SEND_WEEKLY}],config:M("notifications","config")}},methods:{t:n,async updateSettings(){try{const e=new FormData;e.append("batchSetting",this.config.setting_batchtime),e.append("soundNotification",this.config.sound_notification?"yes":"no"),e.append("soundTalk",this.config.sound_talk?"yes":"no"),await y.post(D("apps/notifications/api/v2/settings/admin"),e),I(n("notifications","Your settings have been updated."))}catch(e){w(n("notifications","An error occurred while updating your settings.")),console.error(e)}}}},U={for:"notify_setting_batchtime",class:"notification-frequency__label"},V=["value"];function Y(e,i,O,R,a,o){const f=_("NcCheckboxRadioSwitch"),p=_("NcSettingsSection");return d(),h(p,{name:o.t("notifications","Notifications defaults"),description:o.t("notifications","Configure the default notification settings")},{default:l(()=>[u("p",null,[u("label",U,c(o.t("notifications","Send email reminders about unhandled notifications after:")),1),E(u("select",{id:"notify_setting_batchtime","onUpdate:modelValue":i[0]||(i[0]=t=>a.config.setting_batchtime=t),class:"notification-frequency__select",onChange:i[1]||(i[1]=t=>o.updateSettings())},[(d(!0),m(S,null,N(a.batchtime_options,t=>(d(),m("option",{key:t.value,value:t.value},c(t.text),9,V))),128))],544),[[L,a.config.setting_batchtime]])]),r(f,{modelValue:a.config.sound_notification,"onUpdate:modelValue":[i[2]||(i[2]=t=>a.config.sound_notification=t),o.updateSettings]},{default:l(()=>[g(c(o.t("notifications","Play sound when a new notification arrives")),1)]),_:1},8,["modelValue","onUpdate:modelValue"]),r(f,{modelValue:a.config.sound_talk,"onUpdate:modelValue":[i[3]||(i[3]=t=>a.config.sound_talk=t),o.updateSettings]},{default:l(()=>[g(c(o.t("notifications","Play sound when a call started (requires Nextcloud Talk)")),1)]),_:1},8,["modelValue","onUpdate:modelValue"])]),_:1},8,["name","description"])}const F=v(x,[["render",Y]]);b(F).mount("#notifications-admin-settings");
//# sourceMappingURL=notifications-admin-settings.mjs.map
2 changes: 1 addition & 1 deletion js/notifications-admin-settings.mjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use OCA\Notifications\Capabilities;
use OCA\Notifications\Listener\AddMissingIndicesListener;
use OCA\Notifications\Listener\BeforeTemplateRenderedListener;
use OCA\Notifications\Listener\PostLoginListener;
use OCA\Notifications\Listener\UserCreatedListener;
use OCA\Notifications\Listener\UserDeletedListener;
use OCA\Notifications\Notifier\AdminNotifications;
Expand All @@ -24,7 +23,6 @@
use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent;
use OCP\DB\Events\AddMissingIndicesEvent;
use OCP\Notification\IManager;
use OCP\User\Events\PostLoginEvent;
use OCP\User\Events\UserCreatedEvent;
use OCP\User\Events\UserDeletedEvent;

Expand All @@ -47,7 +45,6 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
$context->registerEventListener(BeforeTemplateRenderedEvent::class, BeforeTemplateRenderedListener::class);
$context->registerEventListener(UserCreatedEvent::class, UserCreatedListener::class);
$context->registerEventListener(PostLoginEvent::class, PostLoginListener::class);
}

#[\Override]
Expand Down
13 changes: 4 additions & 9 deletions lib/BackgroundJob/GenerateUserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

use OCA\Notifications\Model\Settings;
use OCA\Notifications\Model\SettingsMapper;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\IDBConnection;
Expand Down Expand Up @@ -47,15 +46,11 @@ protected function run($argument): void {
return;
}

try {
$this->settingsMapper->getSettingsByUser($user->getUID());
} catch (DoesNotExistException) {
$settings = new Settings();
$settings->setUserId($user->getUID());
$settings->setNextSendTime(1);
$settings->setBatchTime(Settings::EMAIL_SEND_3HOURLY);
// Initializes the default settings
$settings = $this->settingsMapper->getSettingsByUser($user->getUID());
if ($settings->getLastSendId() === 0) {
$settings->setLastSendId($maxId);
$this->settingsMapper->insert($settings);
$this->settingsMapper->update($settings);
}
});
}
Expand Down
Loading