mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-28 11:12:25 -05:00
[feature] support blur filter action (#4371)
This pull request implements the `blur` value of `filter_action` for status filtering. It was introduced by Mastodon 4.4.0. [Related docs update](https://github.com/mastodon/documentation/pull/1620) Signed-off-by: nicole mikołajczyk <git@mkljczk.pl> Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4371 Reviewed-by: kim <gruf@noreply.codeberg.org> Co-authored-by: nicole mikołajczyk <git@mkljczk.pl> Co-committed-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
parent
7f8cb204cd
commit
fb2ef90ec5
7 changed files with 20 additions and 4 deletions
|
|
@ -69,6 +69,8 @@ const (
|
|||
FilterActionWarn FilterAction = "warn"
|
||||
// FilterActionHide filters will remove this status from API results.
|
||||
FilterActionHide FilterAction = "hide"
|
||||
// FilterActionBlur filters will include this status in API results indicating the media attachments should be hidden/blurred.
|
||||
FilterActionBlur FilterAction = "blur"
|
||||
)
|
||||
|
||||
// FilterKeyword represents text to filter within a v2 filter.
|
||||
|
|
|
|||
|
|
@ -100,6 +100,8 @@ func toAPIFilterAction(m gtsmodel.FilterAction) apimodel.FilterAction {
|
|||
return apimodel.FilterActionWarn
|
||||
case gtsmodel.FilterActionHide:
|
||||
return apimodel.FilterActionHide
|
||||
case gtsmodel.FilterActionBlur:
|
||||
return apimodel.FilterActionBlur
|
||||
}
|
||||
return apimodel.FilterActionNone
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,8 +208,8 @@ func (f *Filter) getStatusFilterResults(
|
|||
var apiResult *apimodel.FilterResult
|
||||
|
||||
switch filter.Action {
|
||||
case gtsmodel.FilterActionWarn:
|
||||
// For filter action WARN get all possible filter matches against status.
|
||||
case gtsmodel.FilterActionWarn, gtsmodel.FilterActionBlur:
|
||||
// For filter action WARN or BLUR get all possible filter matches against status.
|
||||
keywordMatches, statusMatches := getFilterMatches(filter, status.ID, fields)
|
||||
if len(keywordMatches) == 0 && len(statusMatches) == 0 {
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -205,6 +205,10 @@ const (
|
|||
// FilterActionHide means that the status should
|
||||
// be removed from timeline results entirely.
|
||||
FilterActionHide FilterAction = 2
|
||||
|
||||
// FilterActionWarn means that the status should
|
||||
// be shown with its media attachments hidden/blurred.
|
||||
FilterActionBlur FilterAction = 3
|
||||
)
|
||||
|
||||
// String returns human-readable form of FilterAction.
|
||||
|
|
@ -216,6 +220,8 @@ func (act FilterAction) String() string {
|
|||
return "warn"
|
||||
case FilterActionHide:
|
||||
return "hide"
|
||||
case FilterActionBlur:
|
||||
return "blur"
|
||||
default:
|
||||
panic(fmt.Sprintf("invalid filter action: %d", act))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ func APIFilterActionToFilterAction(m apimodel.FilterAction) gtsmodel.FilterActio
|
|||
return gtsmodel.FilterActionWarn
|
||||
case apimodel.FilterActionHide:
|
||||
return gtsmodel.FilterActionHide
|
||||
case apimodel.FilterActionBlur:
|
||||
return gtsmodel.FilterActionBlur
|
||||
}
|
||||
return gtsmodel.FilterActionNone
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2500,6 +2500,8 @@ func filterActionToAPIFilterAction(m gtsmodel.FilterAction) apimodel.FilterActio
|
|||
return apimodel.FilterActionWarn
|
||||
case gtsmodel.FilterActionHide:
|
||||
return apimodel.FilterActionHide
|
||||
case gtsmodel.FilterActionBlur:
|
||||
return apimodel.FilterActionBlur
|
||||
}
|
||||
return apimodel.FilterActionNone
|
||||
}
|
||||
|
|
|
|||
|
|
@ -383,14 +383,16 @@ func FilterContexts(contexts []apimodel.FilterContext) error {
|
|||
func FilterAction(action apimodel.FilterAction) error {
|
||||
switch action {
|
||||
case apimodel.FilterActionWarn,
|
||||
apimodel.FilterActionHide:
|
||||
apimodel.FilterActionHide,
|
||||
apimodel.FilterActionBlur:
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf(
|
||||
"filter action '%s' was not recognized, valid options are '%s', '%s'",
|
||||
"filter action '%s' was not recognized, valid options are '%s', '%s', '%s'",
|
||||
action,
|
||||
apimodel.FilterActionWarn,
|
||||
apimodel.FilterActionHide,
|
||||
apimodel.FilterActionBlur,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue