notifications icon indicating copy to clipboard operation
notifications copied to clipboard

Allow to send notifications to all members of a group

Open nickvergessen opened this issue 7 years ago • 4 comments

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

nickvergessen avatar Feb 16 '18 12:02 nickvergessen

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.

rasos avatar Jan 11 '19 06:01 rasos

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"

t2d avatar Dec 20 '19 14:12 t2d

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.

Justinzobel avatar Jul 14 '21 01:07 Justinzobel

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"

oleua avatar Apr 17 '24 05:04 oleua