Encrypted channels

This commit is contained in:
2024-05-12 22:00:22 +08:00
parent 13fcc64f79
commit 18af7eae81
5 changed files with 27 additions and 36 deletions

View File

@ -134,11 +134,12 @@ func ListAvailableChannel(user models.Account, realmId ...uint) ([]models.Channe
return channels, nil
}
func NewChannel(user models.Account, alias, name, description string, realmId ...uint) (models.Channel, error) {
func NewChannel(user models.Account, alias, name, description string, isEncrypted bool, realmId ...uint) (models.Channel, error) {
channel := models.Channel{
Alias: alias,
Name: name,
Description: description,
IsEncrypted: isEncrypted,
AccountID: user.ID,
Members: []models.ChannelMember{
{AccountID: user.ID},
@ -153,10 +154,13 @@ func NewChannel(user models.Account, alias, name, description string, realmId ..
return channel, err
}
func EditChannel(channel models.Channel, alias, name, description string) (models.Channel, error) {
func EditChannel(channel models.Channel, alias, name, description string, isEncrypted bool) (models.Channel, error) {
channel.Alias = alias
channel.Name = name
channel.Description = description
if !channel.IsEncrypted {
channel.IsEncrypted = isEncrypted
}
err := database.C.Save(&channel).Error