nextcloud / announcementcenter

📢 Announcement Center for Nextcloud
https://apps.nextcloud.com/apps/announcementcenter
GNU Affero General Public License v3.0
39 stars 24 forks source link

Generate Announcement from CLI/OCC #147

Closed rijmenantspj closed 1 week ago

rijmenantspj commented 5 years ago

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

dhelonious commented 1 year ago

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.

nickvergessen commented 1 year ago

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?

dhelonious commented 1 year ago

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!

mwinkens commented 6 months ago

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}}}