Skip to content

Commit 85b383e

Browse files
author
jeffyanta
authored
Retweets don't count for Twitter registrations (#112)
1 parent b06dfe5 commit 85b383e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/code/async/user/twitter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ func (p *service) findNewRegistrationTweets(ctx context.Context) ([]*twitter_lib
254254
}
255255

256256
func (p *service) findVerifiedTipAccountRegisteredInTweet(ctx context.Context, tweet *twitter_lib.Tweet) (*common.Account, *uuid.UUID, error) {
257+
if tweet.IsRetweet() {
258+
return nil, nil, errTwitterRegistrationNotFound
259+
}
260+
257261
tweetParts := strings.Fields(tweet.Text)
258262
for _, tweetPart := range tweetParts {
259263
// Look for the well-known prefix to indicate a potential registration value

pkg/twitter/client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"io"
99
"net/http"
1010
"net/url"
11+
"strings"
1112
"sync"
1213
"time"
1314

@@ -306,6 +307,11 @@ func (c *Client) getBearerToken(clientId, clientSecret string) (string, error) {
306307
return result.AccessToken, nil
307308
}
308309

310+
// IsRetweet returns whether the tweet is a retweet
311+
func (t *Tweet) IsRetweet() bool {
312+
return strings.HasPrefix(t.Text, "RT @")
313+
}
314+
309315
type twitterError struct {
310316
Title string `json:"title"`
311317
Detail string `json:"detail"`

0 commit comments

Comments
 (0)