mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-29 04:12:25 -05:00 
			
		
		
		
	Pg to bun (#148)
* start moving to bun * changing more stuff * more * and yet more * tests passing * seems stable now * more big changes * small fix * little fixes
This commit is contained in:
		
					parent
					
						
							
								071eca20ce
							
						
					
				
			
			
				commit
				
					
						2dc9fc1626
					
				
			
		
					 713 changed files with 98694 additions and 22704 deletions
				
			
		|  | @ -19,6 +19,7 @@ | |||
| package processing | ||||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"net/url" | ||||
|  | @ -29,7 +30,7 @@ import ( | |||
| 	"github.com/superseriousbusiness/gotosocial/internal/id" | ||||
| ) | ||||
| 
 | ||||
| func (p *processor) processFromFederator(federatorMsg gtsmodel.FromFederator) error { | ||||
| func (p *processor) processFromFederator(ctx context.Context, federatorMsg gtsmodel.FromFederator) error { | ||||
| 	l := p.log.WithFields(logrus.Fields{ | ||||
| 		"func":         "processFromFederator", | ||||
| 		"federatorMsg": fmt.Sprintf("%+v", federatorMsg), | ||||
|  | @ -48,16 +49,16 @@ func (p *processor) processFromFederator(federatorMsg gtsmodel.FromFederator) er | |||
| 				return errors.New("note was not parseable as *gtsmodel.Status") | ||||
| 			} | ||||
| 
 | ||||
| 			status, err := p.federator.EnrichRemoteStatus(federatorMsg.ReceivingAccount.Username, incomingStatus) | ||||
| 			status, err := p.federator.EnrichRemoteStatus(ctx, federatorMsg.ReceivingAccount.Username, incomingStatus) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 
 | ||||
| 			if err := p.timelineStatus(status); err != nil { | ||||
| 			if err := p.timelineStatus(ctx, status); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 
 | ||||
| 			if err := p.notifyStatus(status); err != nil { | ||||
| 			if err := p.notifyStatus(ctx, status); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		case gtsmodel.ActivityStreamsProfile: | ||||
|  | @ -70,7 +71,7 @@ func (p *processor) processFromFederator(federatorMsg gtsmodel.FromFederator) er | |||
| 				return errors.New("like was not parseable as *gtsmodel.StatusFave") | ||||
| 			} | ||||
| 
 | ||||
| 			if err := p.notifyFave(incomingFave, federatorMsg.ReceivingAccount); err != nil { | ||||
| 			if err := p.notifyFave(ctx, incomingFave, federatorMsg.ReceivingAccount); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		case gtsmodel.ActivityStreamsFollow: | ||||
|  | @ -80,7 +81,7 @@ func (p *processor) processFromFederator(federatorMsg gtsmodel.FromFederator) er | |||
| 				return errors.New("incomingFollowRequest was not parseable as *gtsmodel.FollowRequest") | ||||
| 			} | ||||
| 
 | ||||
| 			if err := p.notifyFollowRequest(incomingFollowRequest, federatorMsg.ReceivingAccount); err != nil { | ||||
| 			if err := p.notifyFollowRequest(ctx, incomingFollowRequest, federatorMsg.ReceivingAccount); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		case gtsmodel.ActivityStreamsAnnounce: | ||||
|  | @ -90,7 +91,7 @@ func (p *processor) processFromFederator(federatorMsg gtsmodel.FromFederator) er | |||
| 				return errors.New("announce was not parseable as *gtsmodel.Status") | ||||
| 			} | ||||
| 
 | ||||
| 			if err := p.federator.DereferenceAnnounce(incomingAnnounce, federatorMsg.ReceivingAccount.Username); err != nil { | ||||
| 			if err := p.federator.DereferenceAnnounce(ctx, incomingAnnounce, federatorMsg.ReceivingAccount.Username); err != nil { | ||||
| 				return fmt.Errorf("error dereferencing announce from federator: %s", err) | ||||
| 			} | ||||
| 
 | ||||
|  | @ -100,17 +101,17 @@ func (p *processor) processFromFederator(federatorMsg gtsmodel.FromFederator) er | |||
| 			} | ||||
| 			incomingAnnounce.ID = incomingAnnounceID | ||||
| 
 | ||||
| 			if err := p.db.PutStatus(incomingAnnounce); err != nil { | ||||
| 			if err := p.db.PutStatus(ctx, incomingAnnounce); err != nil { | ||||
| 				if err != db.ErrNoEntries { | ||||
| 					return fmt.Errorf("error adding dereferenced announce to the db: %s", err) | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			if err := p.timelineStatus(incomingAnnounce); err != nil { | ||||
| 			if err := p.timelineStatus(ctx, incomingAnnounce); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 
 | ||||
| 			if err := p.notifyAnnounce(incomingAnnounce); err != nil { | ||||
| 			if err := p.notifyAnnounce(ctx, incomingAnnounce); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		case gtsmodel.ActivityStreamsBlock: | ||||
|  | @ -121,10 +122,10 @@ func (p *processor) processFromFederator(federatorMsg gtsmodel.FromFederator) er | |||
| 			} | ||||
| 
 | ||||
| 			// remove any of the blocking account's statuses from the blocked account's timeline, and vice versa | ||||
| 			if err := p.timelineManager.WipeStatusesFromAccountID(block.AccountID, block.TargetAccountID); err != nil { | ||||
| 			if err := p.timelineManager.WipeStatusesFromAccountID(ctx, block.AccountID, block.TargetAccountID); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 			if err := p.timelineManager.WipeStatusesFromAccountID(block.TargetAccountID, block.AccountID); err != nil { | ||||
| 			if err := p.timelineManager.WipeStatusesFromAccountID(ctx, block.TargetAccountID, block.AccountID); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 			// TODO: same with notifications | ||||
|  | @ -145,7 +146,7 @@ func (p *processor) processFromFederator(federatorMsg gtsmodel.FromFederator) er | |||
| 				return err | ||||
| 			} | ||||
| 
 | ||||
| 			if _, _, err := p.federator.GetRemoteAccount(federatorMsg.ReceivingAccount.Username, incomingAccountURI, true); err != nil { | ||||
| 			if _, _, err := p.federator.GetRemoteAccount(ctx, federatorMsg.ReceivingAccount.Username, incomingAccountURI, true); err != nil { | ||||
| 				return fmt.Errorf("error dereferencing account from federator: %s", err) | ||||
| 			} | ||||
| 		} | ||||
|  | @ -165,25 +166,25 @@ func (p *processor) processFromFederator(federatorMsg gtsmodel.FromFederator) er | |||
| 
 | ||||
| 			// delete all attachments for this status | ||||
| 			for _, a := range statusToDelete.AttachmentIDs { | ||||
| 				if err := p.mediaProcessor.Delete(a); err != nil { | ||||
| 				if err := p.mediaProcessor.Delete(ctx, a); err != nil { | ||||
| 					return err | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			// delete all mentions for this status | ||||
| 			for _, m := range statusToDelete.MentionIDs { | ||||
| 				if err := p.db.DeleteByID(m, >smodel.Mention{}); err != nil { | ||||
| 				if err := p.db.DeleteByID(ctx, m, >smodel.Mention{}); err != nil { | ||||
| 					return err | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			// delete all notifications for this status | ||||
| 			if err := p.db.DeleteWhere([]db.Where{{Key: "status_id", Value: statusToDelete.ID}}, &[]*gtsmodel.Notification{}); err != nil { | ||||
| 			if err := p.db.DeleteWhere(ctx, []db.Where{{Key: "status_id", Value: statusToDelete.ID}}, &[]*gtsmodel.Notification{}); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 
 | ||||
| 			// remove this status from any and all timelines | ||||
| 			return p.deleteStatusFromTimelines(statusToDelete) | ||||
| 			return p.deleteStatusFromTimelines(ctx, statusToDelete) | ||||
| 		case gtsmodel.ActivityStreamsProfile: | ||||
| 			// DELETE A PROFILE/ACCOUNT | ||||
| 			// TODO: handle side effects of account deletion here: delete all objects, statuses, media etc associated with account | ||||
|  | @ -198,7 +199,7 @@ func (p *processor) processFromFederator(federatorMsg gtsmodel.FromFederator) er | |||
| 				return errors.New("follow was not parseable as *gtsmodel.Follow") | ||||
| 			} | ||||
| 
 | ||||
| 			if err := p.notifyFollow(follow, federatorMsg.ReceivingAccount); err != nil { | ||||
| 			if err := p.notifyFollow(ctx, follow, federatorMsg.ReceivingAccount); err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 		} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue