From 1121e3d320e8e749352d5d642fdde8687e1f8822 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Tue, 21 May 2019 23:55:04 -0400 Subject: [PATCH] fix #404 --- irc/accounts.go | 4 ++++ irc/errors.go | 1 + irc/hostserv.go | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/irc/accounts.go b/irc/accounts.go index 81dfecb4..8815d886 100644 --- a/irc/accounts.go +++ b/irc/accounts.go @@ -1108,6 +1108,10 @@ func (am *AccountManager) VHostReject(account string, reason string) (result VHo func (am *AccountManager) VHostSetEnabled(client *Client, enabled bool) (result VHostInfo, err error) { munger := func(input VHostInfo) (output VHostInfo, err error) { + if input.ApprovedVHost == "" { + err = errNoVhost + return + } output = input output.Enabled = enabled return diff --git a/irc/errors.go b/irc/errors.go index df47f8d2..6cbe55bf 100644 --- a/irc/errors.go +++ b/irc/errors.go @@ -44,6 +44,7 @@ var ( errFeatureDisabled = errors.New(`That feature is disabled`) errBanned = errors.New("IP or nickmask banned") errInvalidParams = utils.ErrInvalidParams + errNoVhost = errors.New(`You do not have an approved vhost`) ) // Socket Errors diff --git a/irc/hostserv.go b/irc/hostserv.go index cc81fbb6..698830e3 100644 --- a/irc/hostserv.go +++ b/irc/hostserv.go @@ -154,7 +154,9 @@ func hsOnOffHandler(server *Server, client *Client, command string, params []str } _, err := server.accounts.VHostSetEnabled(client, enable) - if err != nil { + if err == errNoVhost { + hsNotice(rb, client.t(err.Error())) + } else if err != nil { hsNotice(rb, client.t("An error occurred")) } else if enable { hsNotice(rb, client.t("Successfully enabled your vhost"))