Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix twitter repost #110

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading