mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
fix(irc): append invite command on add (#297)
This commit is contained in:
parent
ffada19506
commit
df7a51d479
3 changed files with 32 additions and 0 deletions
|
@ -560,3 +560,26 @@ func (r *IrcRepo) UpdateChannel(channel *domain.IrcChannel) error {
|
|||
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *IrcRepo) UpdateInviteCommand(networkID int64, invite string) error {
|
||||
|
||||
// update record
|
||||
channelQueryBuilder := r.db.squirrel.
|
||||
Update("irc_network").
|
||||
Set("invite_command", invite).
|
||||
Where("id = ?", networkID)
|
||||
|
||||
query, args, err := channelQueryBuilder.ToSql()
|
||||
if err != nil {
|
||||
r.log.Error().Stack().Err(err).Msg("irc.UpdateInviteCommand: error building query")
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = r.db.handler.Exec(query, args...)
|
||||
if err != nil {
|
||||
r.log.Error().Stack().Err(err).Msg("irc.UpdateInviteCommand: error executing query")
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ type IrcRepo interface {
|
|||
UpdateNetwork(ctx context.Context, network *IrcNetwork) error
|
||||
StoreChannel(networkID int64, channel *IrcChannel) error
|
||||
UpdateChannel(channel *IrcChannel) error
|
||||
UpdateInviteCommand(networkID int64, invite string) error
|
||||
StoreNetworkChannels(ctx context.Context, networkID int64, channels []IrcChannel) error
|
||||
CheckExistingNetwork(ctx context.Context, network *IrcNetwork) (*IrcNetwork, error)
|
||||
FindActiveNetworks(ctx context.Context) ([]IrcNetwork, error)
|
||||
|
|
|
@ -556,6 +556,14 @@ func (s *service) StoreNetwork(ctx context.Context, network *domain.IrcNetwork)
|
|||
existingNetwork.Channels = append(existingNetwork.Channels, network.Channels...)
|
||||
}
|
||||
|
||||
// append invite command for existing network
|
||||
if network.InviteCommand != "" {
|
||||
existingNetwork.InviteCommand = strings.Join([]string{existingNetwork.InviteCommand, network.InviteCommand}, ",")
|
||||
if err := s.repo.UpdateInviteCommand(existingNetwork.ID, existingNetwork.InviteCommand); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if existingNetwork.Enabled {
|
||||
// if server, tls, invite command, port : changed - restart
|
||||
// if nickserv account, nickserv password : changed - stay connected, and change those
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue