How does the Administrator make categories the same for everyone?
For example, if I put in Channel 1, Channel 2 & Channel 3 in Category My Category, then I want new member to have this category, including the three channels, visible in the sidebar.
You can do that with an onboardingscript which creates the categories and adds the channels for the user in the sidebar via the API, but that requires you to know when people join or to prepare their accounts before first use, not sure if this is an option.
There’s a feature which never really worked for me and is called “Default channels” which can be used to add all new users to a list of channels you specify in the server configuration. Using this feature combined with the feature “Channel actions”, you can automatically put the channels into categories for the users, at least during provisioning, but the users can change that, so you cannot enforce this configuration on them if they want to change it (or leave channels, f.ex.) and they can also rename their categories.
Would something like that help or do you require more control on what your users see and can do to their view?
The onboardingscript is nothing you can find online, it’s more a hint that you would need something like that.
I wrote a script for someone on the community server some time ago, which should give you an idea on how to proceed. If not, let me know how we can fine-tune it to your needs:
#!/bin/bash
# space separated list of channels to add for each user
CHANNELS="writing_work lab_work cyber_342w_homework_help general_ist_homework_help off_topic"
# team to add the users to
TEAM="cyber-342w"
# the maildomain added to the username
MAILDOMAIN="school.edu"
# mmctl command
MMCTL="mmctl --local"
# password to be used for all accounts. Leave empty and set PWLEN > 0 if you want passwords to be auto-generated
PASSWORD=""
PWLEN=16
# set to empty string if you want to actually run the commands, set to "echo" if you just want to see what woule be done
DEBUG="echo"
# first parameter of the script will be the file to read the input data from
# if no parameter is given or if the file cannot be found, fail
if [ -z "$1" ] || ! [ -f "$1" ]; then
echo "input file $1 not found."
exit 1
fi
while read line; do
# split the input line by space into parts
IFS=" " read -r -a PARTS <<< "$line"
# generate random password if requested
[ "$PWLEN" -gt "0" ] && PASSWORD=$(makepasswd --chars=$PWLEN)
# create the user account
$DEBUG $MMCTL user create --email "${PARTS[0]}@$MAILDOMAIN" --email-verified --firstname ${PARTS[1]} --lastname ${PARTS[2]} --locale en --password $PASSWORD --username ${PARTS[0]}
# add it to all mentioned channels
for channel in $CHANNELS; do
$DEBUG $MMCTL channel users add $TEAM:$channel ${PARTS[0]}
done
# output user + password for copy/pasting it to the users
echo "${PARTS[0]} / $PASSWORD"
done < "$1"
This script reads in a CSV of users to create and sets them up automatically and also adds them to a list of predefined channels.
The categories can be done using channel actions, as I said - so in your existing channels, you can click on the channel and choose “Channel actions” which will give you the following modal:
Here you can specify the category to add this channel to and when the category does not exist, it will be created on the fly for the user that joined the channel.
Meanwhile, I checked out the API Documentation and simply could not find a way to add a channel to a specific category or assign a category to a specific channel.
That’s because a channel does not belong to a sidebar category. The categories are part of the user’s view, so every user could have his own categories, that’s why you cannot configure that by channel.
Yes, I understand, but there must be a way to move a channel into a specific category, for that particular user. The database has some kind of connection there, as well, to know, which channel ought to be shown under which category.
Seen that one, but it does not let me assign channels to it, by user or something equivalent to that functionality.
Now, I need the same thing, except the other way around. I want to send a payload, patching an existing sidebar category to include all channel IDs from the provided array.
As it turns out, providing the channel IDs via UpdateSidebarCategoriesForTeamForUser was already possible – it’s just, that the API documentation is incomplete.
So, if anyone wants to move a channel from one category to another, one must fetch both categories, remove the channel IDs in question from the current category & add them to the channel ID list of the new category. Then, PUT the category array to https://your-mattermost-url.com/api/v4/users/{user_id}/teams/{team_id}/channels/categories & the channel is moved, after the user reloaded the Mattermost page in the browser.
The more people request such a feature on Mattermost’s product board, the more likely we will see it, so please raise your voice on https://mattermost.com/suggestions for such a feature.
@agriesser@Akito
Based on a recent support ticket, I was told that this API exists, but looks like it hasn’t been documented yet. The “Channel Actions” mentioned here can be done graphically, but to do it via API you need to use this:
https:/<url>/plugins/playbooks/api/v0/actions/channels/<channel id>
with a JSON payload of: