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 {
135
135
return err
136
136
}
137
137
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 )
144
139
})
145
140
146
141
switch err {
147
142
case nil :
148
143
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
153
163
default :
154
164
return errors .Wrap (err , "error saving new registration" )
155
165
}
You can’t perform that action at this time.
0 commit comments