Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nickvergessen opened this issue Feb 16, 2018 · 4 comments
Open

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

nickvergessen opened this issue Feb 16, 2018 · 4 comments

Comments

@nickvergessen
Copy link
Member

nickvergessen commented Feb 16, 2018

Copied from nextcloud/admin_notifications#4

Both from console and OCS

Maybe also "all users that logged in" too:
nextcloud/admin_notifications#5

@rasos
Copy link

rasos commented Jan 11, 2019

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
Copy link

t2d commented Dec 20, 2019

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
Copy link

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
Copy link

ostasevych commented Apr 17, 2024

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants