mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(flags): limit challenge requests to country flags
This commit is contained in:
@@ -126,17 +126,18 @@ describe('comment-flag-selection', () => {
|
||||
expect(getCommentFlagRequestFromSelection('none')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('publishes selected flags as signed comment flairs and challenge answers', () => {
|
||||
it('publishes geographic flags as challenge-backed comment flairs', () => {
|
||||
expect(getCommentFlagPublishOptionsFromSelection('country:auto')).toEqual({
|
||||
challengeRequest: {
|
||||
challengeAnswers: ['bitsocial-flags:5chan:flag:country:auto'],
|
||||
},
|
||||
flairs: [{ type: 'country', code: 'auto', text: 'flag:country:auto' }],
|
||||
});
|
||||
});
|
||||
|
||||
it('publishes board-choice flags as regular comment flairs without a challenge request', () => {
|
||||
expect(getCommentFlagPublishOptionsFromSelection('pony:AJ')).toEqual({
|
||||
challengeRequest: {
|
||||
challengeAnswers: ['bitsocial-flags:5chan:flag:pony:AJ'],
|
||||
},
|
||||
challengeRequest: undefined,
|
||||
flairs: [{ type: 'pony', code: 'AJ', text: 'flag:pony:AJ' }],
|
||||
});
|
||||
});
|
||||
|
||||
@@ -133,9 +133,12 @@ export const getCommentFlagPublishOptionsFromSelection = (value: string | undefi
|
||||
const flag = getCommentFlagRequestFromSelection(value);
|
||||
return flag
|
||||
? {
|
||||
challengeRequest: {
|
||||
challengeAnswers: [`${FLAG_CHALLENGE_ANSWER_PREFIX}${flag.text}`],
|
||||
},
|
||||
challengeRequest:
|
||||
flag.type === 'country'
|
||||
? {
|
||||
challengeAnswers: [`${FLAG_CHALLENGE_ANSWER_PREFIX}${flag.text}`],
|
||||
}
|
||||
: undefined,
|
||||
flairs: [flag],
|
||||
}
|
||||
: {
|
||||
|
||||
Reference in New Issue
Block a user