Skip to content

Commit

Permalink
Fix twitter repost (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-dionysos authored Jan 24, 2024
1 parent 0f527e2 commit 4e90bf6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker v25.0.0+incompatible // indirect
github.com/docker/docker v25.0.1+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
Expand Down
25 changes: 25 additions & 0 deletions kyc/social/internal/social_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,31 @@ func TestTwitterKYC(t *testing.T) {
})
}

func TestTwitterKYCNoRepost(t *testing.T) {
t.Parallel()

const (
expectedText = `✅ Verifying my account on @ice_blockchain with the nickname: "john"`
targetURL = `https://twitter.com/JohnDoe1495747/status/1750103621184700443`
)

conf := loadConfig()
require.NotNil(t, conf)

sc := newMustWebScraper(conf.WebScrapingAPI.URL, conf.WebScrapingAPI.APIKey)
require.NotNil(t, sc)

verifier := newTwitterVerifier(sc, []string{"twitter.com"}, []string{"US", "MX", "CA"})
require.NotNil(t, verifier)

ctx, cancel := context.WithTimeout(context.TODO(), time.Minute)
defer cancel()

username, err := verifier.VerifyPost(ctx, &Metadata{PostURL: targetURL, ExpectedPostText: expectedText})
require.NoError(t, err)
require.Equal(t, "JohnDoe1495747", username)
}

func TestTwitterPrivate(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion kyc/social/internal/twitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (t *twitterVerifierImpl) VerifyContent(ctx context.Context, oe *twitterOE,
return ErrTextNotFound
}

if !t.VerifyPostLink(ctx, doc, expextedPostURL) {
if expextedPostURL != "" && !t.VerifyPostLink(ctx, doc, expextedPostURL) {
return ErrPostNotFound
}

Expand Down
3 changes: 0 additions & 3 deletions kyc/social/social.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ func (r *repository) VerifyPost(ctx context.Context, metadata *VerificationMetad
ExpectedPostText: metadata.expectedPostText(user.User),
ExpectedPostURL: r.expectedPostURL(metadata),
}
if pvm.ExpectedPostURL == "" {
log.Warn(fmt.Sprintf("post url not found for KYCStep:%v,Social:%v", metadata.KYCStep, metadata.Social))
}
if true { // Because we want to be less strict, for the moment.
pvm.ExpectedPostText = fmt.Sprintf("%q", user.Username)
}
Expand Down

0 comments on commit 4e90bf6

Please sign in to comment.