mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-25 21:39:25 +01:00
Merge pull request #718 from slingamn/cstransfer_improvements
better UX for cancelling channel transfers
This commit is contained in:
commit
5cb4a8fc42
@ -780,6 +780,7 @@ func (am *AccountManager) LoadAccount(accountName string) (result ClientAccount,
|
|||||||
}
|
}
|
||||||
|
|
||||||
result, err = am.deserializeRawAccount(raw)
|
result, err = am.deserializeRawAccount(raw)
|
||||||
|
result.NameCasefolded = casefoldedAccount
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1366,8 +1367,8 @@ type AccountSettings struct {
|
|||||||
// ClientAccount represents a user account.
|
// ClientAccount represents a user account.
|
||||||
type ClientAccount struct {
|
type ClientAccount struct {
|
||||||
// Name of the account.
|
// Name of the account.
|
||||||
Name string
|
Name string
|
||||||
// RegisteredAt represents the time that the account was registered.
|
NameCasefolded string
|
||||||
RegisteredAt time.Time
|
RegisteredAt time.Time
|
||||||
Credentials AccountCredentials
|
Credentials AccountCredentials
|
||||||
Verified bool
|
Verified bool
|
||||||
|
@ -98,7 +98,8 @@ To prevent accidental transfers, a verification code is required. For
|
|||||||
example, $bTRANSFER #channel alice$b displays the required confirmation
|
example, $bTRANSFER #channel alice$b displays the required confirmation
|
||||||
code, then $bTRANSFER #channel alice 2930242125$b initiates the transfer.
|
code, then $bTRANSFER #channel alice 2930242125$b initiates the transfer.
|
||||||
Unless you are an IRC operator with the correct permissions, alice must
|
Unless you are an IRC operator with the correct permissions, alice must
|
||||||
then accept the transfer, which she can do with $bTRANSFER accept #channel$b.`,
|
then accept the transfer, which she can do with $bTRANSFER accept #channel$b.
|
||||||
|
To cancel a pending transfer, transfer the channel to yourself.`,
|
||||||
helpShort: `$bTRANSFER$b transfers ownership of a channel to another user.`,
|
helpShort: `$bTRANSFER$b transfers ownership of a channel to another user.`,
|
||||||
enabled: chanregEnabled,
|
enabled: chanregEnabled,
|
||||||
minParams: 2,
|
minParams: 2,
|
||||||
@ -418,17 +419,19 @@ func csTransferHandler(server *Server, client *Client, command string, params []
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
target := params[1]
|
target := params[1]
|
||||||
_, err := server.accounts.LoadAccount(params[1])
|
targetAccount, err := server.accounts.LoadAccount(params[1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
csNotice(rb, client.t("Account does not exist"))
|
csNotice(rb, client.t("Account does not exist"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
expectedCode := unregisterConfirmationCode(regInfo.Name, regInfo.RegisteredAt)
|
if targetAccount.NameCasefolded != account {
|
||||||
codeValidated := 2 < len(params) && params[2] == expectedCode
|
expectedCode := unregisterConfirmationCode(regInfo.Name, regInfo.RegisteredAt)
|
||||||
if !codeValidated {
|
codeValidated := 2 < len(params) && params[2] == expectedCode
|
||||||
csNotice(rb, ircfmt.Unescape(client.t("$bWarning: you are about to transfer control of your channel to another user.$b")))
|
if !codeValidated {
|
||||||
csNotice(rb, fmt.Sprintf(client.t("To confirm your channel transfer, type: /CS TRANSFER %[1]s %[2]s %[3]s"), chname, target, expectedCode))
|
csNotice(rb, ircfmt.Unescape(client.t("$bWarning: you are about to transfer control of your channel to another user.$b")))
|
||||||
return
|
csNotice(rb, fmt.Sprintf(client.t("To confirm your channel transfer, type: /CS TRANSFER %[1]s %[2]s %[3]s"), chname, target, expectedCode))
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
status, err := channel.Transfer(client, target, hasPrivs)
|
status, err := channel.Transfer(client, target, hasPrivs)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user