Skip to content
Permalink
Browse files

Proof services: AllStringKeys -> StringKey (#15306)

* proof services: AllStringKeys -> StringKey

* yes it should
  • Loading branch information...
mlsteele committed Jan 4, 2019
1 parent 331ba38 commit 69b3ee25b7874b27cc258e1a1b8a44b2f04ebe46
@@ -80,7 +80,7 @@ func newIdentify2WithUIDTester(g *libkb.GlobalContext) *Identify2WithUIDTester {

func (i *Identify2WithUIDTester) ListProofCheckers() []string { return nil }
func (i *Identify2WithUIDTester) ListServicesThatAcceptNewProofs() []string { return nil }
func (i *Identify2WithUIDTester) AllStringKeys() []string { return nil }
func (i *Identify2WithUIDTester) Key() string { return i.GetTypeName() }
func (i *Identify2WithUIDTester) CheckProofText(text string, id keybase1.SigID, sig string) error {
return nil
}
@@ -42,7 +42,7 @@ func (rc *DNSChecker) CheckStatus(m libkb.MetaContext, h libkb.SigHint, pcm libk

type DNSServiceType struct{ libkb.BaseServiceType }

func (t *DNSServiceType) AllStringKeys() []string { return t.BaseAllStringKeys(t) }
func (t *DNSServiceType) Key() string { return t.GetTypeName() }

func (t *DNSServiceType) NormalizeUsername(s string) (string, error) {
if !libkb.IsValidHostname(s) {
@@ -39,7 +39,7 @@ func (rc *FacebookChecker) CheckStatus(mctx libkb.MetaContext, h libkb.SigHint,

type FacebookServiceType struct{ libkb.BaseServiceType }

func (t *FacebookServiceType) AllStringKeys() []string { return t.BaseAllStringKeys(t) }
func (t *FacebookServiceType) Key() string { return t.GetTypeName() }

var facebookUsernameRegexp = regexp.MustCompile(`^(?i:[a-z0-9.]{1,50})$`)

@@ -242,7 +242,7 @@ func NewGenericSocialProofServiceType(config *GenericSocialProofConfig) *Generic
}
}

func (t *GenericSocialProofServiceType) AllStringKeys() []string { return t.BaseAllStringKeys(t) }
func (t *GenericSocialProofServiceType) Key() string { return t.GetTypeName() }

func (t *GenericSocialProofServiceType) NormalizeUsername(s string) (string, error) {
if err := t.config.validateRemoteUsername(s); err != nil {
@@ -39,7 +39,7 @@ func (rc *GithubChecker) CheckStatus(mctx libkb.MetaContext, h libkb.SigHint, _

type GithubServiceType struct{ libkb.BaseServiceType }

func (t *GithubServiceType) AllStringKeys() []string { return t.BaseAllStringKeys(t) }
func (t *GithubServiceType) Key() string { return t.GetTypeName() }

var githubUsernameRegexp = regexp.MustCompile(`^(?i:[a-z0-9][a-z0-9-]{0,38})$`)

@@ -57,7 +57,7 @@ func CheckKarma(mctx libkb.MetaContext, un string) (int, error) {

type HackerNewsServiceType struct{ libkb.BaseServiceType }

func (t *HackerNewsServiceType) AllStringKeys() []string { return t.BaseAllStringKeys(t) }
func (t *HackerNewsServiceType) Key() string { return t.GetTypeName() }

var hackerNewsUsernameRegexp = regexp.MustCompile(`^(?i:[a-z0-9_-]{2,15})$`)

@@ -84,7 +84,7 @@ func urlReencode(s string) string {

type RedditServiceType struct{ libkb.BaseServiceType }

func (t *RedditServiceType) AllStringKeys() []string { return t.BaseAllStringKeys(t) }
func (t *RedditServiceType) Key() string { return t.GetTypeName() }

var redditUsernameRegexp = regexp.MustCompile(`^(?i:[a-z0-9_-]{3,20})$`)

@@ -41,7 +41,7 @@ func (rc *RooterChecker) CheckStatus(mctx libkb.MetaContext, h libkb.SigHint, _

type RooterServiceType struct{ libkb.BaseServiceType }

func (t *RooterServiceType) AllStringKeys() []string { return t.BaseAllStringKeys(t) }
func (t *RooterServiceType) Key() string { return t.GetTypeName() }

var rooterUsernameRegexp = regexp.MustCompile(`^(?i:[a-z0-9_]{1,20})$`)

@@ -39,7 +39,7 @@ func (rc *TwitterChecker) CheckStatus(mctx libkb.MetaContext, h libkb.SigHint, _

type TwitterServiceType struct{ libkb.BaseServiceType }

func (t *TwitterServiceType) AllStringKeys() []string { return t.BaseAllStringKeys(t) }
func (t *TwitterServiceType) Key() string { return t.GetTypeName() }

var twitterUsernameRegexp = regexp.MustCompile(`^(?i:[a-z0-9_]{1,20})$`)

@@ -59,11 +59,11 @@ type WebServiceType struct {
scheme string
}

func (t *WebServiceType) AllStringKeys() []string {
func (t *WebServiceType) Key() string {
if t.scheme == "" {
return []string{"web"}
return "web"
}
return []string{t.scheme}
return t.scheme
}

func (t *WebServiceType) NormalizeUsername(s string) (ret string, err error) {
@@ -36,9 +36,7 @@ func (p *staticProofServices) register(services []libkb.ServiceType) {
if !useDevelProofCheckers && st.IsDevelOnly() {
continue
}
for _, k := range st.AllStringKeys() {
p.externalServices[k] = st
}
p.externalServices[st.Key()] = st
}
}

@@ -95,9 +93,7 @@ func (p *proofServices) registerServiceTypes(services []libkb.ServiceType) {
if !useDevelProofCheckers && st.IsDevelOnly() {
continue
}
for _, k := range st.AllStringKeys() {
p.externalServices[k] = st
}
p.externalServices[st.Key()] = st
}
}

@@ -559,7 +559,7 @@ type ProofChecker interface {
// ServiceType is an interface for describing an external proof service, like 'Twitter'
// or 'GitHub', etc.
type ServiceType interface {
AllStringKeys() []string
Key() string

// NormalizeUsername normalizes the given username, assuming
// that it's free of any leading strings like '@' or 'dns://'.
@@ -43,13 +43,11 @@ func (r *RemoteProofLinks) Insert(link RemoteProofChainLink, err ProofError) {
// ForService returns all the active proof links for a service.
func (r *RemoteProofLinks) ForService(st ServiceType) []RemoteProofChainLink {
var links []RemoteProofChainLink
for _, k := range st.AllStringKeys() {
for _, l := range r.links[k] {
if l.link.IsRevoked() {
continue
}
links = append(links, l.link)
for _, l := range r.links[st.Key()] {
if l.link.IsRevoked() {
continue
}
links = append(links, l.link)
}

// Chop the array off if it's a last-writer wins service
@@ -84,10 +84,6 @@ func (t *BaseServiceType) BaseGetProofType(st ServiceType) string {
return "web_service_binding." + st.GetTypeName()
}

func (t *BaseServiceType) BaseAllStringKeys(st ServiceType) []string {
return []string{st.GetTypeName()}
}

func (t *BaseServiceType) LastWriterWins() bool { return true }
func (t *BaseServiceType) PreProofCheck(MetaContext, string) (*Markup, error) { return nil, nil }
func (t *BaseServiceType) PreProofWarning(remotename string) *Markup { return nil }

0 comments on commit 69b3ee2

Please sign in to comment.
You can’t perform that action at this time.