nextcloud / notifications

🔔 Notifications app for Nextcloud
GNU Affero General Public License v3.0
119 stars 56 forks source link

Allow to send notifications to all members of a group #121

Open nickvergessen opened 6 years ago

nickvergessen commented 6 years ago

Copied from https://github.com/nextcloud/admin_notifications/issues/4

Both from console and OCS

Maybe also "all users that logged in" too: https://github.com/nextcloud/admin_notifications/issues/5

rasos commented 5 years ago

We would be even happy to show a notification to all or users of selected groups in a top bar, e.g. for scheduled maintenance announcements.

t2d commented 4 years ago

We would be even happy to show a notification to all or users of selected groups in a top bar, e.g. for scheduled maintenance announcements.

I used this command-line oneliner for this purpose

sudo -u www-data php /path/to/nextcloud/occ user:list | sed 's/.*- \(.*\):.*/\1/' | xargs -l -i sudo -u www-data php /path/to/nextcloud/occ notification:generate {} "System maintenance today starting at 4 PM"
Justinzobel commented 3 years ago

Hate to necro things like this but this would be very helpful.

@t2d Thanks for your script, that did the trick. Would still love to see this feature added.

ostasevych commented 7 months ago

We would be even happy to show a notification to all or users of selected groups in a top bar, e.g. for scheduled maintenance announcements.

I used this command-line oneliner for this purpose

sudo -u www-data php /path/to/nextcloud/occ user:list | sed 's/.*- \(.*\):.*/\1/' | xargs -l -i sudo -u www-data php /path/to/nextcloud/occ notification:generate {} "System maintenance today starting at 4 PM"

This is very nice script!!! I suggest to remove -l option in xargs command and add -l "Body text":

sudo -u www-data php /path/to/nextcloud/occ user:list | sed 's/.*- \(.*\):.*/\1/' | xargs -i sudo -u www-data php /path/to/nextcloud/occ notification:generate -l "Body text" {} "Header"

I also elaborated sending messages to a certain group on the base of occ group:list command on the base of your findings.

My suggestion is to use the following sed sentence:

sed -En '/^[[:space:]]*-[[:space:]]<groupname>.$/,/^[[:space:]]{2}-[[:space:]][^-]/{/^[[:space:]]*-[[:space:]]/{s/^[[:space:]]{4}-[[:space:]]//p}; /^[[:space:]]*-[[:space:]]/d}'

So, the final script will look like this:

php ./occ group:list | \
sed -En '/^[[:space:]]*-[[:space:]]<groupname>.$/,/^[[:space:]]{2}-[[:space:]][^-]/{/^[[:space:]]*-[[:space:]]/{s/^[[:space:]]{4}-[[:space:]]//p}; /^[[:space:]]*-[[:space:]]/d}' | \
xargs -i php ./occ notification:generate -l "Body of the message" {} "Header of the message"