mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 11:42:25 -05:00 
			
		
		
		
	[bugfix] Queue implicit accepts *before* other side effects (#4282)
This PR just fiddles with the order in which we process status create / boost / fave side effects and implicit acceptances. The goal is to try to make sure the Accept message gets sent to a remote instance *before* the interaction with an implicitly accepted status. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4282 Co-authored-by: tobi <tobi.smethurst@protonmail.com> Co-committed-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
		
					parent
					
						
							
								bfc8c31e5f
							
						
					
				
			
			
				commit
				
					
						38ff88f006
					
				
			
		
					 3 changed files with 36 additions and 33 deletions
				
			
		|  | @ -130,15 +130,6 @@ func (p *Processor) BoostCreate( | ||||||
| 		return nil, gtserror.NewErrorInternalError(err) | 		return nil, gtserror.NewErrorInternalError(err) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Process side effects asynchronously. |  | ||||||
| 	p.state.Workers.Client.Queue.Push(&messages.FromClientAPI{ |  | ||||||
| 		APObjectType:   ap.ActivityAnnounce, |  | ||||||
| 		APActivityType: ap.ActivityCreate, |  | ||||||
| 		GTSModel:       boost, |  | ||||||
| 		Origin:         requester, |  | ||||||
| 		Target:         target.Account, |  | ||||||
| 	}) |  | ||||||
| 
 |  | ||||||
| 	// If the boost target status replies to a status | 	// If the boost target status replies to a status | ||||||
| 	// that we own, and has a pending interaction | 	// that we own, and has a pending interaction | ||||||
| 	// request, use the boost as an implicit accept. | 	// request, use the boost as an implicit accept. | ||||||
|  | @ -156,6 +147,16 @@ func (p *Processor) BoostCreate( | ||||||
| 		target.PendingApproval = util.Ptr(false) | 		target.PendingApproval = util.Ptr(false) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	// Queue remaining boost side effects | ||||||
|  | 	// (send out boost, update timeline, etc). | ||||||
|  | 	p.state.Workers.Client.Queue.Push(&messages.FromClientAPI{ | ||||||
|  | 		APObjectType:   ap.ActivityAnnounce, | ||||||
|  | 		APActivityType: ap.ActivityCreate, | ||||||
|  | 		GTSModel:       boost, | ||||||
|  | 		Origin:         requester, | ||||||
|  | 		Target:         target.Account, | ||||||
|  | 	}) | ||||||
|  | 
 | ||||||
| 	return p.c.GetAPIStatus(ctx, requester, boost) | 	return p.c.GetAPIStatus(ctx, requester, boost) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -275,21 +275,6 @@ func (p *Processor) Create( | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	var model any = status |  | ||||||
| 	if backfill { |  | ||||||
| 		// We specifically wrap backfilled statuses in |  | ||||||
| 		// a different type to signal to worker process. |  | ||||||
| 		model = >smodel.BackfillStatus{Status: status} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	// Send it to the client API worker for async side-effects. |  | ||||||
| 	p.state.Workers.Client.Queue.Push(&messages.FromClientAPI{ |  | ||||||
| 		APObjectType:   ap.ObjectNote, |  | ||||||
| 		APActivityType: ap.ActivityCreate, |  | ||||||
| 		GTSModel:       model, |  | ||||||
| 		Origin:         requester, |  | ||||||
| 	}) |  | ||||||
| 
 |  | ||||||
| 	// If the new status replies to a status that | 	// If the new status replies to a status that | ||||||
| 	// replies to us, use our reply as an implicit | 	// replies to us, use our reply as an implicit | ||||||
| 	// accept of any pending interaction. | 	// accept of any pending interaction. | ||||||
|  | @ -307,6 +292,22 @@ func (p *Processor) Create( | ||||||
| 		status.InReplyTo.PendingApproval = util.Ptr(false) | 		status.InReplyTo.PendingApproval = util.Ptr(false) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	var model any = status | ||||||
|  | 	if backfill { | ||||||
|  | 		// We specifically wrap backfilled statuses in | ||||||
|  | 		// a different type to signal to worker process. | ||||||
|  | 		model = >smodel.BackfillStatus{Status: status} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// Queue remaining create side effects | ||||||
|  | 	// (send out status, update timeline, etc). | ||||||
|  | 	p.state.Workers.Client.Queue.Push(&messages.FromClientAPI{ | ||||||
|  | 		APObjectType:   ap.ObjectNote, | ||||||
|  | 		APActivityType: ap.ActivityCreate, | ||||||
|  | 		GTSModel:       model, | ||||||
|  | 		Origin:         requester, | ||||||
|  | 	}) | ||||||
|  | 
 | ||||||
| 	return p.c.GetAPIStatus(ctx, requester, status) | 	return p.c.GetAPIStatus(ctx, requester, status) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -160,15 +160,6 @@ func (p *Processor) FaveCreate( | ||||||
| 		return nil, gtserror.NewErrorInternalError(err) | 		return nil, gtserror.NewErrorInternalError(err) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Process new status fave side effects. |  | ||||||
| 	p.state.Workers.Client.Queue.Push(&messages.FromClientAPI{ |  | ||||||
| 		APObjectType:   ap.ActivityLike, |  | ||||||
| 		APActivityType: ap.ActivityCreate, |  | ||||||
| 		GTSModel:       gtsFave, |  | ||||||
| 		Origin:         requester, |  | ||||||
| 		Target:         status.Account, |  | ||||||
| 	}) |  | ||||||
| 
 |  | ||||||
| 	// If the fave target status replies to a status | 	// If the fave target status replies to a status | ||||||
| 	// that we own, and has a pending interaction | 	// that we own, and has a pending interaction | ||||||
| 	// request, use the fave as an implicit accept. | 	// request, use the fave as an implicit accept. | ||||||
|  | @ -186,6 +177,16 @@ func (p *Processor) FaveCreate( | ||||||
| 		status.PendingApproval = util.Ptr(false) | 		status.PendingApproval = util.Ptr(false) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	// Queue remaining fave side effects | ||||||
|  | 	// (send out fave, update timeline, etc). | ||||||
|  | 	p.state.Workers.Client.Queue.Push(&messages.FromClientAPI{ | ||||||
|  | 		APObjectType:   ap.ActivityLike, | ||||||
|  | 		APActivityType: ap.ActivityCreate, | ||||||
|  | 		GTSModel:       gtsFave, | ||||||
|  | 		Origin:         requester, | ||||||
|  | 		Target:         status.Account, | ||||||
|  | 	}) | ||||||
|  | 
 | ||||||
| 	return p.c.GetAPIStatus(ctx, requester, status) | 	return p.c.GetAPIStatus(ctx, requester, status) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue