2024-03-03 15:14:59 -05:00
|
|
|
|
package moderation
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2024-03-07 19:41:05 -05:00
|
|
|
|
"fmt"
|
2024-03-03 15:14:59 -05:00
|
|
|
|
"net/http"
|
|
|
|
|
"net/url"
|
|
|
|
|
|
|
|
|
|
"github.com/google/go-querystring/query"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type RemoveBlockedTermParams struct {
|
|
|
|
|
// The ID of the broadcaster that owns the list of blocked terms.
|
|
|
|
|
BroadcasterID string `url:"broadcaster_id"`
|
|
|
|
|
|
|
|
|
|
// The ID of the broadcaster or a user that has permission to moderate the broadcaster’s chat room.
|
|
|
|
|
// This ID must match the user ID in the user access token.
|
|
|
|
|
ModeratorID string `url:"moderator_id"`
|
|
|
|
|
|
|
|
|
|
// The ID of the blocked term to remove from the broadcaster’s list of blocked terms.
|
|
|
|
|
ID string `url:"id"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Removes the word or phrase from the broadcaster’s list of blocked terms.
|
|
|
|
|
//
|
|
|
|
|
// Requires a user access token that includes the moderator:manage:blocked_terms scope.
|
|
|
|
|
func (m *Moderation) RemoveBlockedTerm(ctx context.Context, params *RemoveBlockedTermParams) error {
|
|
|
|
|
v, _ := query.Values(params)
|
|
|
|
|
endpoint := m.baseUrl.ResolveReference(&url.URL{Path: "moderation/blocks", RawQuery: v.Encode()})
|
|
|
|
|
|
|
|
|
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res, err := m.client.Do(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
defer res.Body.Close()
|
|
|
|
|
|
2024-03-07 19:41:05 -05:00
|
|
|
|
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
|
|
|
|
|
if !statusOK {
|
|
|
|
|
return fmt.Errorf("failed to remove blocked term (%d)", res.StatusCode)
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-03 15:14:59 -05:00
|
|
|
|
return nil
|
|
|
|
|
}
|