commit 91a9c24dc39484f793605fcbf0ec2578d03ca581 Author: Brian Read Date: Fri Jul 18 06:34:00 2025 +0100 Initial commit for scripts diff --git a/AddAllMemeberstoSpecificChannels.sh b/AddAllMemeberstoSpecificChannels.sh new file mode 100755 index 0000000..456cc6a --- /dev/null +++ b/AddAllMemeberstoSpecificChannels.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +# --- BEGIN VARIABLES: SET THESE --- +ROCKET_CHAT_URL="https://chat.koozali.org" +TOKEN="LwSxku5012GVjT5GKukvCiAE3jmxzNREsJ3ZO87oP1D" +USER_ID="9RmjfwmQZc9pYrC9G" +CHANNELS_FILE="ChannelsToAddTo" +# --- END VARIABLES --- + +# Get all users (members) from Rocket.Chat +get_all_members() { + curl -s -X GET "$ROCKET_CHAT_URL/api/v1/users.list?count=1000" \ + -H "X-Auth-Token: $TOKEN" \ + -H "X-User-Id: $USER_ID" \ + -H "Content-Type: application/json" +} + +# Get all members of a channel +get_channel_members() { + local channel_id="$1" + curl -s -X GET "$ROCKET_CHAT_URL/api/v1/channels.members?roomId=$channel_id" \ + -H "X-Auth-Token: $TOKEN" \ + -H "X-User-Id: $USER_ID" \ + -H "Content-Type: application/json" +} + +# Add a single user to a channel +add_member_to_channel() { + local channel_id="$1" + local member_id="$2" + curl -s -X POST "$ROCKET_CHAT_URL/api/v1/channels.invite" \ + -H "X-Auth-Token: $TOKEN" \ + -H "X-User-Id: $USER_ID" \ + -H "Content-Type: application/json" \ + -d "{\"roomId\":\"$channel_id\", \"userId\":\"$member_id\"}" +} + +# MAIN SCRIPT +echo "Fetching ALL Rocket.Chat users..." +members_response=$(get_all_members) +member_ids=$(echo "$members_response" | jq -r '.users[] | select(.active == true) | ._id') +total_members=$(echo "$member_ids" | wc -w) +echo "Total members to add: $total_members" + +while read -r channel_name channel_id; do + echo "" + echo "Processing channel '$channel_name' ($channel_id)..." + # Get current members of this channel (as a bash array) + current_members=$(get_channel_members "$channel_id" | jq -r '.members[] | ._id') + # Add each member _only if not already in the channel_ + added=0 + already=0 + for member_id in $member_ids; do + if echo "$current_members" | grep -qx "$member_id"; then + echo " User $member_id is ALREADY a member of $channel_name" + ((already++)) + else + resp=$(add_member_to_channel "$channel_id" "$member_id") + if echo "$resp" | grep -q '"success":true'; then + echo " Added user $member_id to $channel_name" + ((added++)) + else + echo " Could NOT add $member_id to $channel_name: $(echo "$resp" | jq -c .)" + fi + fi + done + echo "$added members added, $already already present in $channel_name" +done < "$CHANNELS_FILE" \ No newline at end of file diff --git a/ChannelsToAddTo b/ChannelsToAddTo new file mode 100644 index 0000000..4de72bb --- /dev/null +++ b/ChannelsToAddTo @@ -0,0 +1,5 @@ +SME11-Contribs 66d099b1effca216c2ca2e74 +SME11-Server-Manager 66d16fbceffca216c2ca2f4e +general-it-news oJWcrQenLagQAnxhE +itjokes vbHqtbm3Ck9sJAHeA +testing-setup PEmWy7T8eQNSKHaXW diff --git a/channel list b/channel list new file mode 100755 index 0000000..42dd62f --- /dev/null +++ b/channel list @@ -0,0 +1,785 @@ +{ + "channels": [ + { + "_id": "66bdc31d984a39b87c64b400", + "fname": "Gitea", + "_updatedAt": "2024-09-03T14:27:30.110Z", + "customFields": {}, + "topic": "Gitea notifications", + "broadcast": false, + "encrypted": false, + "name": "Gitea", + "t": "c", + "msgs": 52, + "usersCount": 6, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john", + "name": "John Crisp" + }, + "ts": "2024-08-15T08:58:05.753Z", + "ro": false, + "sysMes": true, + "lm": "2024-09-03T14:27:30.050Z" + }, + { + "_id": "66d099b1effca216c2ca2e74", + "fname": "SME11-Contribs", + "_updatedAt": "2024-08-31T15:08:24.487Z", + "customFields": {}, + "topic": "Channel for discussion of the Contribs for SME11", + "broadcast": false, + "encrypted": false, + "name": "SME11-Contribs", + "t": "c", + "msgs": 15, + "usersCount": 6, + "u": { + "_id": "9RmjfwmQZc9pYrC9G", + "username": "brian.read", + "name": "Brian Read" + }, + "ts": "2024-08-29T15:54:25.079Z", + "ro": false, + "default": false, + "sysMes": true, + "lm": "2024-08-31T10:56:52.563Z" + }, + { + "_id": "66d16fbceffca216c2ca2f4e", + "fname": "SME11-Server-Manager", + "_updatedAt": "2024-09-02T19:56:22.063Z", + "customFields": {}, + "topic": "[SM2](https://wiki.koozali.org/Server_Manager2) - [Code a Contrib](https://wiki.koozali.org/Server_Manager2_create_panel_for_contrib) - [Bugs](https://bugs.koozali.org/buglist.cgi?classification=SME+Server&component=server-manager&query_format=advanced&resolution=---) - [Legacy Contribs](https://wiki.koozali.org/Server_Manager_2_Howto_incorporate_a_legacy_contrib#Introduction) [Translation](https://wiki.koozali.org/Language_translation_for_Server_Manager_2_in_SME11)", + "broadcast": false, + "encrypted": false, + "name": "SME11-Server-Manager", + "t": "c", + "msgs": 73, + "usersCount": 24, + "u": { + "_id": "9RmjfwmQZc9pYrC9G", + "username": "brian.read", + "name": "Brian Read" + }, + "ts": "2024-08-30T07:07:40.214Z", + "ro": false, + "default": false, + "sysMes": true, + "announcement": "", + "description": "For discussion of the Mojolicious based Server Manager which will be the default for SME11", + "lm": "2024-09-02T19:56:22.021Z" + }, + { + "_id": "JRZTKTSLwa6EHmwJy", + "name": "aepajttjrnnyw2zph", + "fname": "Server-Certificates", + "t": "c", + "msgs": 26, + "usersCount": 5, + "u": { + "_id": "AKxrunz4cFJjbnWCK", + "username": "jean" + }, + "topic": "sme-10-dev", + "prid": "qGy7pdqDfQFjsWsdv", + "ts": "2020-03-11T04:01:44.199Z", + "ro": false, + "_updatedAt": "2020-03-11T18:49:53.626Z", + "lm": "2020-03-11T18:49:53.610Z" + }, + { + "_id": "8QzKkJofMAdym9Ehx", + "fname": "AI and LLM", + "customFields": {}, + "description": "AI and LLM", + "broadcast": false, + "encrypted": false, + "name": "ai-and-llm", + "t": "c", + "msgs": 143, + "usersCount": 7, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "ts": "2023-09-16T14:08:29.060Z", + "ro": false, + "default": false, + "sysMes": true, + "_updatedAt": "2024-08-31T15:08:15.701Z", + "lm": "2024-08-31T15:08:15.654Z" + }, + { + "_id": "65bad253bacb671c87db27b2", + "fname": "authentication", + "_updatedAt": "2024-04-25T13:21:55.622Z", + "customFields": {}, + "broadcast": false, + "encrypted": false, + "name": "authentication", + "t": "c", + "msgs": 11, + "usersCount": 9, + "u": { + "_id": "AKxrunz4cFJjbnWCK", + "username": "jean", + "name": "Jean Phillipe Pialasse" + }, + "ts": "2024-01-31T23:05:55.296Z", + "ro": false, + "default": false, + "sysMes": true, + "lm": "2024-02-01T04:52:53.084Z", + "description": "Multi Factor Authentication + OAuth", + "topic": "Wiki pages?" + }, + { + "_id": "M666jDWW8RCef3Fts", + "fname": "Civil-Debate", + "customFields": {}, + "broadcast": false, + "encrypted": false, + "name": "civil-debate", + "t": "c", + "msgs": 144, + "usersCount": 4, + "u": { + "_id": "KAxzYv4kXuFtZePFB", + "username": "greg.zartman" + }, + "ts": "2023-03-09T03:01:21.996Z", + "ro": false, + "default": false, + "sysMes": true, + "_updatedAt": "2024-08-24T02:28:07.405Z", + "lm": "2024-08-23T04:08:55.152Z" + }, + { + "_id": "7soZXKPxPqhgvwNkD", + "fname": "Contrib-Affa", + "customFields": {}, + "description": "Discussions on Affa", + "broadcast": false, + "encrypted": false, + "name": "contrib-affa", + "t": "c", + "msgs": 2113, + "usersCount": 10, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "ts": "2021-11-30T13:02:52.129Z", + "ro": false, + "_updatedAt": "2024-08-29T17:23:32.511Z", + "lm": "2024-08-29T17:23:32.471Z", + "topic": "[Wiki](https://wiki.koozali.org/Affa]) - [Bugs](https://bugs.koozali.org/buglist.cgi?action=wrap&bug_status=UNCONFIRMED&bug_status=CONFIRMED&bug_status=NEEDINFO&bug_status=IN_PROGRESS&bug_status=RESOLVED&bug_status=VERIFIED&component=smeserver-affa&list_id=96472&product=SME%20Contribs&resolution=---&resolution=FIXED)" + }, + { + "_id": "JHry6usYFAhKoJAmc", + "name": "contrib-docker", + "fname": "Contrib-Docker", + "t": "c", + "msgs": 74, + "usersCount": 4, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "broadcast": false, + "encrypted": false, + "ts": "2021-02-25T16:25:48.923Z", + "ro": false, + "_updatedAt": "2023-09-16T14:12:54.379Z", + "lm": "2023-06-27T13:53:53.753Z" + }, + { + "_id": "25HxggAFGW7NmasTw", + "fname": "Contrib-FreePBX", + "customFields": {}, + "broadcast": false, + "encrypted": false, + "name": "contrib-freepbx", + "t": "c", + "msgs": 150, + "usersCount": 2, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "ts": "2023-10-18T17:46:25.889Z", + "ro": false, + "default": false, + "sysMes": true, + "_updatedAt": "2024-03-15T17:08:43.054Z", + "description": "Discussions on FreePBX/Asterisk", + "lm": "2024-03-15T17:00:08.592Z" + }, + { + "_id": "KKhG9Jsx9bzG63bR6", + "name": "contrib-l2tpd-ipsec", + "fname": "Contrib-L2TPD-Ipsec", + "t": "c", + "msgs": 565, + "usersCount": 3, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "broadcast": false, + "encrypted": false, + "ts": "2020-02-10T16:09:14.011Z", + "ro": false, + "_updatedAt": "2021-11-16T13:23:58.228Z", + "lm": "2021-11-16T13:23:58.217Z", + "description": "L2tpd+ipsec" + }, + { + "_id": "kDkmnganJftvcpZXH", + "fname": "Contrib-Nextcloud", + "customFields": {}, + "description": "Nextcloud issues", + "broadcast": false, + "encrypted": false, + "name": "contrib-nextcloud", + "t": "c", + "msgs": 644, + "usersCount": 7, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "ts": "2023-10-10T10:07:11.519Z", + "ro": false, + "default": false, + "sysMes": true, + "_updatedAt": "2024-06-03T14:33:11.373Z", + "lm": "2024-06-03T14:33:11.274Z" + }, + { + "_id": "ztFihJtgXcw4MfNRS", + "name": "contrib-zabbix", + "fname": "Contrib-Zabbix", + "t": "c", + "msgs": 55, + "usersCount": 4, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "broadcast": false, + "encrypted": false, + "ts": "2020-03-23T17:21:12.677Z", + "ro": false, + "_updatedAt": "2020-09-16T10:30:47.444Z", + "lm": "2020-09-16T10:30:47.433Z" + }, + { + "_id": "7qkchLuTzpC8Ff8GT", + "fname": "freepbx", + "topic": "sme10-contribs", + "prid": "FwQxBArDuJEGxyS6X", + "encrypted": false, + "name": "f9vrfsqge6xhpixxw", + "t": "c", + "msgs": 10, + "usersCount": 5, + "u": { + "_id": "AKxrunz4cFJjbnWCK", + "username": "jean" + }, + "ts": "2021-11-11T22:49:52.586Z", + "ro": false, + "_updatedAt": "2023-04-15T16:08:54.063Z", + "lm": "2022-01-09T18:57:51.988Z" + }, + { + "_id": "tijBfGJ5u9JHFadPe", + "name": "fr", + "fname": "fr", + "t": "c", + "msgs": 546, + "usersCount": 10, + "u": { + "_id": "AKxrunz4cFJjbnWCK", + "username": "jean" + }, + "customFields": {}, + "ts": "2019-07-23T02:27:58.828Z", + "ro": false, + "_updatedAt": "2024-05-16T09:22:55.810Z", + "lm": "2024-05-16T09:22:55.723Z" + }, + { + "_id": "hu8pyQH57ZjekaGti", + "name": "fxDQ5b4kGTxSMJ2Rx", + "fname": "Server- SSLCiphers", + "t": "c", + "msgs": 495, + "usersCount": 11, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "description": "SSL Settings", + "topic": "smestuff", + "prid": "NpatrG7JMmTZTaHiz", + "ts": "2019-08-11T11:05:31.161Z", + "ro": false, + "_updatedAt": "2020-05-05T14:56:31.076Z", + "lm": "2020-05-05T14:56:31.058Z" + }, + { + "_id": "oJWcrQenLagQAnxhE", + "name": "general-it-news", + "fname": "General IT News", + "t": "c", + "msgs": 2157, + "usersCount": 81, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "broadcast": false, + "encrypted": false, + "ts": "2021-04-15T16:10:41.418Z", + "ro": false, + "_updatedAt": "2024-08-29T06:56:37.563Z", + "lm": "2024-08-29T06:56:37.520Z", + "default": true + }, + { + "_id": "vbHqtbm3Ck9sJAHeA", + "fname": "ITjokes", + "customFields": {}, + "broadcast": false, + "encrypted": false, + "name": "itjokes", + "t": "c", + "msgs": 901, + "usersCount": 28, + "u": { + "_id": "AKxrunz4cFJjbnWCK", + "username": "jean" + }, + "ts": "2022-09-24T13:13:22.449Z", + "ro": false, + "default": true, + "sysMes": true, + "_updatedAt": "2024-09-01T00:51:57.540Z", + "lm": "2024-09-01T00:51:57.470Z" + }, + { + "_id": "N8MtxRk9jwy2aqc5r", + "name": "koozali", + "fname": "koozali", + "t": "c", + "msgs": 23, + "usersCount": 9, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "broadcast": false, + "encrypted": false, + "ts": "2018-11-21T23:05:51.683Z", + "ro": false, + "default": false, + "_updatedAt": "2023-01-27T20:44:56.268Z", + "lm": "2023-01-27T20:40:43.821Z" + }, + { + "_id": "3jhc9BHmGnkHvQRMB", + "fname": "Musicians", + "customFields": {}, + "broadcast": false, + "encrypted": false, + "name": "musicians", + "t": "c", + "msgs": 36, + "usersCount": 4, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "ts": "2023-07-09T18:50:50.450Z", + "ro": false, + "default": false, + "sysMes": true, + "_updatedAt": "2024-08-07T10:11:43.256Z", + "lm": "2024-04-27T19:38:06.444Z" + }, + { + "_id": "Etojc8c9m7MBsiQjN", + "name": "nig5vqr2prbffk28j", + "fname": "Docker", + "t": "c", + "msgs": 8, + "usersCount": 3, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "description": "Docker stuff", + "topic": "sme-10-dev", + "prid": "qGy7pdqDfQFjsWsdv", + "ts": "2020-03-10T20:17:36.548Z", + "ro": false, + "_updatedAt": "2021-11-15T19:13:53.599Z", + "lm": "2021-11-15T19:13:53.583Z" + }, + { + "_id": "oE7EE2NqXGS7PWGsS", + "name": "nrbda-4-trrhx-7-mwt-7-l", + "fname": "Contrib-Letsencrypt", + "t": "c", + "msgs": 375, + "usersCount": 9, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "description": "Testing letsencrypt and dehydrated", + "topic": "smestuff", + "prid": "NpatrG7JMmTZTaHiz", + "ts": "2020-01-30T09:41:57.785Z", + "ro": false, + "_updatedAt": "2024-05-10T05:23:58.782Z", + "lm": "2024-05-10T05:23:58.690Z" + }, + { + "_id": "ifzziBnsCGtdGFqhx", + "name": "publictest", + "fname": "publictest", + "t": "c", + "msgs": 177, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "ts": "2018-03-01T15:55:04.213Z", + "ro": false, + "_updatedAt": "2024-08-27T15:19:51.988Z", + "lm": "2024-07-18T15:11:59.500Z", + "usersCount": 14, + "topic": "Public Test Room", + "announcement": "Make an announcement" + }, + { + "_id": "9WfHLWjeLHH5oz2dp", + "name": "rw2tytj8yblma9mo2", + "fname": "Contrib-PHPKi", + "t": "c", + "msgs": 2941, + "usersCount": 7, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "description": "PHPKI", + "topic": "smestuff", + "prid": "NpatrG7JMmTZTaHiz", + "ts": "2020-03-03T10:47:10.746Z", + "ro": false, + "_updatedAt": "2024-08-27T15:21:16.753Z", + "lm": "2024-03-20T00:07:27.792Z" + }, + { + "_id": "qGy7pdqDfQFjsWsdv", + "name": "sme-10-dev", + "fname": "SME10-Dev", + "t": "c", + "msgs": 20365, + "usersCount": 58, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "broadcast": false, + "ts": "2019-11-05T10:10:58.817Z", + "ro": false, + "_updatedAt": "2024-08-28T21:44:46.026Z", + "lm": "2024-08-28T21:44:45.984Z", + "description": "SME v10 Development", + "topic": "Discussion on SMEv10 development\n- [v10 Bugs](https://bugs.contribs.org/report.cgi?x_axis_field=bug_status&y_axis_field=target_milestone&product=SME+Server+10.X&format=table&action=wrap)\n- [Reports](https://wiki.contribs.org/Bugzilla_Reports)\n- [RPM Building](https://wiki.contribs.org/Setting_up_RPM_Building_for_SME_Server)\n- [Releases](https://release.koozali.org/SMErepo)\n-[WIP Beta1 iso](https://wip.koozali.org/ThisIsSME10Beta1/)\n- for systemd dev see #SME-10-Dev-systemd", + "joinCodeRequired": false + }, + { + "_id": "6615815c9585c1e1f00d90a6", + "fname": "sme-authentication", + "_updatedAt": "2024-05-02T22:19:48.542Z", + "customFields": {}, + "broadcast": false, + "encrypted": false, + "name": "sme-authentication", + "t": "c", + "msgs": 908, + "usersCount": 4, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john", + "name": "John Crisp" + }, + "ts": "2024-04-09T17:56:44.034Z", + "ro": false, + "default": false, + "sysMes": true, + "lm": "2024-04-30T18:46:57.056Z" + }, + { + "_id": "XEth9kepPo8fFv5hH", + "name": "sme-documentation", + "fname": "SME-Documentation", + "t": "c", + "msgs": 1172, + "usersCount": 24, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "broadcast": false, + "encrypted": false, + "ts": "2020-03-27T09:56:25.399Z", + "ro": false, + "_updatedAt": "2024-08-15T21:13:56.928Z", + "topic": "Discuss Wiki documentation - \n[Wiki](https://wiki.contribs.org)\n - [Overall bugs](https://bugs.contribs.org/describecomponents.cgi?product=SME%20Server%20Documentation)\n- [All Doc bugs](https://bugs.contribs.org/buglist.cgi?action=wrap&f1=bug_status&list_id=89632&o1=notequals&product=SME%20Server%20Documentation&v1=CLOSED)\n - [Wiki bugs](https://bugs.contribs.org/buglist.cgi?product=SME%20Server%20Documentation&component=Wiki&resolution=---)\n- [Releases](https://release.koozali.org/SMErepo)", + "lm": "2023-06-24T06:07:23.282Z" + }, + { + "_id": "JbDMkLtxDb7KZgiar", + "fname": "SME-IPv6", + "customFields": {}, + "description": "Discussions on IPv6 implementation in SME", + "broadcast": false, + "encrypted": false, + "name": "sme-ipv6", + "t": "c", + "msgs": 325, + "usersCount": 7, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "ts": "2022-09-25T21:46:28.727Z", + "ro": false, + "default": false, + "sysMes": true, + "_updatedAt": "2024-08-28T18:30:52.715Z", + "lm": "2024-08-23T09:12:17.278Z", + "joinCodeRequired": false, + "topic": "- [IPv6 bug](https://bugs.koozali.org/show_bug.cgi?id=6393) - [IPv6 Wiki](https://wiki.koozali.org/IPv6)" + }, + { + "_id": "FwQxBArDuJEGxyS6X", + "name": "sme10-contribs", + "fname": "SME10-Contribs", + "t": "c", + "msgs": 19312, + "usersCount": 61, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "broadcast": false, + "encrypted": false, + "ts": "2020-03-13T00:04:01.598Z", + "ro": false, + "_updatedAt": "2024-08-31T18:32:53.412Z", + "lm": "2024-08-31T18:32:53.384Z", + "topic": "SME v10 contribs - [Bugs](https://bugs.contribs.org/describecomponents.cgi?product=SME%20Contribs)\n- [Matrix](https://bugs.contribs.org/report.cgi?x_axis_field=bug_status&y_axis_field=product&f1=bug_status&o1=notequals&v1=CLOSED&query_format=report-table&format=table&action=wrap)\n- [Table](https://bugs.contribs.org/report.cgi?x_axis_field=bug_status&y_axis_field=component&z_axis_field=&no_redirect=1&query_format=report-table&short_desc_type=allwordssubstr&short_desc=&product=SME+Contribs&bug_status=UNCONFIRMED&bug_status=CONFIRMED&bug_status=NEEDINFO&bug_status=IN_PROGRESS&bug_status=RESOLVED&bug_status=VERIFIED&resolution=---&resolution=FIXED&longdesc_type=allwordssubstr&longdesc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&bug_id=&bug_id_type=anyexact&emailtype1=substring&email1=&emailtype2=substring&email2=&emailtype3=substring&email3=&chfieldvalue=&chfieldfrom=&chfieldto=Now&j_top=AND&f1=noop&o1=noop&v1=&format=table&action=wrap)\n- [QA](https://wiki.contribs.org/Category:Contribs_QA)\n- [Contribs QA](https://wiki.contribs.org/SME10.0_Contribs_QA)\n- [Contribs Status Spreadsheet](https://docs.google.com/spreadsheets/d/1J4z70lzTM0bkkgWTVDH8F4Ll5_IuNJIQDmU8ArliyI0/edit?ts=5fa13787#gid=0)\n", + "description": "Discussion of SME v10 contribs\n", + "jitsiTimeout": "2023-01-24T22:14:08.058Z", + "default": true + }, + { + "_id": "wPZZEGuAwv2Db5NNd", + "name": "sme10-dev-systemd", + "fname": "SME10-Dev-systemd", + "t": "c", + "msgs": 1366, + "usersCount": 10, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "broadcast": false, + "encrypted": false, + "ts": "2020-09-24T09:24:04.658Z", + "ro": false, + "_updatedAt": "2024-01-10T05:51:51.142Z", + "lm": "2024-01-10T05:51:51.077Z" + }, + { + "_id": "CyKuf22GMjffGBX7p", + "fname": "SME11-Dev", + "customFields": {}, + "description": "get ready for SME11 .. start brainstorming", + "broadcast": false, + "encrypted": false, + "name": "sme11-dev", + "t": "c", + "msgs": 3445, + "usersCount": 21, + "u": { + "_id": "AKxrunz4cFJjbnWCK", + "username": "jean" + }, + "ts": "2022-07-18T04:07:29.703Z", + "ro": false, + "default": true, + "sysMes": true, + "_updatedAt": "2024-09-03T04:22:55.914Z", + "lm": "2024-09-03T04:22:55.817Z", + "joinCodeRequired": false, + "announcement": "", + "topic": "SME 11 dev chat : [Install Test](https://wiki.koozali.org/Sme11BuildQueue#Bare_install_test) - \n[GIT](https://src.koozali.org/smeserver) - \n[Bugs to fix](https://bugs.koozali.org/buglist.cgi?action=wrap&product=SME%20Server%2011.X&target_milestone=11.alpha1&bug_status=CONFIRMED) - \n[Bugs to verify](https://bugs.koozali.org/buglist.cgi?action=wrap&product=SME%20Server%2011.X&target_milestone=11.alpha1&bug_status=RESOLVED)" + }, + { + "_id": "DZK2sAB3Cw3BGLSto", + "fname": "SMEServer Gitea", + "customFields": {}, + "description": "About the use of git and gitea in building SMEServer", + "broadcast": false, + "encrypted": false, + "name": "smeserver-gitea", + "t": "c", + "msgs": 3368, + "usersCount": 10, + "u": { + "_id": "9RmjfwmQZc9pYrC9G", + "username": "brian.read" + }, + "ts": "2023-02-22T09:13:19.647Z", + "ro": false, + "default": false, + "sysMes": true, + "_updatedAt": "2024-08-16T04:57:29.282Z", + "lm": "2024-08-09T00:05:02.763Z", + "e2eKeyId": "eyJrdHkiOiJv" + }, + { + "_id": "NpatrG7JMmTZTaHiz", + "name": "smestuff", + "fname": "smestuff", + "t": "c", + "msgs": 44047, + "usersCount": 92, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "broadcast": false, + "encrypted": false, + "ts": "2018-11-12T20:48:21.667Z", + "ro": false, + "default": true, + "_updatedAt": "2024-09-03T03:46:26.318Z", + "lm": "2024-09-03T03:46:26.270Z", + "topic": "General Chat \n- [Forums](https://forums.contribs.org) \n- [Wiki](https://wiki.contribs.org)\n- [Bugs](https://bugs.contribs.org) \n- [Design](https://wiki.koozali.org/SME_Server:Documentation:Developers_Manual)", + "announcement": "", + "description": "", + "jitsiTimeout": "2023-03-06T02:11:17.889Z", + "muted": [], + "unmuted": [ + "greg.zartman" + ] + }, + { + "_id": "BkyYDrp4EsfHxprxC", + "fname": "#tasting", + "customFields": {}, + "broadcast": false, + "encrypted": false, + "name": "tasting", + "t": "c", + "msgs": 311, + "usersCount": 10, + "u": { + "_id": "AKxrunz4cFJjbnWCK", + "username": "jean" + }, + "ts": "2023-04-22T00:50:25.565Z", + "ro": false, + "default": false, + "sysMes": true, + "_updatedAt": "2024-09-02T19:39:12.735Z", + "lm": "2024-09-02T19:39:12.690Z" + }, + { + "_id": "PEmWy7T8eQNSKHaXW", + "name": "testing-setup", + "fname": "Testing-Setup", + "t": "c", + "msgs": 9411, + "usersCount": 57, + "u": { + "_id": "SRX9MQ7EBJZeauYn4", + "username": "chris.s-n" + }, + "customFields": {}, + "broadcast": false, + "encrypted": false, + "ts": "2020-03-15T16:23:24.030Z", + "ro": false, + "_updatedAt": "2024-09-03T15:06:39.300Z", + "lm": "2024-09-03T15:06:39.265Z", + "description": "Channel to discuss testing", + "topic": "- [QA](https://wiki.contribs.org/SME_Server:Documentation:QA:Verification)- [SME10 QA](https://wiki.contribs.org/SME10.0_QA)- [v10 Verification](https://bugs.contribs.org/buglist.cgi?action=wrap&bug_status=RESOLVED&f1=bug_status&list_id=89651&o1=notequals&product=SME%20Server%2010.X&v1=CLOSED)- [ALL Verification](https://bugs.contribs.org/buglist.cgi?action=wrap&bug_status=RESOLVED&f1=bug_status&list_id=89650&o1=notequals&v1=CLOSED)- [Setups](https://wiki.contribs.org/Testing_Environments)- [Releases](https://release.koozali.org/SMErepo)- [DevManual](https://wiki.contribs.org/SME_Server:Documentation:Developers_Manual)- [Contribs Spreadsheet](https://docs.google.com/spreadsheets/d/1J4z70lzTM0bkkgWTVDH8F4Ll5_IuNJIQDmU8ArliyI0/edit?ts=5fa13787#gid=0) - [SME v11](https://wiki.koozali.org/Sme11BuildQueue#Bare_install_test)" + }, + { + "_id": "fhtGwDE8Ti7izvbSX", + "name": "wineandbeer", + "fname": "WineAndBeer", + "t": "c", + "msgs": 89, + "usersCount": 2, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "customFields": {}, + "broadcast": false, + "encrypted": false, + "ts": "2020-03-13T14:12:19.132Z", + "ro": false, + "_updatedAt": "2020-12-11T22:01:40.745Z", + "lm": "2020-12-11T22:01:40.676Z" + }, + { + "_id": "X2Wk3W5taM9PJYP4R", + "name": "zuACrkFd3DM6fTu5R", + "fname": "Server-Manager 2 - read only", + "t": "c", + "msgs": 2983, + "usersCount": 26, + "u": { + "_id": "hYHbjXWQMSRMu2szG", + "username": "john" + }, + "description": "To discuss the development of a replacement for the FormMagick version of server manager, based on Mojolicious.", + "topic": "[SM2](https://wiki.koozali.org/Server_Manager2) - [Code a Contrib](https://wiki.koozali.org/Server_Manager2_create_panel_for_contrib) - [Bugs](https://bugs.koozali.org/buglist.cgi?classification=SME+Server&component=server-manager&query_format=advanced&resolution=---) - [Legacy Contribs](https://wiki.koozali.org/Server_Manager_2_Howto_incorporate_a_legacy_contrib#Introduction) [Translation](https://wiki.koozali.org/Language_translation_for_Server_Manager_2_in_SME11)", + "prid": "NpatrG7JMmTZTaHiz", + "ts": "2019-07-06T10:20:07.041Z", + "ro": false, + "_updatedAt": "2024-08-30T07:11:19.045Z", + "lm": "2024-08-30T07:06:19.103Z", + "avatarETag": "1708598149723" + } + ], + "count": 37, + "offset": 0, + "total": 37, + "success": true +} diff --git a/channelList b/channelList new file mode 100644 index 0000000..4404c85 --- /dev/null +++ b/channelList @@ -0,0 +1,42 @@ +Bugzilla 677e99393ddf8049989dbcb7 +Gitea 66bdc31d984a39b87c64b400 +Koji-New-Builds 677e8e453ddf8049989dbc73 +SME11-Contribs 66d099b1effca216c2ca2e74 +SME11-Server-Manager 66d16fbceffca216c2ca2f4e +SME11-Server-Manager-AdminLTE 67ebbb22157c10705d0a93ee +Tasting BkyYDrp4EsfHxprxC +Wiki 67b770851f56a124fa47d994 +aepajttjrnnyw2zph JRZTKTSLwa6EHmwJy +ai-and-llm 8QzKkJofMAdym9Ehx +authentication 65bad253bacb671c87db27b2 +civil-debate M666jDWW8RCef3Fts +contrib-affa 7soZXKPxPqhgvwNkD +contrib-docker JHry6usYFAhKoJAmc +contrib-freepbx 25HxggAFGW7NmasTw +contrib-l2tpd-ipsec KKhG9Jsx9bzG63bR6 +contrib-nextcloud kDkmnganJftvcpZXH +contrib-zabbix ztFihJtgXcw4MfNRS +f9vrfsqge6xhpixxw 7qkchLuTzpC8Ff8GT +fr tijBfGJ5u9JHFadPe +fxDQ5b4kGTxSMJ2Rx hu8pyQH57ZjekaGti +general-it-news oJWcrQenLagQAnxhE +itjokes vbHqtbm3Ck9sJAHeA +koozali N8MtxRk9jwy2aqc5r +musicians 3jhc9BHmGnkHvQRMB +nig5vqr2prbffk28j Etojc8c9m7MBsiQjN +nrbda-4-trrhx-7-mwt-7-l oE7EE2NqXGS7PWGsS +publictest ifzziBnsCGtdGFqhx +rw2tytj8yblma9mo2 9WfHLWjeLHH5oz2dp +sme-10-dev qGy7pdqDfQFjsWsdv +sme-documentation XEth9kepPo8fFv5hH +sme-ipv6 JbDMkLtxDb7KZgiar +sme-samba-ad-dc 6615815c9585c1e1f00d90a6 +sme10-contribs FwQxBArDuJEGxyS6X +sme10-dev-systemd wPZZEGuAwv2Db5NNd +sme11-dev CyKuf22GMjffGBX7p +smeserver-gitea DZK2sAB3Cw3BGLSto +smestuff NpatrG7JMmTZTaHiz +testing-setup PEmWy7T8eQNSKHaXW +wineandbeer fhtGwDE8Ti7izvbSX +zkxbCgqhtbbvwRdnw 67101492d5ee027c9ca09d21 +zuACrkFd3DM6fTu5R X2Wk3W5taM9PJYP4R diff --git a/getRocketHChanneHistory.sh b/getRocketHChanneHistory.sh new file mode 100755 index 0000000..935bdbf --- /dev/null +++ b/getRocketHChanneHistory.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# Variables +ROCKET_CHAT_URL="https:///chat.koozali.org" # Replace with your Rocket.Chat URL +TOKEN="LwSxku5012GVjT5GKukvCiAE3jmxzNREsJ3ZO87oP1D" # Replace with your user token +DISCUSSION_ID="X2Wk3W5taM9PJYP4R" # Replace with the discussion ID +CHANNEL_ID="66bdc31d984a39b87c64b400" # Replace with the channel ID +USER_ID="9RmjfwmQZc9pYrC9G" + +# Function to fetch channel history +fetch_channel_history() { + response=$(curl --request GET --url "$ROCKET_CHAT_URL/channels.history?roomName=Gitea" \ + -H "X-Auth-Token: $TOKEN" \ + -H "X-User-Id: $USER_ID" \ + -H "Content-Type: application/json") + + echo "Channel History:" + echo "$response" +} + + +get_channel_list() { + curl -s -X GET "$ROCKET_CHAT_URL/api/v1/channels.list" \ + -H "X-Auth-Token: $TOKEN" \ + -H "X-User-Id: $USER_ID" \ + -H "Content-Type: application/json" +} + +# Main Logic +#channels=$(get_channel_list) +#echo $channels +#exit 1 + +fetch_channel_history diff --git a/getRocketMembers.sh b/getRocketMembers.sh new file mode 100644 index 0000000..119cfdd --- /dev/null +++ b/getRocketMembers.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# Variables +ROCKET_CHAT_URL="https:///chat.koozali.org" # Replace with your Rocket.Chat URL +TOKEN="LwSxku5012GVjT5GKukvCiAE3jmxzNREsJ3ZO87oP1D" # Replace with your user token +DISCUSSION_ID="X2Wk3W5taM9PJYP4R" # Replace with the discussion ID +CHANNEL_ID="66d16fbceffca216c2ca2f4e" # Replace with the channel ID +USER_ID="9RmjfwmQZc9pYrC9G" + +# Function to get members from the discussion +get_discussion_members() { + curl -s -X GET "$ROCKET_CHAT_URL/api/v1/channels.members?roomId=$DISCUSSION_ID" \ + -H "X-Auth-Token: $TOKEN" \ + -H "X-User-Id: $USER_ID" \ + -H "Content-Type: application/json" +} + +# Function to add a member to the channel +add_member_to_channel() { + local member_id=$1 + curl -s -X POST "$ROCKET_CHAT_URL/api/v1/channels.invite" \ + -H "X-Auth-Token: $TOKEN" \ + -H "X-User-Id: $USER_ID" \ + -H "Content-Type: application/json" \ + -d "{\"roomId\":\"$CHANNEL_ID\", \"userId\":\"$member_id\"}" +} + +get_channel_list() { + curl -s -X GET "$ROCKET_CHAT_URL/api/v1/channels.list" \ + -H "X-Auth-Token: $TOKEN" \ + -H "X-User-Id: $USER_ID" \ + -H "Content-Type: application/json" +} + +# Main Logic +channels=$(get_channel_list) +echo $channels +#exit 0 +#channel_names=$(echo "$channels" | jq -r '.channels[]._id') +channel_names=$(echo "$channels" | jq -r '.channels[] | "\(._id) \(.fname)"' | tr ' ' '\n' | grep SME11) +for name in $channel_names; do + echo $name +done + + +#exit 0 + +# Fetch the members +members_response=$(get_discussion_members) +echo $members_response +exit 0 + +# Parse the user IDs from the response (you might need to modify this according to the API response structure) +member_ids=$(echo "$members_response" | jq -r '.members[]._id') +echo $member_ids + +# Iterate over each member and add them to the specified channel +i=0 +for member_id in $member_ids; do + echo $member_id + add_member_to_channel "$member_id" + echo "Added member $member_id to channel" + #exit 1 + ((i++)) +done + +echo "$i members added to the channel." \ No newline at end of file diff --git a/getRocketRoomMemberMatrix.sh b/getRocketRoomMemberMatrix.sh new file mode 100755 index 0000000..b3568e7 --- /dev/null +++ b/getRocketRoomMemberMatrix.sh @@ -0,0 +1,72 @@ +#!/bin/bash + +# Variables +ROCKET_CHAT_URL="https://chat.koozali.org" # Replace with your Rocket.Chat URL +TOKEN="LwSxku5012GVjT5GKukvCiAE3jmxzNREsJ3ZO87oP1D" # Replace with your user token +USER_ID="9RmjfwmQZc9pYrC9G" + +# Function to get a list of channels +get_channel_list() { + curl -s -X GET "$ROCKET_CHAT_URL/api/v1/channels.list" \ + -H "X-Auth-Token: $TOKEN" \ + -H "X-User-Id: $USER_ID" \ + -H "Content-Type: application/json" +} + +# Function to get members in a given room +get_members_in_channel() { + local channel_id=$1 + curl -s -X GET "$ROCKET_CHAT_URL/api/v1/channels.members?roomId=$channel_id" \ + -H "X-Auth-Token: $TOKEN" \ + -H "X-User-Id: $USER_ID" \ + -H "Content-Type: application/json" +} + +# Main Logic +channels=$(get_channel_list) + +# Check if the channel list request was successful +if echo "$channels" | jq -e . >/dev/null; then + # Create an array to store channel information + mapfile -t channel_array < <(echo "$channels" | jq -c '.channels[] | {id: ._id, name: .fname}') + + # Print header + echo -e "Channel Name \t\t\t Members" + echo -e "--------------\t\t\t-----------------------------" + + # Iterate over each channel from the array + for channel in "${channel_array[@]}"; do + channel_id=$(echo "$channel" | jq -r '.id') + channel_name=$(echo "$channel" | jq -r '.name') + + # Check if channel_id and channel_name were extracted correctly + if [[ -z "$channel_id" || -z "$channel_name" ]]; then + echo "Warning: Channel ID or Name is empty. Channel data: $channel" + continue + fi + + #echo "Fetching members for channel: $channel_name (ID: $channel_id)" # Debugging line + + # Get members for this channel + members_response=$(get_members_in_channel "$channel_id") + + # Output the raw response for debugging + #echo "Members Response: $members_response" + + # Check if the members response is valid + if echo "$members_response" | jq -e . >/dev/null; then + member_ids=$(echo "$members_response" | jq -r '.members[].username // empty') # Capture usernames + + # Create a members list + member_list=$(echo "$member_ids" | tr '\n' ', ' | sed 's/, $//') # Join members with a comma + echo -e "$channel_name \t\t\t $member_list" + else + echo "$channel_name | Unable to fetch members or no members found" + fi + done +else + echo "Failed to retrieve channels or invalid response." + echo "$channels" # Print the actual response for debugging +fi + +echo "Done."