diff options
Diffstat (limited to 'src/services/entity_normalizer')
| -rw-r--r-- | src/services/entity_normalizer/entity_normalizer.service.js | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 8e413584..5f45660d 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -33,6 +33,7 @@ export const parseUser = (data) => { if (masto) { output.screen_name = data.acct + output.statusnet_profile_url = data.url // There's nothing else to get if (mastoShort) { @@ -42,7 +43,7 @@ export const parseUser = (data) => { output.name = data.display_name output.name_html = addEmojis(data.display_name, data.emojis) - // output.description = ??? missing + output.description = data.note output.description_html = addEmojis(data.note, data.emojis) // Utilize avatar_static for gif avatars? @@ -56,22 +57,49 @@ export const parseUser = (data) => { output.bot = data.bot - output.statusnet_profile_url = data.url - if (data.pleroma) { const relationship = data.pleroma.relationship + output.background_image = data.pleroma.background_image + output.token = data.pleroma.chat_token + if (relationship) { output.follows_you = relationship.followed_by + output.requested = relationship.requested output.following = relationship.following output.statusnet_blocking = relationship.blocking output.muted = relationship.muting + output.showing_reblogs = relationship.showing_reblogs + output.subscribed = relationship.subscribing } + output.hide_follows = data.pleroma.hide_follows + output.hide_followers = data.pleroma.hide_followers + output.hide_follows_count = data.pleroma.hide_follows_count + output.hide_followers_count = data.pleroma.hide_followers_count + output.rights = { moderator: data.pleroma.is_moderator, admin: data.pleroma.is_admin } + // TODO: Clean up in UI? This is duplication from what BE does for qvitterapi + if (output.rights.admin) { + output.role = 'admin' + } else if (output.rights.moderator) { + output.role = 'moderator' + } else { + output.role = 'member' + } + } + + if (data.source) { + output.description = data.source.note + output.default_scope = data.source.privacy + if (data.source.pleroma) { + output.no_rich_text = data.source.pleroma.no_rich_text + output.show_role = data.source.pleroma.show_role + output.discoverable = data.source.pleroma.discoverable + } } // TODO: handle is_local @@ -106,8 +134,6 @@ export const parseUser = (data) => { output.muted = data.muted - // QVITTER ONLY FOR NOW - // Really only applies to logged in user, really.. I THINK if (data.rights) { output.rights = { moderator: data.rights.delete_others_notice, @@ -118,6 +144,8 @@ export const parseUser = (data) => { output.default_scope = data.default_scope output.hide_follows = data.hide_follows output.hide_followers = data.hide_followers + output.hide_follows_count = data.hide_follows_count + output.hide_followers_count = data.hide_followers_count output.background_image = data.background_image // on mastoapi this info is contained in a "relationship" output.following = data.following @@ -131,19 +159,20 @@ export const parseUser = (data) => { output.statuses_count = data.statuses_count output.friendIds = [] output.followerIds = [] - output.pinnedStatuseIds = [] + output.pinnedStatusIds = [] if (data.pleroma) { output.follow_request_count = data.pleroma.follow_request_count - } - if (data.pleroma) { output.tags = data.pleroma.tags output.deactivated = data.pleroma.deactivated + + output.notification_settings = data.pleroma.notification_settings } output.tags = output.tags || [] output.rights = output.rights || {} + output.notification_settings = output.notification_settings || {} return output } @@ -168,9 +197,11 @@ export const parseAttachment = (data) => { return output } export const addEmojis = (string, emojis) => { + const matchOperatorsRegex = /[|\\{}()[\]^$+*?.-]/g return emojis.reduce((acc, emoji) => { + const regexSafeShortCode = emoji.shortcode.replace(matchOperatorsRegex, '\\$&') return acc.replace( - new RegExp(`:${emoji.shortcode}:`, 'g'), + new RegExp(`:${regexSafeShortCode}:`, 'g'), `<img src='${emoji.url}' alt='${emoji.shortcode}' title='${emoji.shortcode}' class='emoji' />` ) }, string) @@ -192,6 +223,8 @@ export const parseStatus = (data) => { output.statusnet_html = addEmojis(data.content, data.emojis) + output.tags = data.tags + if (data.pleroma) { const { pleroma } = data output.text = pleroma.content ? data.pleroma.content['text/plain'] : data.content @@ -199,6 +232,7 @@ export const parseStatus = (data) => { output.statusnet_conversation_id = data.pleroma.conversation_id output.is_local = pleroma.local output.in_reply_to_screen_name = data.pleroma.in_reply_to_account_acct + output.thread_muted = pleroma.thread_muted } else { output.text = data.content output.summary = data.spoiler_text @@ -214,7 +248,9 @@ export const parseStatus = (data) => { output.summary_html = addEmojis(data.spoiler_text, data.emojis) output.external_url = data.url + output.poll = data.poll output.pinned = data.pinned + output.muted = data.muted } else { output.favorited = data.favorited output.fave_num = data.fave_num |
