mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 07:12:26 -05:00 
			
		
		
		
	[bugfix] Fix no notification if mention edited into status (#4102)
This pull request adds mention notifications if a mention was edited into a status after its initial publication. Closes https://codeberg.org/superseriousbusiness/gotosocial/issues/3869 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4102 Co-authored-by: tobi <tobi.smethurst@protonmail.com> Co-committed-by: tobi <tobi.smethurst@protonmail.com>
This commit is contained in:
		
					parent
					
						
							
								056c67f396
							
						
					
				
			
			
				commit
				
					
						f3f1854359
					
				
			
		
					 13 changed files with 196 additions and 48 deletions
				
			
		|  | @ -19,9 +19,11 @@ package processing | |||
| 
 | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 
 | ||||
| 	"code.superseriousbusiness.org/gotosocial/internal/config" | ||||
| 	"code.superseriousbusiness.org/gotosocial/internal/db" | ||||
| 	"code.superseriousbusiness.org/gotosocial/internal/federation" | ||||
| 	"code.superseriousbusiness.org/gotosocial/internal/gtscontext" | ||||
| 	"code.superseriousbusiness.org/gotosocial/internal/gtsmodel" | ||||
|  | @ -100,7 +102,29 @@ func GetParseMentionFunc(state *state.State, federator *federation.Federator) gt | |||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		// Return mention with useful populated fields, | ||||
| 		// Check if the mention was | ||||
| 		// in the database already. | ||||
| 		if statusID != "" { | ||||
| 			mention, err := state.DB.GetMentionByTargetAcctStatus(ctx, targetAcct.ID, statusID) | ||||
| 			if err != nil && !errors.Is(err, db.ErrNoEntries) { | ||||
| 				return nil, fmt.Errorf( | ||||
| 					"db error checking for existing mention: %w", | ||||
| 					err, | ||||
| 				) | ||||
| 			} | ||||
| 
 | ||||
| 			if mention != nil { | ||||
| 				// We had it, return this rather | ||||
| 				// than creating a new one. | ||||
| 				mention.NameString = namestring | ||||
| 				mention.OriginAccountURI = originAcct.URI | ||||
| 				mention.TargetAccountURI = targetAcct.URI | ||||
| 				mention.TargetAccountURL = targetAcct.URL | ||||
| 				return mention, nil | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		// Return new mention with useful populated fields, | ||||
| 		// but *don't* store it in the database; that's | ||||
| 		// up to the calling function to do, if they want. | ||||
| 		return >smodel.Mention{ | ||||
|  | @ -114,6 +138,10 @@ func GetParseMentionFunc(state *state.State, federator *federation.Federator) gt | |||
| 			TargetAccountURL: targetAcct.URL, | ||||
| 			TargetAccount:    targetAcct, | ||||
| 			NameString:       namestring, | ||||
| 
 | ||||
| 			// Mention wasn't | ||||
| 			// stored in the db. | ||||
| 			IsNew: true, | ||||
| 		}, nil | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue