Normalize profile fields

This commit is contained in:
kPherox 2019-11-19 14:15:41 +00:00 committed by Shpuld Shpludson
parent 8b37996805
commit a55486f8d7
2 changed files with 22 additions and 0 deletions

View file

@ -46,6 +46,14 @@ export const parseUser = (data) => {
output.description = data.note output.description = data.note
output.description_html = addEmojis(data.note, data.emojis) output.description_html = addEmojis(data.note, data.emojis)
output.fields = data.fields
output.fields_html = data.fields.map(field => {
return {
name: addEmojis(field.name, data.emojis),
value: addEmojis(field.value, data.emojis)
}
})
// Utilize avatar_static for gif avatars? // Utilize avatar_static for gif avatars?
output.profile_image_url = data.avatar output.profile_image_url = data.avatar
output.profile_image_url_original = data.avatar output.profile_image_url_original = data.avatar
@ -95,6 +103,7 @@ export const parseUser = (data) => {
if (data.source) { if (data.source) {
output.description = data.source.note output.description = data.source.note
output.default_scope = data.source.privacy output.default_scope = data.source.privacy
output.fields = data.source.fields
if (data.source.pleroma) { if (data.source.pleroma) {
output.no_rich_text = data.source.pleroma.no_rich_text output.no_rich_text = data.source.pleroma.no_rich_text
output.show_role = data.source.pleroma.show_role output.show_role = data.source.pleroma.show_role

View file

@ -277,6 +277,19 @@ describe('API Entities normalizer', () => {
expect(parsedUser).to.have.property('description_html').that.contains('<img') expect(parsedUser).to.have.property('description_html').that.contains('<img')
}) })
it('adds emojis to user profile fields', () => {
const user = makeMockUserMasto({ emojis: makeMockEmojiMasto(), fields: [{ name: ':thinking:', value: ':image:' }] })
const parsedUser = parseUser(user)
expect(parsedUser).to.have.property('fields_html').to.be.an('array')
const field = parsedUser.fields_html[0]
expect(field).to.have.property('name').that.contains('<img')
expect(field).to.have.property('value').that.contains('<img')
})
it('adds hide_follows and hide_followers user settings', () => { it('adds hide_follows and hide_followers user settings', () => {
const user = makeMockUserMasto({ pleroma: { hide_followers: true, hide_follows: false, hide_followers_count: false, hide_follows_count: true } }) const user = makeMockUserMasto({ pleroma: { hide_followers: true, hide_follows: false, hide_followers_count: false, hide_follows_count: true } })