announcementcenter icon indicating copy to clipboard operation
announcementcenter copied to clipboard

Generate Announcement from CLI/OCC

Open rijmenantspj opened this issue 7 years ago • 4 comments

Steps to reproduce

N/A

Expected behaviour

As a Request for Enhancement/Feature Request: As a Nextcloud admin, it would be helpful to be able to create announcements from the command line (for example via Nextcloud's OCC).

Actual behaviour

Announcements can, to my understanding, only be created from the Announcement Center.

Server configuration

Operating system: Ubuntu 18.04.2 LTS (Bionic Beaver)

Web server: Apache 2.4.29

Database: MariaDB 10.1.38

PHP version: PHP 7.2.15

Nextcloud version: 15.0.5

Where did you install Nextcloud from: Archive File (see https://nextcloud.com/install/#instructions-server)

Signing status: N/A

List of activated apps: N/A

Nextcloud configuration: N/A

Are you using an external user-backend, if yes which one: N/A

Client configuration

Browser: N/A

Operating system: N/A

Logs

N/A

Nextcloud log (data/owncloud.log)

N/A

Browser log

N/A

rijmenantspj avatar Mar 10 '19 09:03 rijmenantspj

Any news on this? This feature would be quite helpful in federated clusters and for any kind of automation involving downtimes and other changes which should be announced properly.

dhelonious avatar Mar 16 '23 16:03 dhelonious

https://github.com/nextcloud/announcementcenter#%EF%B8%8F-state-of-maintenance

If you manage to run a federated cluster maybe you could also sponsor a feature development?

nickvergessen avatar Mar 16 '23 16:03 nickvergessen

Thanks for the info, I totally overlooked that... I currently evaluate whether Nextcloud is feasable for our use case with up to 30k users. I imagine the announcement center being really useful for things like ToS and maintenance announcements, so one has not to build and rely on other communication infrastructures. If we want to move on with this project, we will approach your company and we will definately consider your suggestion!

dhelonious avatar Mar 17 '23 10:03 dhelonious

as a workaround you might use the rest api here and post at /api/v1/announcements, but you'll need an admin session. But I agree, a CLI would be nice, I'll check this out next PR!

According to https://docs.nextcloud.com/server/latest/developer_manual/server/externalapi.html#authentication-basics this should work

curl -X POST \
  -H "Content-Type: application/json" \
  --header "OCS-APIRequest: true" \
  -u adminUser:appToken \
  -d '{
    "subject": "Your Subject",
    "message": "Your Markdown Body",
    "plainMessage": "Your Plain Body",
    "groups": ["group1", "group2"],
    "activities": true,
    "notifications": true,
    "emails": true,
    "comments": true,
    "banner": true,
    "scheduleTime": null,
    "deleteTime": null
  }' \
  https://127.0.0.1/ocs/v2.php/apps/announcementcenter/api/v1/announcements?format=json

You might need to remove scheduleTime and deleteTime in your version

I tested this:

{"ocs":{"meta":{"status":"ok","statuscode":200,"message":"OK"},"data":{"id":24,"author_id":"nextcloud27","author":"nextcloud27","time":1710863883,"subject":"Your Subject","message":"Your Markdown Body","groups":[{"id":"everyone","name":"everyone"}],"comments":0,"schedule_time":null,"delete_time":null,"notifications":true}}}

mwinkens avatar Mar 19 '24 15:03 mwinkens