mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 02:02:25 -05:00 
			
		
		
		
	[feature] Add List functionality (#1802)
* start working on lists * further list work * test list db functions nicely * more work on lists * peepoopeepoo * poke * start list timeline func * we're getting there lads * couldn't be me working on stuff... could it? * hook up handlers * fiddling * weeee * woah * screaming, pissing * fix streaming being a whiny baby * lint, small test fix, swagger * tidying up, testing * fucked! by the linter * move timelines to state like a boss * add timeline start to tests using state * invalidate lists
This commit is contained in:
		
					parent
					
						
							
								282be6f26d
							
						
					
				
			
			
				commit
				
					
						f5c004d67d
					
				
			
		
					 123 changed files with 5654 additions and 970 deletions
				
			
		|  | @ -18,7 +18,6 @@ | |||
| package stream | ||||
| 
 | ||||
| import ( | ||||
| 	"errors" | ||||
| 	"sync" | ||||
| 
 | ||||
| 	"github.com/superseriousbusiness/gotosocial/internal/oauth" | ||||
|  | @ -40,37 +39,38 @@ func New(state *state.State, oauthServer oauth.Server) Processor { | |||
| } | ||||
| 
 | ||||
| // toAccount streams the given payload with the given event type to any streams currently open for the given account ID. | ||||
| func (p *Processor) toAccount(payload string, event string, timelines []string, accountID string) error { | ||||
| func (p *Processor) toAccount(payload string, event string, streamTypes []string, accountID string) error { | ||||
| 	// Load all streams open for this account. | ||||
| 	v, ok := p.streamMap.Load(accountID) | ||||
| 	if !ok { | ||||
| 		// no open connections so nothing to stream | ||||
| 		return nil | ||||
| 	} | ||||
| 
 | ||||
| 	streamsForAccount, ok := v.(*stream.StreamsForAccount) | ||||
| 	if !ok { | ||||
| 		return errors.New("stream map error") | ||||
| 		return nil // No entry = nothing to stream. | ||||
| 	} | ||||
| 	streamsForAccount := v.(*stream.StreamsForAccount) //nolint:forcetypeassert | ||||
| 
 | ||||
| 	streamsForAccount.Lock() | ||||
| 	defer streamsForAccount.Unlock() | ||||
| 
 | ||||
| 	for _, s := range streamsForAccount.Streams { | ||||
| 		s.Lock() | ||||
| 		defer s.Unlock() | ||||
| 
 | ||||
| 		if !s.Connected { | ||||
| 			continue | ||||
| 		} | ||||
| 
 | ||||
| 		for _, t := range timelines { | ||||
| 			if _, found := s.Timelines[t]; found { | ||||
| 	typeLoop: | ||||
| 		for _, streamType := range streamTypes { | ||||
| 			if _, found := s.StreamTypes[streamType]; found { | ||||
| 				s.Messages <- &stream.Message{ | ||||
| 					Stream:  []string{string(t)}, | ||||
| 					Stream:  []string{streamType}, | ||||
| 					Event:   string(event), | ||||
| 					Payload: payload, | ||||
| 				} | ||||
| 				// break out to the outer loop, to avoid sending duplicates | ||||
| 				// of the same event to the same stream | ||||
| 				break | ||||
| 
 | ||||
| 				// Break out to the outer loop, | ||||
| 				// to avoid sending duplicates of | ||||
| 				// the same event to the same stream. | ||||
| 				break typeLoop | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue