[bugfix] rename include_types[] to types[] (#3023)

This commit is contained in:
tobi 2024-06-18 18:18:35 +02:00 committed by GitHub
parent d2b3d37724
commit 4ce5c37df5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19 additions and 19 deletions

View file

@ -34,8 +34,8 @@ const (
BasePathWithID = BasePath + "/:" + IDKey BasePathWithID = BasePath + "/:" + IDKey
BasePathWithClear = BasePath + "/clear" BasePathWithClear = BasePath + "/clear"
// IncludeTypesKey names an array param specifying notification types to include. // TypesKey names an array param specifying notification types to include.
IncludeTypesKey = "include_types[]" TypesKey = "types[]"
// ExcludeTypesKey names an array param specifying notification types to exclude. // ExcludeTypesKey names an array param specifying notification types to exclude.
ExcludeTypesKey = "exclude_types[]" ExcludeTypesKey = "exclude_types[]"
MaxIDKey = "max_id" MaxIDKey = "max_id"

View file

@ -171,7 +171,7 @@ func (m *Module) NotificationsGETHandler(c *gin.Context) {
c.Query(SinceIDKey), c.Query(SinceIDKey),
c.Query(MinIDKey), c.Query(MinIDKey),
limit, limit,
c.QueryArray(IncludeTypesKey), c.QueryArray(TypesKey),
c.QueryArray(ExcludeTypesKey), c.QueryArray(ExcludeTypesKey),
) )
if errWithCode != nil { if errWithCode != nil {

View file

@ -45,7 +45,7 @@ func (suite *NotificationsTestSuite) getNotifications(
maxID string, maxID string,
minID string, minID string,
limit int, limit int,
includeTypes []string, types []string,
excludeTypes []string, excludeTypes []string,
expectedHTTPStatus int, expectedHTTPStatus int,
expectedBody string, expectedBody string,
@ -71,8 +71,8 @@ func (suite *NotificationsTestSuite) getNotifications(
if limit != 0 { if limit != 0 {
query.Set(notifications.LimitKey, strconv.Itoa(limit)) query.Set(notifications.LimitKey, strconv.Itoa(limit))
} }
if len(includeTypes) > 0 { if len(types) > 0 {
query[notifications.IncludeTypesKey] = includeTypes query[notifications.TypesKey] = types
} }
if len(excludeTypes) > 0 { if len(excludeTypes) > 0 {
query[notifications.ExcludeTypesKey] = excludeTypes query[notifications.ExcludeTypesKey] = excludeTypes
@ -123,7 +123,7 @@ func (suite *NotificationsTestSuite) TestGetNotificationsSingle() {
maxID := "" maxID := ""
minID := "" minID := ""
limit := 10 limit := 10
includeTypes := []string(nil) types := []string(nil)
excludeTypes := []string(nil) excludeTypes := []string(nil)
expectedHTTPStatus := http.StatusOK expectedHTTPStatus := http.StatusOK
expectedBody := "" expectedBody := ""
@ -135,7 +135,7 @@ func (suite *NotificationsTestSuite) TestGetNotificationsSingle() {
maxID, maxID,
minID, minID,
limit, limit,
includeTypes, types,
excludeTypes, excludeTypes,
expectedHTTPStatus, expectedHTTPStatus,
expectedBody, expectedBody,
@ -181,7 +181,7 @@ func (suite *NotificationsTestSuite) TestGetNotificationsExcludeOneType() {
maxID := "" maxID := ""
minID := "" minID := ""
limit := 10 limit := 10
includeTypes := []string(nil) types := []string(nil)
excludeTypes := []string{"follow_request"} excludeTypes := []string{"follow_request"}
expectedHTTPStatus := http.StatusOK expectedHTTPStatus := http.StatusOK
expectedBody := "" expectedBody := ""
@ -193,7 +193,7 @@ func (suite *NotificationsTestSuite) TestGetNotificationsExcludeOneType() {
maxID, maxID,
minID, minID,
limit, limit,
includeTypes, types,
excludeTypes, excludeTypes,
expectedHTTPStatus, expectedHTTPStatus,
expectedBody, expectedBody,
@ -220,7 +220,7 @@ func (suite *NotificationsTestSuite) TestGetNotificationsIncludeOneType() {
maxID := "" maxID := ""
minID := "" minID := ""
limit := 10 limit := 10
includeTypes := []string{"favourite"} types := []string{"favourite"}
excludeTypes := []string(nil) excludeTypes := []string(nil)
expectedHTTPStatus := http.StatusOK expectedHTTPStatus := http.StatusOK
expectedBody := "" expectedBody := ""
@ -232,7 +232,7 @@ func (suite *NotificationsTestSuite) TestGetNotificationsIncludeOneType() {
maxID, maxID,
minID, minID,
limit, limit,
includeTypes, types,
excludeTypes, excludeTypes,
expectedHTTPStatus, expectedHTTPStatus,
expectedBody, expectedBody,

View file

@ -200,7 +200,7 @@ func (n *notificationDB) GetAccountNotifications(
sinceID string, sinceID string,
minID string, minID string,
limit int, limit int,
includeTypes []string, types []string,
excludeTypes []string, excludeTypes []string,
) ([]*gtsmodel.Notification, error) { ) ([]*gtsmodel.Notification, error) {
// Ensure reasonable // Ensure reasonable
@ -238,9 +238,9 @@ func (n *notificationDB) GetAccountNotifications(
frontToBack = false // page up frontToBack = false // page up
} }
if len(includeTypes) > 0 { if len(types) > 0 {
// Include only requested notification types. // Include only requested notification types.
q = q.Where("? IN (?)", bun.Ident("notification.notification_type"), bun.In(includeTypes)) q = q.Where("? IN (?)", bun.Ident("notification.notification_type"), bun.In(types))
} }
if len(excludeTypes) > 0 { if len(excludeTypes) > 0 {

View file

@ -28,8 +28,8 @@ type Notification interface {
// GetAccountNotifications returns a slice of notifications that pertain to the given accountID. // GetAccountNotifications returns a slice of notifications that pertain to the given accountID.
// //
// Returned notifications will be ordered ID descending (ie., highest/newest to lowest/oldest). // Returned notifications will be ordered ID descending (ie., highest/newest to lowest/oldest).
// If includeTypes is empty, *all* notification types will be included. // If types is empty, *all* notification types will be included.
GetAccountNotifications(ctx context.Context, accountID string, maxID string, sinceID string, minID string, limit int, includeTypes []string, excludeTypes []string) ([]*gtsmodel.Notification, error) GetAccountNotifications(ctx context.Context, accountID string, maxID string, sinceID string, minID string, limit int, types []string, excludeTypes []string) ([]*gtsmodel.Notification, error)
// GetNotificationByID returns one notification according to its id. // GetNotificationByID returns one notification according to its id.
GetNotificationByID(ctx context.Context, id string) (*gtsmodel.Notification, error) GetNotificationByID(ctx context.Context, id string) (*gtsmodel.Notification, error)

View file

@ -41,7 +41,7 @@ func (p *Processor) NotificationsGet(
sinceID string, sinceID string,
minID string, minID string,
limit int, limit int,
includeTypes []string, types []string,
excludeTypes []string, excludeTypes []string,
) (*apimodel.PageableResponse, gtserror.WithCode) { ) (*apimodel.PageableResponse, gtserror.WithCode) {
notifs, err := p.state.DB.GetAccountNotifications( notifs, err := p.state.DB.GetAccountNotifications(
@ -51,7 +51,7 @@ func (p *Processor) NotificationsGet(
sinceID, sinceID,
minID, minID,
limit, limit,
includeTypes, types,
excludeTypes, excludeTypes,
) )
if err != nil && !errors.Is(err, db.ErrNoEntries) { if err != nil && !errors.Is(err, db.ErrNoEntries) {