@@ -137,6 +137,7 @@ func (p *service) findNewTwitterRegistrations(ctx context.Context) error {
137137 continue
138138 }
139139
140+ // Attempt to find a tip account from the registration tweet
140141 tipAccount , err := findTipAccountRegisteredInTweet (tweet )
141142 switch err {
142143 case nil :
@@ -146,6 +147,20 @@ func (p *service) findNewTwitterRegistrations(ctx context.Context) error {
146147 return errors .Wrapf (err , "unexpected error processing tweet %s" , tweet .ID )
147148 }
148149
150+ // Validate the new tip account
151+ accountInfoRecord , err := p .data .GetAccountInfoByTokenAddress (ctx , tipAccount .PublicKey ().ToBase58 ())
152+ switch err {
153+ case nil :
154+ // todo: potentially use a relationship account instead
155+ if accountInfoRecord .AccountType != commonpb .AccountType_PRIMARY {
156+ continue
157+ }
158+ case account .ErrAccountInfoNotFound :
159+ continue
160+ default :
161+ return errors .Wrap (err , "error getting account info" )
162+ }
163+
149164 processedUsernames [tweet .AdditionalMetadata .Author .Username ] = struct {}{}
150165
151166 err = p .updateCachedTwitterUser (ctx , tweet .AdditionalMetadata .Author , tipAccount )
@@ -197,21 +212,6 @@ func (p *service) updateCachedTwitterUser(ctx context.Context, user *twitter_lib
197212 mu .Lock ()
198213 defer mu .Unlock ()
199214
200- // Validate the new tip account if it's provided
201- if newTipAccount != nil {
202- accountInfoRecord , err := p .data .GetAccountInfoByTokenAddress (ctx , newTipAccount .PublicKey ().ToBase58 ())
203- switch err {
204- case nil :
205- if accountInfoRecord .AccountType != commonpb .AccountType_PRIMARY {
206- return nil
207- }
208- case account .ErrAccountInfoNotFound :
209- return nil
210- default :
211- return errors .Wrap (err , "error getting account info" )
212- }
213- }
214-
215215 record , err := p .data .GetTwitterUser (ctx , user .Username )
216216 switch err {
217217 case twitter .ErrUserNotFound :
0 commit comments