From 334ec7175eabed67e73622c2374f1cca926bcbbe Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 6 Jan 2024 17:04:16 -0500 Subject: [PATCH] Initial POC --- .node-version | 2 +- Dockerfile | 11 ++ nginx.conf | 44 ++++++++ src/boot/after_store.js | 100 ++++++++++-------- src/components/status/status.js | 14 ++- src/components/timeline/timeline.js | 2 +- src/modules/config.js | 62 +++++------ src/modules/instance.js | 39 ++++--- src/modules/statuses.js | 5 +- src/services/api/api.service.js | 49 ++++++--- .../entity_normalizer.service.js | 26 +++-- static/config.json | 2 +- 12 files changed, 237 insertions(+), 119 deletions(-) create mode 100644 Dockerfile create mode 100644 nginx.conf diff --git a/.node-version b/.node-version index b26a34e4..b6a7d89c 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -7.2.1 +16 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..194efed0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM node:16 as builder +WORKDIR /build +COPY ./ /build/ +RUN npm run build + + +FROM nginx:alpine +LABEL org.opencontainers.image.authors="@phoenix_fairy@thetransagenda.gay" +COPY --from=builder /build/dist /usr/share/nginx/html +COPY nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..4a1d6440 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,44 @@ +server { + listen 80; + server_name localhost; + + #access_log /var/log/nginx/host.access.log main; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ /index.html; + } + + #error_page 404 /404.html; + + # redirect server error pages to the static page /50x.html + # + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + + # proxy the PHP scripts to Apache listening on 127.0.0.1:80 + # + #location ~ \.php$ { + # proxy_pass http://127.0.0.1; + #} + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + #location ~ \.php$ { + # root html; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; + # include fastcgi_params; + #} + + # deny access to .htaccess files, if Apache's document root + # concurs with nginx's one + # + #location ~ /\.ht { + # deny all; + #} +} diff --git a/src/boot/after_store.js b/src/boot/after_store.js index d45584c0..9983afd6 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -70,9 +70,10 @@ const getInstanceConfig = async ({ store }) => { const res = await preloadFetch('/api/v1/instance') if (res.ok) { const data = await res.json() - const textlimit = data.max_toot_chars - const vapidPublicKey = data.pleroma.vapid_public_key - + const textlimit = data.configuration.statuses.max_characters + //const vapidPublicKey = data.pleroma.vapid_public_key + // Get this from /api/meta + const vapidPublicKey = "" store.dispatch('setInstanceOption', { name: 'textlimit', value: textlimit }) store.dispatch('setInstanceOption', { name: 'accountApprovalRequired', value: data.approval_required }) // don't override cookie if set @@ -94,9 +95,10 @@ const getInstanceConfig = async ({ store }) => { const getBackendProvidedConfig = async ({ store }) => { try { - const res = await window.fetch('/api/pleroma/frontend_configurations') - if (res.ok) { - const data = await res.json() + //const res = await window.fetch('/api/pleroma/frontend_configurations') + if (true) { + //const data = await res.json() + const data = {"masto_fe":{"showInstanceSpecificPanel":true},"pleroma_fe":{"alwaysShowSubjectInput":true,"background":"/images/city.jpg","collapseMessageWithSubject":true,"conversationDisplay":"linear","disableChat":false,"greentext":false,"hideFilteredStatuses":true,"hideMutedPosts":true,"hidePostStats":false,"hideSitename":false,"hideUserStats":false,"loginMethod":"password","logo":"/static/logo.svg","logoMargin":".1em","logoMask":true,"noAttachmentLinks":false,"nsfwCensorImage":"","postContentType":"text/plain","redirectRootLogin":"/main/friends","redirectRootNoLogin":"/main/public","renderMisskeyMarkdown":true,"scopeCopy":true,"showFeaturesPanel":true,"showInstanceSpecificPanel":false,"sidebarRight":false,"subjectLineBehavior":"email","theme":"pleroma-dark","webPushNotifications":false}} return data.pleroma_fe } else { throw (res) @@ -265,71 +267,75 @@ const resolveStaffAccounts = ({ store, accounts }) => { const getNodeInfo = async ({ store }) => { try { - const res = await preloadFetch('/nodeinfo/2.0.json') + const res = await preloadFetch('/nodeinfo/2.0') + // TODO: Load from /api/meta + //meta = new Request('/api/meta', { + // method: "POST"}) + //const res = await preloadFetch(meta) if (res.ok) { const data = await res.json() const metadata = data.metadata - const features = metadata.features + //const features = data.configuration store.dispatch('setInstanceOption', { name: 'name', value: metadata.nodeName }) - store.dispatch('setInstanceOption', { name: 'registrationOpen', value: data.openRegistrations }) - store.dispatch('setInstanceOption', { name: 'mediaProxyAvailable', value: features.includes('media_proxy') }) - store.dispatch('setInstanceOption', { name: 'safeDM', value: features.includes('safe_dm_mentions') }) - store.dispatch('setInstanceOption', { name: 'pollsAvailable', value: features.includes('polls') }) - store.dispatch('setInstanceOption', { name: 'editingAvailable', value: features.includes('editing') }) - store.dispatch('setInstanceOption', { name: 'pollLimits', value: metadata.pollLimits }) - store.dispatch('setInstanceOption', { name: 'mailerEnabled', value: metadata.mailerEnabled }) - store.dispatch('setInstanceOption', { name: 'translationEnabled', value: features.includes('akkoma:machine_translation') }) + store.dispatch('setInstanceOption', { name: 'registrationOpen', value: !data.disableRegistration }) + store.dispatch('setInstanceOption', { name: 'mediaProxyAvailable', value: false }) + store.dispatch('setInstanceOption', { name: 'safeDM', value: false }) + store.dispatch('setInstanceOption', { name: 'pollsAvailable', value: true }) + store.dispatch('setInstanceOption', { name: 'editingAvailable', value: true }) + //store.dispatch('setInstanceOption', { name: 'pollLimits', value: configuration.polls }) + store.dispatch('setInstanceOption', { name: 'mailerEnabled', value: metadata.enableEmail }) + store.dispatch('setInstanceOption', { name: 'translationEnabled', value: false }) - const uploadLimits = metadata.uploadLimits - store.dispatch('setInstanceOption', { name: 'uploadlimit', value: parseInt(uploadLimits.general) }) - store.dispatch('setInstanceOption', { name: 'avatarlimit', value: parseInt(uploadLimits.avatar) }) - store.dispatch('setInstanceOption', { name: 'backgroundlimit', value: parseInt(uploadLimits.background) }) - store.dispatch('setInstanceOption', { name: 'bannerlimit', value: parseInt(uploadLimits.banner) }) - store.dispatch('setInstanceOption', { name: 'fieldsLimits', value: metadata.fieldsLimits }) + // const uploadLimits = metadata.uploadLimits + // store.dispatch('setInstanceOption', { name: 'uploadlimit', value: parseInt(configuration.media_attachments.image_size_limit) }) + // store.dispatch('setInstanceOption', { name: 'avatarlimit', value: parseInt(configuration.media_attachments.image_size_limit) }) + // store.dispatch('setInstanceOption', { name: 'backgroundlimit', value: parseInt(configuration.media_attachments.image_size_limit) }) + // store.dispatch('setInstanceOption', { name: 'bannerlimit', value: parseInt(configuration.media_attachments.image_size_limit) }) + // store.dispatch('setInstanceOption', { name: 'fieldsLimits', value: metadata.fieldsLimits }) - store.dispatch('setInstanceOption', { name: 'restrictedNicknames', value: metadata.restrictedNicknames }) - store.dispatch('setInstanceOption', { name: 'postFormats', value: metadata.postFormats }) + store.dispatch('setInstanceOption', { name: 'restrictedNicknames', value: ["admin","instance.actor","instance.relay"] }) + store.dispatch('setInstanceOption', { name: 'postFormats', value: ["text/x.misskeymarkdown"] }) - const suggestions = metadata.suggestions - store.dispatch('setInstanceOption', { name: 'suggestionsEnabled', value: suggestions.enabled }) - store.dispatch('setInstanceOption', { name: 'suggestionsWeb', value: suggestions.web }) + //const suggestions = metadata.suggestions + store.dispatch('setInstanceOption', { name: 'suggestionsEnabled', value: false }) + store.dispatch('setInstanceOption', { name: 'suggestionsWeb', value: false }) const software = data.software store.dispatch('setInstanceOption', { name: 'backendVersion', value: software.version }) store.dispatch('setInstanceOption', { name: 'pleromaBackend', value: software.name === 'pleroma' }) - const priv = metadata.private - store.dispatch('setInstanceOption', { name: 'private', value: priv }) + //const priv = metadata.private + store.dispatch('setInstanceOption', { name: 'private', value: false }) const frontendVersion = window.___pleromafe_commit_hash store.dispatch('setInstanceOption', { name: 'frontendVersion', value: frontendVersion }) const federation = metadata.federation - store.dispatch('setInstanceOption', { - name: 'tagPolicyAvailable', - value: typeof federation.mrf_policies === 'undefined' - ? false - : metadata.federation.mrf_policies.includes('TagPolicy') - }) + // store.dispatch('setInstanceOption', { + // name: 'tagPolicyAvailable', + // value: typeof federation.mrf_policies === 'undefined' + // ? false + // : metadata.federation.mrf_policies.includes('TagPolicy') + // }) - store.dispatch('setInstanceOption', { name: 'federationPolicy', value: federation }) - store.dispatch('setInstanceOption', { name: 'localBubbleInstances', value: metadata.localBubbleInstances }) - store.dispatch('setInstanceOption', { - name: 'federating', - value: typeof federation.enabled === 'undefined' - ? true - : federation.enabled - }) + // store.dispatch('setInstanceOption', { name: 'federationPolicy', value: federation }) + store.dispatch('setInstanceOption', { name: 'localBubbleInstances', value: [ ] }) + // store.dispatch('setInstanceOption', { + // name: 'federating', + // value: typeof federation.enabled === 'undefined' + // ? true + // : federation.enabled + // }) - store.dispatch('setInstanceOption', { name: 'publicTimelineVisibility', value: metadata.publicTimelineVisibility }) - store.dispatch('setInstanceOption', { name: 'federatedTimelineAvailable', value: metadata.federatedTimelineAvailable }) + store.dispatch('setInstanceOption', { name: 'publicTimelineVisibility', value: !metadata.disableLocalTimeline }) + store.dispatch('setInstanceOption', { name: 'federatedTimelineAvailable', value: metadata.disableGlobalTimeline }) const accountActivationRequired = metadata.accountActivationRequired store.dispatch('setInstanceOption', { name: 'accountActivationRequired', value: accountActivationRequired }) const accounts = metadata.staffAccounts - resolveStaffAccounts({ store, accounts }) + //resolveStaffAccounts({ store, accounts }) } else { throw (res) } @@ -400,7 +406,7 @@ const afterStoreSetup = async ({ store, i18n }) => { // Start fetching things that don't need to block the UI getTOS({ store }) - getStickers({ store }) + // getStickers({ store }) const router = createRouter({ history: createWebHistory(), diff --git a/src/components/status/status.js b/src/components/status/status.js index 9bb3364f..14ac78a3 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -441,7 +441,13 @@ const Status = { return this.$i18n.t('general.scope_in_timeline.' + this.status.visibility) }, isEdited () { - return this.status.edited_at !== null + if (this.status.hasOwnProperty('edited_at')) { + return this.status.edited_at !== null + } + else + { + return false + }; }, editingAvailable () { return this.$store.state.instance.editingAvailable @@ -452,10 +458,16 @@ const Status = { switch (visibility) { case 'private': return 'lock' + case 'followers': + return 'lock' case 'unlisted': return 'lock-open' + case 'home': + return 'lock-open' case 'direct': return 'envelope' + case 'specified': + return 'specified' case 'local': return 'users' default: diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index cdb35e08..1a5150e9 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -172,7 +172,7 @@ const Timeline = { fetchOlderStatuses: throttle( function () { const store = this.$store const credentials = store.state.users.currentUser.credentials - store.commit('setLoading', { timeline: this.timelineName, value: true }) + //store.commit('setLoading', { timeline: this.timelineName, value: true }) timelineFetcher.fetchAndUpdate({ store, credentials, diff --git a/src/modules/config.js b/src/modules/config.js index 91a966bd..45d42dc4 100644 --- a/src/modules/config.js +++ b/src/modules/config.js @@ -160,37 +160,37 @@ const config = { } }, actions: { - syncSettings: (store) => { - store.commit('setOption', { name: 'profileVersion', value: store.state.profileVersion + 1 }) - const notice = { - level: 'info', - messageKey: 'settings_profile.synchronizing', - messageArgs: { profile: store.state.profile }, - timeout: 5000 - } - store.dispatch('pushGlobalNotice', notice) - store.rootState.api.backendInteractor.saveSettingsProfile({ - settings: store.state, profileName: store.state.profile, version: store.state.profileVersion - }).then(() => { - store.dispatch('removeGlobalNotice', notice) - store.dispatch('pushGlobalNotice', { - level: 'success', - messageKey: 'settings_profile.synchronized', - messageArgs: { profile: store.state.profile }, - timeout: 2000 - }) - store.dispatch('listSettingsProfiles') - }).catch((err) => { - store.dispatch('removeGlobalNotice', notice) - store.dispatch('pushGlobalNotice', { - level: 'error', - messageKey: 'settings_profile.synchronization_error', - messageArgs: { error: err.message }, - timeout: 5000 - }) - console.error(err) - }) - }, + // syncSettings: (store) => { + // store.commit('setOption', { name: 'profileVersion', value: store.state.profileVersion + 1 }) + // const notice = { + // level: 'info', + // messageKey: 'settings_profile.synchronizing', + // messageArgs: { profile: store.state.profile }, + // timeout: 5000 + // } + // store.dispatch('pushGlobalNotice', notice) + // store.rootState.api.backendInteractor.saveSettingsProfile({ + // settings: store.state, profileName: store.state.profile, version: store.state.profileVersion + // }).then(() => { + // store.dispatch('removeGlobalNotice', notice) + // store.dispatch('pushGlobalNotice', { + // level: 'success', + // messageKey: 'settings_profile.synchronized', + // messageArgs: { profile: store.state.profile }, + // timeout: 2000 + // }) + // store.dispatch('listSettingsProfiles') + // }).catch((err) => { + // store.dispatch('removeGlobalNotice', notice) + // store.dispatch('pushGlobalNotice', { + // level: 'error', + // messageKey: 'settings_profile.synchronization_error', + // messageArgs: { error: err.message }, + // timeout: 5000 + // }) + // console.error(err) + // }) + // }, deleteSettingsProfile (store, name) { store.rootState.api.backendInteractor.deleteSettingsProfile({ profileName: name }).then(() => { store.dispatch('listSettingsProfiles') diff --git a/src/modules/instance.js b/src/modules/instance.js index 0c856352..03c83e68 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -177,22 +177,33 @@ const instance = { async getCustomEmoji ({ commit, state }) { try { - const res = await window.fetch('/api/v1/pleroma/emoji') + const res = await window.fetch('/api/emojis') if (res.ok) { const result = await res.json() - const values = Array.isArray(result) ? Object.assign({}, ...result) : result - const emoji = Object.entries(values).map(([key, value]) => { - const imageUrl = value.image_url - return { - displayText: key, - imageUrl: imageUrl ? state.server + imageUrl : value, - tags: imageUrl ? value.tags.sort((a, b) => a > b ? 1 : 0) : ['utf'], - replacement: `:${key}: ` - } - // Technically could use tags but those are kinda useless right now, - // should have been "pack" field, that would be more useful - }).sort((a, b) => a.displayText.toLowerCase() > b.displayText.toLowerCase() ? 1 : -1) - commit('setInstanceOption', { name: 'customEmoji', value: emoji }) + //const values = Array.isArray(result.emojis) ? Object.assign({}, ...result) : result + const values = result.emojis + var emoji = [] + for ( var i = 0; i < values.length; i++) { + emoji.push({ + displayText: values[i].name, + imageUrl: values[i].url, + replacement: values[i].name, + tags: ['sharkey'] + }) + } + + // const emoji = Object.entries(values).map(([key, value]) => { + // const imageUrl = value.image_url + // return { + // displayText: key, + // imageUrl: imageUrl ? state.server + imageUrl : value, + // tags: imageUrl ? value.tags.sort((a, b) => a > b ? 1 : 0) : ['utf'], + // replacement: `:${key}: ` + // } + // // Technically could use tags but those are kinda useless right now, + // // should have been "pack" field, that would be more useful + // }).sort((a, b) => a.displayText.toLowerCase() > b.displayText.toLowerCase() ? 1 : -1) + commit('setInstanceOption', { name: 'customEmoji', value: Object.assign(emoji) }) } else { throw (res) } diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 1080462c..97fc1d4d 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -191,10 +191,12 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us const addStatus = (data, showImmediately, addToTimeline = true) => { const result = addStatusToGlobalStorage(state, data) const status = result.item - + if (result.new) { // We are mentioned in a post + if (status.type === 'status' && find(status.attentions, { id: user.id })) { + const mentions = state.timelines.mentions // Add the mention to the mentions timeline @@ -205,6 +207,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us sortTimeline(mentions) } } + if (status.visibility === 'direct') { const dms = state.timelines.dms diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index de21ef3b..5adf1c66 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -53,7 +53,7 @@ const MASTODON_DENY_USER_URL = id => `/api/v1/follow_requests/${id}/reject` const MASTODON_DIRECT_MESSAGES_TIMELINE_URL = '/api/v1/timelines/direct' const MASTODON_PUBLIC_TIMELINE = '/api/v1/timelines/public' const MASTODON_USER_HOME_TIMELINE_URL = '/api/v1/timelines/home' -const AKKOMA_BUBBLE_TIMELINE_URL = '/api/v1/timelines/bubble' +const AKKOMA_BUBBLE_TIMELINE_URL = 'api/notes/bubble-timeline' const MASTODON_STATUS_URL = id => `/api/v1/statuses/${id}` const MASTODON_STATUS_CONTEXT_URL = id => `/api/v1/statuses/${id}/context` const MASTODON_STATUS_SOURCE_URL = id => `/api/v1/statuses/${id}/source` @@ -67,7 +67,7 @@ const MASTODON_LIST_ACCOUNTS_URL = id => `/api/v1/lists/${id}/accounts` const MASTODON_TAG_TIMELINE_URL = tag => `/api/v1/timelines/tag/${tag}` const MASTODON_BOOKMARK_TIMELINE_URL = '/api/v1/bookmarks' const MASTODON_USER_BLOCKS_URL = '/api/v1/blocks/' -const MASTODON_USER_MUTES_URL = '/api/v1/mutes/' +const MASTODON_USER_MUTES_URL = '/api/v1/mutes' const MASTODON_BLOCK_USER_URL = id => `/api/v1/accounts/${id}/block` const MASTODON_UNBLOCK_USER_URL = id => `/api/v1/accounts/${id}/unblock` const MASTODON_MUTE_USER_URL = id => `/api/v1/accounts/${id}/mute` @@ -79,6 +79,7 @@ const MASTODON_SET_NOTE_URL = id => `/api/v1/accounts/${id}/note` const MASTODON_BOOKMARK_STATUS_URL = id => `/api/v1/statuses/${id}/bookmark` const MASTODON_UNBOOKMARK_STATUS_URL = id => `/api/v1/statuses/${id}/unbookmark` const MASTODON_POST_STATUS_URL = '/api/v1/statuses' +const MISSKEY_POST_NOTE_URL = '/api/notes/create' const MASTODON_MEDIA_UPLOAD_URL = '/api/v1/media' const MASTODON_VOTE_URL = id => `/api/v1/polls/${id}/votes` const MASTODON_POLL_URL = id => `/api/v1/polls/${id}` @@ -103,8 +104,8 @@ const PLEROMA_EMOJI_REACTIONS_URL = id => `/api/v1/pleroma/statuses/${id}/reacti const PLEROMA_EMOJI_REACT_URL = (id, emoji) => `/api/v1/pleroma/statuses/${id}/reactions/${emoji}` const PLEROMA_EMOJI_UNREACT_URL = (id, emoji) => `/api/v1/pleroma/statuses/${id}/reactions/${emoji}` const PLEROMA_BACKUP_URL = '/api/v1/pleroma/backups' -const PLEROMA_ANNOUNCEMENTS_URL = '/api/v1/pleroma/admin/announcements' -const PLEROMA_POST_ANNOUNCEMENT_URL = '/api/v1/pleroma/admin/announcements' +const PLEROMA_ANNOUNCEMENTS_URL = '/api/announcements' +const PLEROMA_POST_ANNOUNCEMENT_URL = '/api/admin/announcements/create' const PLEROMA_EDIT_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}` const PLEROMA_DELETE_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}` const AKKOMA_SETTING_PROFILE_URL = (name) => `/api/v1/akkoma/frontend_settings/pleroma-fe/${name}` @@ -344,7 +345,7 @@ const fetchUser = ({ id, credentials }) => { } const fetchUserRelationship = ({ id, credentials }) => { - let url = `${MASTODON_USER_RELATIONSHIPS_URL}/?id=${id}` + let url = `${MASTODON_USER_RELATIONSHIPS_URL}?id=${id}` return fetch(url, { headers: authHeaders(credentials) }) .then((response) => { return new Promise((resolve, reject) => response.json() @@ -878,15 +879,30 @@ const postStatus = ({ const form = new FormData() const pollOptions = poll.options || [] - form.append('status', status) + form.append('text', status) form.append('source', 'Pleroma FE') - if (spoilerText) form.append('spoiler_text', spoilerText) - if (visibility) form.append('visibility', visibility) - if (sensitive) form.append('sensitive', sensitive) + if (spoilerText) form.append('cw', spoilerText) + if (visibility){ + var misskey_visibility = "public" + switch (visibility) { + case 'unlisted': + misskey_visibility = "home" + break; + case 'private': + misskey_visibility = "followers" + break; + case 'direct': + misskey_visibility = "specified" + break; + + } + form.append('visibility', misskey_visibility) + } + if (sensitive) form.append('cw', spoilerText) if (contentType) form.append('content_type', contentType) if (language) form.append('language', language) mediaIds.forEach(val => { - form.append('media_ids[]', val) + form.append('mediaIds[]', val) }) if (pollOptions.some(option => option !== '')) { const normalizedPoll = { @@ -902,7 +918,7 @@ const postStatus = ({ }) } if (inReplyToStatusId) { - form.append('in_reply_to_id', inReplyToStatusId) + form.append('replyId', inReplyToStatusId) } if (quoteId) { form.append('quote_id', quoteId) @@ -912,12 +928,13 @@ const postStatus = ({ } let postHeaders = authHeaders(credentials) + postHeaders["Content-Type"] = 'application/json' if (idempotencyKey) { postHeaders['idempotency-key'] = idempotencyKey } - return fetch(MASTODON_POST_STATUS_URL, { - body: form, + return fetch(MISSKEY_POST_NOTE_URL, { + body: JSON.stringify(Object.fromEntries(form)), method: 'POST', headers: postHeaders }) @@ -941,11 +958,11 @@ const editStatus = ({ const pollOptions = poll.options || [] form.append('status', status) - if (spoilerText) form.append('spoiler_text', spoilerText) - if (sensitive) form.append('sensitive', sensitive) + if (spoilerText) form.append('cw', spoilerText) + if (sensitive) form.append('cw', spoilerText) if (contentType) form.append('content_type', contentType) mediaIds.forEach(val => { - form.append('media_ids[]', val) + form.append('mediaIds[]', val) }) if (pollOptions.some(option => option !== '')) { diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 4fddd875..b4fc96be 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -96,7 +96,7 @@ export const parseUser = (data) => { output.instance = data.akkoma.instance output.status_ttl_days = data.akkoma.status_ttl_days } - + output.relationship = {} if (data.pleroma) { const relationship = data.pleroma.relationship @@ -261,8 +261,18 @@ export const parseSource = (data) => { return output } -export const parseStatus = (data) => { +export const parseStatus = (data_in) => { + var data = {} const output = {} + if (data_in.hasOwnProperty('createdNote')) + { + data = data_in.createdNote + data.is_post_verb = true // For status parser + } + else { + data = data_in + } + const masto = data.hasOwnProperty('account') if (masto) { @@ -282,8 +292,9 @@ export const parseStatus = (data) => { output.tags = data.tags - output.edited_at = data.edited_at - + output.edited_at = data.hasOwnProperty('edited_at') ? data.edited_at : null + output.emoji_reactions = data.hasOwnProperty('emoji_reactions') ? data.emoji_reactions : [] + if (data.pleroma) { const { pleroma } = data output.text = pleroma.content ? data.pleroma.content['text/plain'] : data.content @@ -297,6 +308,9 @@ export const parseStatus = (data) => { } else { output.text = data.content output.summary = data.spoiler_text + output.statusnet_conversation_id = ( data.hasOwnProperty('in_reply_to_id') && data.in_reply_to_id != null) ? data.in_reply_to_id : data.id + output.parent_visible = true + } if (data.akkoma) { @@ -398,7 +412,7 @@ export const parseStatus = (data) => { if (data.hasOwnProperty('originalStatus')) { Object.assign(output, data.originalStatus) } - + debugger; return output } @@ -412,7 +426,7 @@ export const parseNotification = (data) => { if (masto) { output.type = mastoDict[data.type] || data.type - output.seen = data.pleroma.is_seen + //output.seen = data.pleroma.is_seen if (data.status) { output.status = isStatusNotification(output.type) ? parseStatus(data.status) : null output.action = output.status // TODO: Refactor, this is unneeded diff --git a/static/config.json b/static/config.json index b1d412e7..d7d2b6dd 100644 --- a/static/config.json +++ b/static/config.json @@ -8,7 +8,7 @@ "hidePostStats": false, "hideSitename": false, "hideUserStats": false, - "loginMethod": "password", + "loginMethod": "token", "logo": "/static/logo.svg", "logoMargin": ".1em", "logoMask": true,