File tree Expand file tree Collapse file tree 1 file changed +20
-10
lines changed
Expand file tree Collapse file tree 1 file changed +20
-10
lines changed Original file line number Diff line number Diff line change @@ -135,21 +135,31 @@ func (p *service) processNewTwitterRegistrations(ctx context.Context) error {
135135 return err
136136 }
137137
138- err = p .data .MarkTweetAsProcessed (ctx , tweet .ID )
139- if err != nil {
140- return err
141- }
142-
143- return nil
138+ return p .data .MarkTweetAsProcessed (ctx , tweet .ID )
144139 })
145140
146141 switch err {
147142 case nil :
148143 go push_util .SendTwitterAccountConnectedPushNotification (ctx , p .data , p .pusher , tipAccount )
149- case twitter .ErrDuplicateTipAddress , twitter .ErrDuplicateNonce :
150- // Any race conditions with duplicate nonces or tip addresses will are ignored
151- //
152- // todo: In the future, support multiple tip address mappings
144+ case twitter .ErrDuplicateTipAddress :
145+ err = p .data .ExecuteInTx (ctx , sql .LevelDefault , func (ctx context.Context ) error {
146+ err = p .data .MarkTwitterNonceAsUsed (ctx , tweet .ID , * registrationNonce )
147+ if err != nil {
148+ return err
149+ }
150+
151+ return p .data .MarkTweetAsProcessed (ctx , tweet .ID )
152+ })
153+ if err != nil {
154+ return errors .Wrap (err , "error saving tweet with duplicate tip address metadata" )
155+ }
156+ return nil
157+ case twitter .ErrDuplicateNonce :
158+ err = p .data .MarkTweetAsProcessed (ctx , tweet .ID )
159+ if err != nil {
160+ return errors .Wrap (err , "error marking tweet with duplicate nonce as processed" )
161+ }
162+ return nil
153163 default :
154164 return errors .Wrap (err , "error saving new registration" )
155165 }
You can’t perform that action at this time.
0 commit comments