Browse Source

fix #404

tags/v1.1.0-rc1
Shivaram Lingamneni 5 years ago
parent
commit
1121e3d320
3 changed files with 8 additions and 1 deletions
  1. 4
    0
      irc/accounts.go
  2. 1
    0
      irc/errors.go
  3. 3
    1
      irc/hostserv.go

+ 4
- 0
irc/accounts.go View File

@@ -1108,6 +1108,10 @@ func (am *AccountManager) VHostReject(account string, reason string) (result VHo
1108 1108
 
1109 1109
 func (am *AccountManager) VHostSetEnabled(client *Client, enabled bool) (result VHostInfo, err error) {
1110 1110
 	munger := func(input VHostInfo) (output VHostInfo, err error) {
1111
+		if input.ApprovedVHost == "" {
1112
+			err = errNoVhost
1113
+			return
1114
+		}
1111 1115
 		output = input
1112 1116
 		output.Enabled = enabled
1113 1117
 		return

+ 1
- 0
irc/errors.go View File

@@ -44,6 +44,7 @@ var (
44 44
 	errFeatureDisabled                = errors.New(`That feature is disabled`)
45 45
 	errBanned                         = errors.New("IP or nickmask banned")
46 46
 	errInvalidParams                  = utils.ErrInvalidParams
47
+	errNoVhost                        = errors.New(`You do not have an approved vhost`)
47 48
 )
48 49
 
49 50
 // Socket Errors

+ 3
- 1
irc/hostserv.go View File

@@ -154,7 +154,9 @@ func hsOnOffHandler(server *Server, client *Client, command string, params []str
154 154
 	}
155 155
 
156 156
 	_, err := server.accounts.VHostSetEnabled(client, enable)
157
-	if err != nil {
157
+	if err == errNoVhost {
158
+		hsNotice(rb, client.t(err.Error()))
159
+	} else if err != nil {
158 160
 		hsNotice(rb, client.t("An error occurred"))
159 161
 	} else if enable {
160 162
 		hsNotice(rb, client.t("Successfully enabled your vhost"))

Loading…
Cancel
Save