fix: only send non-direct messages over websockets
This commit is contained in:
		
							parent
							
								
									97b05d787f
								
							
						
					
					
						commit
						507b7349ba
					
				
					 2 changed files with 16 additions and 7 deletions
				
			
		|  | @ -58,12 +58,16 @@ const ( | ||||||
| 	TokenScopePostsRead     TokenScope = "posts.read" | 	TokenScopePostsRead     TokenScope = "posts.read" | ||||||
| 	TokenScopePostsWrite    TokenScope = "posts.write" | 	TokenScopePostsWrite    TokenScope = "posts.write" | ||||||
| 	TokenScopeTimeline      TokenScope = "timeline" | 	TokenScopeTimeline      TokenScope = "timeline" | ||||||
| 	TokenScopeStreaming TokenScope = "streaming" | 	TokenScopeStreaming     TokenScope = "streaming" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func (s TokenScope) IsValid() bool { | func (s TokenScope) IsValid() bool { | ||||||
| 	switch s { | 	switch s { | ||||||
| 	case TokenScopeAccountsRead, TokenScopeAccountsMe, TokenScopeAccountsWrite: | 	case TokenScopeAccountsRead, TokenScopeAccountsMe, | ||||||
|  | 	TokenScopeAccountsWrite, TokenScopeBlogsRead, | ||||||
|  | 	TokenScopeBlogsWrite, TokenScopePostsRead, | ||||||
|  | 	TokenScopePostsWrite, TokenScopeTimeline, | ||||||
|  | 	TokenScopeStreaming: | ||||||
| 		return true | 		return true | ||||||
| 	default: | 	default: | ||||||
| 		return false | 		return false | ||||||
|  |  | ||||||
|  | @ -71,11 +71,16 @@ func (p *Processor) handlePostLocal( | ||||||
| 	apiPost := api.DBPostToPost(post, blog, acct) | 	apiPost := api.DBPostToPost(post, blog, acct) | ||||||
| 	p.SocketHolder.Send(acct.ID, streaming.EventTypePost, apiPost) | 	p.SocketHolder.Send(acct.ID, streaming.EventTypePost, apiPost) | ||||||
| 
 | 
 | ||||||
| 	for _, follower := range followers { | 	// send to followers | ||||||
| 		if !follower.IsLocal { | 	if post.Visibility != database.DirectVisibility { | ||||||
| 			continue | 		for _, follower := range followers { | ||||||
| 		} | 			if !follower.IsLocal { | ||||||
|  | 				continue | ||||||
|  | 			} | ||||||
| 
 | 
 | ||||||
| 		p.SocketHolder.Send(follower.AccountID, streaming.EventTypePost, apiPost) | 			p.SocketHolder.Send(follower.AccountID, streaming.EventTypePost, apiPost) | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	// TODO: send to mentions | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue