getLabelerHeaders function

Map<String, String> getLabelerHeaders(
  1. ModerationPrefs? prefs, {
  2. List<String> appLabelers = const [_kBskyLabelerDid],
})

Implementation

Map<String, String> getLabelerHeaders(
  final ModerationPrefs? prefs, {
  final List<String> appLabelers = const [_kBskyLabelerDid],
}) {
  final subscribedLabelers =
      prefs?.labelers
          .map((e) => e.did)
          .where((e) => e.startsWith('did:'))
          .where((e) => !appLabelers.contains(e)) ??
      const <String>[];

  // Only app labelers are sent with the `;redact` parameter, following the
  // official client behavior.
  return {
    'atproto-accept-labelers': <String>{
      ...appLabelers.map((did) => '$did;redact'),
      ...subscribedLabelers,
    }.join(', '),
  };
}