ContentFilterable
protocol ContentFilterableA Protocol used to provide convenience functions for Models that return content that is filterable.
Adopting the protocol requires implmenting contentTextStrings() which returns an array of ‘content’
strings that should be scanned in a filter operation.
- 
                  
                  DeclarationSwift func contentTextStrings() -> [String]
- 
                  containsMutewords(using:Extension method) Checks if a ContentFilterablecontains any of the provided array of muting strings, returning true if it doesDeclarationSwift func containsMutewords(using mutewords: [String]) -> BoolParametersmutewordsThe list of strings on which to filter the post. Return ValueTRUE if the post contains a muting string. 
- 
                  filterOutStrings(using:Extension method) Checks if a ContentFilterablecontains any of the provided array of strings, returningnilif it does, else returningself. Returnsselfif the array of search strings is empty ornil.DeclarationSwift func filterOutStrings(using words: [String]?) -> Self?ParameterswordsThe list of strings on which to filter the post. Return ValueThe provided object, or nilif the object’s text fields contain a string.
- 
                  getMentionsDiffs(editedString:Extension methodisCreate: ) Returns (removes, adds) which are (importantly!) disjoint sets of usernames @mentioned in the reciever or in the editedString. Used to update mention counts for mentioned users. A user @mentioned multiple times in the same ContentFilterable only counts once. DeclarationSwift func getMentionsDiffs(editedString: String?, isCreate: Bool) -> (Set<String>, Set<String>)
- 
                  getAlertwordDiffs(editedString:Extension methodisCreate: ) DeclarationSwift func getAlertwordDiffs(editedString: String?, isCreate: Bool) -> (Set<String>, Set<String>)
- 
                  getHashtags()Extension methodRetuns all discovered hashtags in all text strings of the content. DeclarationSwift func getHashtags() -> Set<String>
- 
                  buildCleanWordsArray(_:Extension method) DeclarationSwift static func buildCleanWordsArray(_ str: String) -> Set<String>
- 
                  getMentionsSet(for:Extension method) Returns a set of possible usernames found as @mentions in the given string. Does not check whether the @mentions are valid users. The regex looks for: - Start-of-string or whitespace,
- ‘@’
- 2…50 characters that are in the set of valid Username chars
- Trailing separator characters are excluded from the mention (such as ending with punctuation)
- A non-Username char or end-of-string. ChatGPT turned this from a mega string processing nightmare into an unreadable regex! “Software”
 Example: “@heidi likes @sam” -> [“heidi”, “sam”] DeclarationSwift static func getMentionsSet(for string: String) -> Set<String>
- 
                  filterForMention(of:Extension method) Fluent queries can filter for strings in text fields, but @mentions require more specific filtering. This fn tests that the given username is @mentioned in the receiver’s content. It’s specifically looking for cases where one name is a substring of another. Example: both @John and @John.Doe are users. Simple string search returns @John.Doe results in a search for @John. Also, if a user is @mentioned at the end of a sentence, the period is a valid username char, but is not valid at the end of a username (must have a following alphanumeric). @TODO consider: https://www.swiftbysundell.com/articles/string-parsing-in-swift/ DeclarationSwift func filterForMention(of username: String) -> Self?ParametersusernameString of the username (including @) that we are attempting to match for. Return ValueA ContentFilterable (such as ForumPost or FezPost) if the username is found, else nil. 
 View on GitHub
            View on GitHub
           ContentFilterable Protocol Reference
      ContentFilterable Protocol Reference