@atproto/api
Version:
Client library for atproto and Bluesky
35 lines • 1.28 kB
JavaScript
import { AtUri } from '@atproto/syntax';
import { ModerationDecision } from '../decision.js';
import { decideAccount } from './account.js';
import { decideProfile } from './profile.js';
export function decideUserList(subject, opts) {
const acc = new ModerationDecision();
const creator =
// Note: ListViewBasic should not contain a creator field, but let's support it anyway
'creator' in subject && isProfile(subject.creator)
? subject.creator
: undefined;
if (creator) {
acc.setDid(creator.did);
acc.setIsMe(creator.did === opts.userDid);
if (subject.labels?.length) {
for (const label of subject.labels) {
acc.addLabel('content', label, opts);
}
}
return ModerationDecision.merge(acc, decideAccount(creator, opts), decideProfile(creator, opts));
}
const creatorDid = new AtUri(subject.uri).hostname;
acc.setDid(creatorDid);
acc.setIsMe(creatorDid === opts.userDid);
if (subject.labels?.length) {
for (const label of subject.labels) {
acc.addLabel('content', label, opts);
}
}
return acc;
}
function isProfile(v) {
return v && typeof v === 'object' && 'did' in v;
}
//# sourceMappingURL=user-list.js.map