瀏覽代碼

refactor some conditions for clarity

tags/v1.0.0-rc1
Shivaram Lingamneni 5 年之前
父節點
當前提交
35948d2e5b
共有 1 個文件被更改,包括 7 次插入7 次删除
  1. 7
    7
      irc/accounts.go

+ 7
- 7
irc/accounts.go 查看文件

@@ -213,13 +213,18 @@ func (am *AccountManager) EnforcementStatus(cfnick, skeleton string) (account st
213 213
 	skelAccount := am.skeletonToAccount[skeleton]
214 214
 	if nickAccount == "" && skelAccount == "" {
215 215
 		return "", NickReservationNone
216
-	} else if nickAccount != "" && skelAccount != "" && nickAccount != skelAccount {
216
+	} else if nickAccount != "" && (skelAccount == nickAccount || skelAccount == "") {
217
+		return nickAccount, finalEnforcementMethod(nickAccount)
218
+	} else if skelAccount != "" && nickAccount == "" {
219
+		return skelAccount, finalEnforcementMethod(skelAccount)
220
+	} else {
221
+		// nickAccount != skelAccount and both are nonempty:
217 222
 		// two people have competing claims on (this casefolding of) this nick!
218 223
 		nickMethod := finalEnforcementMethod(nickAccount)
219 224
 		skelMethod := finalEnforcementMethod(skelAccount)
220 225
 		switch {
221 226
 		case nickMethod == NickReservationNone && skelMethod == NickReservationNone:
222
-			return "", NickReservationNone
227
+			return nickAccount, NickReservationNone
223 228
 		case skelMethod == NickReservationNone:
224 229
 			return nickAccount, nickMethod
225 230
 		case nickMethod == NickReservationNone:
@@ -228,12 +233,7 @@ func (am *AccountManager) EnforcementStatus(cfnick, skeleton string) (account st
228 233
 			// nobody can use this nick
229 234
 			return "!", NickReservationStrict
230 235
 		}
231
-	} else if nickAccount == "" && skelAccount != "" {
232
-		// skeleton owner is the only owner; fall through to normal case
233
-		nickAccount = skelAccount
234 236
 	}
235
-	// else: nickAccount != "" && skelAccount == "", nickAccount is the only owner
236
-	return nickAccount, finalEnforcementMethod(nickAccount)
237 237
 }
238 238
 
239 239
 // Looks up the enforcement method stored in the database for an account

Loading…
取消
儲存