+5
-1
atproto/client/apiclient.go
+5
-1
atproto/client/apiclient.go
···
166
166
167
167
// Configures labeler header (Atproto-Accept-Labelers) with the indicated "redact" level labelers, and regular labelers.
168
168
func (c *APIClient) SetLabelers(redact, other []syntax.DID) {
169
+
c.Headers.Set("Atproto-Accept-Labelers", encodeLabelerHeader(redact, other))
170
+
}
171
+
172
+
func encodeLabelerHeader(redact, other []syntax.DID) string {
169
173
val := ""
170
174
for _, did := range redact {
171
175
if val != "" {
···
179
183
}
180
184
val = val + did.String()
181
185
}
182
-
c.Headers.Set("Atproto-Accept-Labelers", val)
186
+
return val
183
187
}
+21
atproto/client/apiclient_test.go
+21
atproto/client/apiclient_test.go
···
1
+
package client
2
+
3
+
import (
4
+
"testing"
5
+
6
+
"github.com/bluesky-social/indigo/atproto/syntax"
7
+
8
+
"github.com/stretchr/testify/assert"
9
+
)
10
+
11
+
func TestEncodeLabelerHeader(t *testing.T) {
12
+
assert := assert.New(t)
13
+
14
+
labelerA := syntax.DID("did:web:aaa.example.com")
15
+
labelerB := syntax.DID("did:web:bbb.example.com")
16
+
17
+
assert.Equal("", encodeLabelerHeader(nil, nil))
18
+
assert.Equal("did:web:aaa.example.com,did:web:bbb.example.com", encodeLabelerHeader(nil, []syntax.DID{labelerA, labelerB}))
19
+
assert.Equal("did:web:aaa.example.com;redact,did:web:bbb.example.com", encodeLabelerHeader([]syntax.DID{labelerA}, []syntax.DID{labelerB}))
20
+
assert.Equal("did:web:aaa.example.com;redact", encodeLabelerHeader([]syntax.DID{labelerA}, nil))
21
+
}