Initial POC

This commit is contained in:
Alex 2024-01-06 17:04:16 -05:00
parent 8dce31d0ad
commit 334ec7175e
12 changed files with 237 additions and 119 deletions

View file

@ -1 +1 @@
7.2.1 16

11
Dockerfile Normal file
View file

@ -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

44
nginx.conf Normal file
View file

@ -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;
#}
}

View file

@ -70,9 +70,10 @@ const getInstanceConfig = async ({ store }) => {
const res = await preloadFetch('/api/v1/instance') const res = await preloadFetch('/api/v1/instance')
if (res.ok) { if (res.ok) {
const data = await res.json() const data = await res.json()
const textlimit = data.max_toot_chars const textlimit = data.configuration.statuses.max_characters
const vapidPublicKey = data.pleroma.vapid_public_key //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: 'textlimit', value: textlimit })
store.dispatch('setInstanceOption', { name: 'accountApprovalRequired', value: data.approval_required }) store.dispatch('setInstanceOption', { name: 'accountApprovalRequired', value: data.approval_required })
// don't override cookie if set // don't override cookie if set
@ -94,9 +95,10 @@ const getInstanceConfig = async ({ store }) => {
const getBackendProvidedConfig = async ({ store }) => { const getBackendProvidedConfig = async ({ store }) => {
try { try {
const res = await window.fetch('/api/pleroma/frontend_configurations') //const res = await window.fetch('/api/pleroma/frontend_configurations')
if (res.ok) { if (true) {
const data = await res.json() //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 return data.pleroma_fe
} else { } else {
throw (res) throw (res)
@ -265,71 +267,75 @@ const resolveStaffAccounts = ({ store, accounts }) => {
const getNodeInfo = async ({ store }) => { const getNodeInfo = async ({ store }) => {
try { 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) { if (res.ok) {
const data = await res.json() const data = await res.json()
const metadata = data.metadata const metadata = data.metadata
const features = metadata.features //const features = data.configuration
store.dispatch('setInstanceOption', { name: 'name', value: metadata.nodeName }) store.dispatch('setInstanceOption', { name: 'name', value: metadata.nodeName })
store.dispatch('setInstanceOption', { name: 'registrationOpen', value: data.openRegistrations }) store.dispatch('setInstanceOption', { name: 'registrationOpen', value: !data.disableRegistration })
store.dispatch('setInstanceOption', { name: 'mediaProxyAvailable', value: features.includes('media_proxy') }) store.dispatch('setInstanceOption', { name: 'mediaProxyAvailable', value: false })
store.dispatch('setInstanceOption', { name: 'safeDM', value: features.includes('safe_dm_mentions') }) store.dispatch('setInstanceOption', { name: 'safeDM', value: false })
store.dispatch('setInstanceOption', { name: 'pollsAvailable', value: features.includes('polls') }) store.dispatch('setInstanceOption', { name: 'pollsAvailable', value: true })
store.dispatch('setInstanceOption', { name: 'editingAvailable', value: features.includes('editing') }) store.dispatch('setInstanceOption', { name: 'editingAvailable', value: true })
store.dispatch('setInstanceOption', { name: 'pollLimits', value: metadata.pollLimits }) //store.dispatch('setInstanceOption', { name: 'pollLimits', value: configuration.polls })
store.dispatch('setInstanceOption', { name: 'mailerEnabled', value: metadata.mailerEnabled }) store.dispatch('setInstanceOption', { name: 'mailerEnabled', value: metadata.enableEmail })
store.dispatch('setInstanceOption', { name: 'translationEnabled', value: features.includes('akkoma:machine_translation') }) store.dispatch('setInstanceOption', { name: 'translationEnabled', value: false })
const uploadLimits = metadata.uploadLimits // const uploadLimits = metadata.uploadLimits
store.dispatch('setInstanceOption', { name: 'uploadlimit', value: parseInt(uploadLimits.general) }) // store.dispatch('setInstanceOption', { name: 'uploadlimit', value: parseInt(configuration.media_attachments.image_size_limit) })
store.dispatch('setInstanceOption', { name: 'avatarlimit', value: parseInt(uploadLimits.avatar) }) // store.dispatch('setInstanceOption', { name: 'avatarlimit', value: parseInt(configuration.media_attachments.image_size_limit) })
store.dispatch('setInstanceOption', { name: 'backgroundlimit', value: parseInt(uploadLimits.background) }) // store.dispatch('setInstanceOption', { name: 'backgroundlimit', value: parseInt(configuration.media_attachments.image_size_limit) })
store.dispatch('setInstanceOption', { name: 'bannerlimit', value: parseInt(uploadLimits.banner) }) // 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: 'fieldsLimits', value: metadata.fieldsLimits })
store.dispatch('setInstanceOption', { name: 'restrictedNicknames', value: metadata.restrictedNicknames }) store.dispatch('setInstanceOption', { name: 'restrictedNicknames', value: ["admin","instance.actor","instance.relay"] })
store.dispatch('setInstanceOption', { name: 'postFormats', value: metadata.postFormats }) store.dispatch('setInstanceOption', { name: 'postFormats', value: ["text/x.misskeymarkdown"] })
const suggestions = metadata.suggestions //const suggestions = metadata.suggestions
store.dispatch('setInstanceOption', { name: 'suggestionsEnabled', value: suggestions.enabled }) store.dispatch('setInstanceOption', { name: 'suggestionsEnabled', value: false })
store.dispatch('setInstanceOption', { name: 'suggestionsWeb', value: suggestions.web }) store.dispatch('setInstanceOption', { name: 'suggestionsWeb', value: false })
const software = data.software const software = data.software
store.dispatch('setInstanceOption', { name: 'backendVersion', value: software.version }) store.dispatch('setInstanceOption', { name: 'backendVersion', value: software.version })
store.dispatch('setInstanceOption', { name: 'pleromaBackend', value: software.name === 'pleroma' }) store.dispatch('setInstanceOption', { name: 'pleromaBackend', value: software.name === 'pleroma' })
const priv = metadata.private //const priv = metadata.private
store.dispatch('setInstanceOption', { name: 'private', value: priv }) store.dispatch('setInstanceOption', { name: 'private', value: false })
const frontendVersion = window.___pleromafe_commit_hash const frontendVersion = window.___pleromafe_commit_hash
store.dispatch('setInstanceOption', { name: 'frontendVersion', value: frontendVersion }) store.dispatch('setInstanceOption', { name: 'frontendVersion', value: frontendVersion })
const federation = metadata.federation const federation = metadata.federation
store.dispatch('setInstanceOption', { // store.dispatch('setInstanceOption', {
name: 'tagPolicyAvailable', // name: 'tagPolicyAvailable',
value: typeof federation.mrf_policies === 'undefined' // value: typeof federation.mrf_policies === 'undefined'
? false // ? false
: metadata.federation.mrf_policies.includes('TagPolicy') // : metadata.federation.mrf_policies.includes('TagPolicy')
}) // })
store.dispatch('setInstanceOption', { name: 'federationPolicy', value: federation }) // store.dispatch('setInstanceOption', { name: 'federationPolicy', value: federation })
store.dispatch('setInstanceOption', { name: 'localBubbleInstances', value: metadata.localBubbleInstances }) store.dispatch('setInstanceOption', { name: 'localBubbleInstances', value: [ ] })
store.dispatch('setInstanceOption', { // store.dispatch('setInstanceOption', {
name: 'federating', // name: 'federating',
value: typeof federation.enabled === 'undefined' // value: typeof federation.enabled === 'undefined'
? true // ? true
: federation.enabled // : federation.enabled
}) // })
store.dispatch('setInstanceOption', { name: 'publicTimelineVisibility', value: metadata.publicTimelineVisibility }) store.dispatch('setInstanceOption', { name: 'publicTimelineVisibility', value: !metadata.disableLocalTimeline })
store.dispatch('setInstanceOption', { name: 'federatedTimelineAvailable', value: metadata.federatedTimelineAvailable }) store.dispatch('setInstanceOption', { name: 'federatedTimelineAvailable', value: metadata.disableGlobalTimeline })
const accountActivationRequired = metadata.accountActivationRequired const accountActivationRequired = metadata.accountActivationRequired
store.dispatch('setInstanceOption', { name: 'accountActivationRequired', value: accountActivationRequired }) store.dispatch('setInstanceOption', { name: 'accountActivationRequired', value: accountActivationRequired })
const accounts = metadata.staffAccounts const accounts = metadata.staffAccounts
resolveStaffAccounts({ store, accounts }) //resolveStaffAccounts({ store, accounts })
} else { } else {
throw (res) throw (res)
} }
@ -400,7 +406,7 @@ const afterStoreSetup = async ({ store, i18n }) => {
// Start fetching things that don't need to block the UI // Start fetching things that don't need to block the UI
getTOS({ store }) getTOS({ store })
getStickers({ store }) // getStickers({ store })
const router = createRouter({ const router = createRouter({
history: createWebHistory(), history: createWebHistory(),

View file

@ -441,7 +441,13 @@ const Status = {
return this.$i18n.t('general.scope_in_timeline.' + this.status.visibility) return this.$i18n.t('general.scope_in_timeline.' + this.status.visibility)
}, },
isEdited () { isEdited () {
return this.status.edited_at !== null if (this.status.hasOwnProperty('edited_at')) {
return this.status.edited_at !== null
}
else
{
return false
};
}, },
editingAvailable () { editingAvailable () {
return this.$store.state.instance.editingAvailable return this.$store.state.instance.editingAvailable
@ -452,10 +458,16 @@ const Status = {
switch (visibility) { switch (visibility) {
case 'private': case 'private':
return 'lock' return 'lock'
case 'followers':
return 'lock'
case 'unlisted': case 'unlisted':
return 'lock-open' return 'lock-open'
case 'home':
return 'lock-open'
case 'direct': case 'direct':
return 'envelope' return 'envelope'
case 'specified':
return 'specified'
case 'local': case 'local':
return 'users' return 'users'
default: default:

View file

@ -172,7 +172,7 @@ const Timeline = {
fetchOlderStatuses: throttle( function () { fetchOlderStatuses: throttle( function () {
const store = this.$store const store = this.$store
const credentials = store.state.users.currentUser.credentials 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({ timelineFetcher.fetchAndUpdate({
store, store,
credentials, credentials,

View file

@ -160,37 +160,37 @@ const config = {
} }
}, },
actions: { actions: {
syncSettings: (store) => { // syncSettings: (store) => {
store.commit('setOption', { name: 'profileVersion', value: store.state.profileVersion + 1 }) // store.commit('setOption', { name: 'profileVersion', value: store.state.profileVersion + 1 })
const notice = { // const notice = {
level: 'info', // level: 'info',
messageKey: 'settings_profile.synchronizing', // messageKey: 'settings_profile.synchronizing',
messageArgs: { profile: store.state.profile }, // messageArgs: { profile: store.state.profile },
timeout: 5000 // timeout: 5000
} // }
store.dispatch('pushGlobalNotice', notice) // store.dispatch('pushGlobalNotice', notice)
store.rootState.api.backendInteractor.saveSettingsProfile({ // store.rootState.api.backendInteractor.saveSettingsProfile({
settings: store.state, profileName: store.state.profile, version: store.state.profileVersion // settings: store.state, profileName: store.state.profile, version: store.state.profileVersion
}).then(() => { // }).then(() => {
store.dispatch('removeGlobalNotice', notice) // store.dispatch('removeGlobalNotice', notice)
store.dispatch('pushGlobalNotice', { // store.dispatch('pushGlobalNotice', {
level: 'success', // level: 'success',
messageKey: 'settings_profile.synchronized', // messageKey: 'settings_profile.synchronized',
messageArgs: { profile: store.state.profile }, // messageArgs: { profile: store.state.profile },
timeout: 2000 // timeout: 2000
}) // })
store.dispatch('listSettingsProfiles') // store.dispatch('listSettingsProfiles')
}).catch((err) => { // }).catch((err) => {
store.dispatch('removeGlobalNotice', notice) // store.dispatch('removeGlobalNotice', notice)
store.dispatch('pushGlobalNotice', { // store.dispatch('pushGlobalNotice', {
level: 'error', // level: 'error',
messageKey: 'settings_profile.synchronization_error', // messageKey: 'settings_profile.synchronization_error',
messageArgs: { error: err.message }, // messageArgs: { error: err.message },
timeout: 5000 // timeout: 5000
}) // })
console.error(err) // console.error(err)
}) // })
}, // },
deleteSettingsProfile (store, name) { deleteSettingsProfile (store, name) {
store.rootState.api.backendInteractor.deleteSettingsProfile({ profileName: name }).then(() => { store.rootState.api.backendInteractor.deleteSettingsProfile({ profileName: name }).then(() => {
store.dispatch('listSettingsProfiles') store.dispatch('listSettingsProfiles')

View file

@ -177,22 +177,33 @@ const instance = {
async getCustomEmoji ({ commit, state }) { async getCustomEmoji ({ commit, state }) {
try { try {
const res = await window.fetch('/api/v1/pleroma/emoji') const res = await window.fetch('/api/emojis')
if (res.ok) { if (res.ok) {
const result = await res.json() const result = await res.json()
const values = Array.isArray(result) ? Object.assign({}, ...result) : result //const values = Array.isArray(result.emojis) ? Object.assign({}, ...result) : result
const emoji = Object.entries(values).map(([key, value]) => { const values = result.emojis
const imageUrl = value.image_url var emoji = []
return { for ( var i = 0; i < values.length; i++) {
displayText: key, emoji.push({
imageUrl: imageUrl ? state.server + imageUrl : value, displayText: values[i].name,
tags: imageUrl ? value.tags.sort((a, b) => a > b ? 1 : 0) : ['utf'], imageUrl: values[i].url,
replacement: `:${key}: ` replacement: values[i].name,
} tags: ['sharkey']
// 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 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 { } else {
throw (res) throw (res)
} }

View file

@ -191,10 +191,12 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
const addStatus = (data, showImmediately, addToTimeline = true) => { const addStatus = (data, showImmediately, addToTimeline = true) => {
const result = addStatusToGlobalStorage(state, data) const result = addStatusToGlobalStorage(state, data)
const status = result.item const status = result.item
if (result.new) { if (result.new) {
// We are mentioned in a post // We are mentioned in a post
if (status.type === 'status' && find(status.attentions, { id: user.id })) { if (status.type === 'status' && find(status.attentions, { id: user.id })) {
const mentions = state.timelines.mentions const mentions = state.timelines.mentions
// Add the mention to the mentions timeline // Add the mention to the mentions timeline
@ -205,6 +207,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
sortTimeline(mentions) sortTimeline(mentions)
} }
} }
if (status.visibility === 'direct') { if (status.visibility === 'direct') {
const dms = state.timelines.dms const dms = state.timelines.dms

View file

@ -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_DIRECT_MESSAGES_TIMELINE_URL = '/api/v1/timelines/direct'
const MASTODON_PUBLIC_TIMELINE = '/api/v1/timelines/public' const MASTODON_PUBLIC_TIMELINE = '/api/v1/timelines/public'
const MASTODON_USER_HOME_TIMELINE_URL = '/api/v1/timelines/home' 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_URL = id => `/api/v1/statuses/${id}`
const MASTODON_STATUS_CONTEXT_URL = id => `/api/v1/statuses/${id}/context` const MASTODON_STATUS_CONTEXT_URL = id => `/api/v1/statuses/${id}/context`
const MASTODON_STATUS_SOURCE_URL = id => `/api/v1/statuses/${id}/source` 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_TAG_TIMELINE_URL = tag => `/api/v1/timelines/tag/${tag}`
const MASTODON_BOOKMARK_TIMELINE_URL = '/api/v1/bookmarks' const MASTODON_BOOKMARK_TIMELINE_URL = '/api/v1/bookmarks'
const MASTODON_USER_BLOCKS_URL = '/api/v1/blocks/' 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_BLOCK_USER_URL = id => `/api/v1/accounts/${id}/block`
const MASTODON_UNBLOCK_USER_URL = id => `/api/v1/accounts/${id}/unblock` const MASTODON_UNBLOCK_USER_URL = id => `/api/v1/accounts/${id}/unblock`
const MASTODON_MUTE_USER_URL = id => `/api/v1/accounts/${id}/mute` 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_BOOKMARK_STATUS_URL = id => `/api/v1/statuses/${id}/bookmark`
const MASTODON_UNBOOKMARK_STATUS_URL = id => `/api/v1/statuses/${id}/unbookmark` const MASTODON_UNBOOKMARK_STATUS_URL = id => `/api/v1/statuses/${id}/unbookmark`
const MASTODON_POST_STATUS_URL = '/api/v1/statuses' 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_MEDIA_UPLOAD_URL = '/api/v1/media'
const MASTODON_VOTE_URL = id => `/api/v1/polls/${id}/votes` const MASTODON_VOTE_URL = id => `/api/v1/polls/${id}/votes`
const MASTODON_POLL_URL = id => `/api/v1/polls/${id}` 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_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_EMOJI_UNREACT_URL = (id, emoji) => `/api/v1/pleroma/statuses/${id}/reactions/${emoji}`
const PLEROMA_BACKUP_URL = '/api/v1/pleroma/backups' const PLEROMA_BACKUP_URL = '/api/v1/pleroma/backups'
const PLEROMA_ANNOUNCEMENTS_URL = '/api/v1/pleroma/admin/announcements' const PLEROMA_ANNOUNCEMENTS_URL = '/api/announcements'
const PLEROMA_POST_ANNOUNCEMENT_URL = '/api/v1/pleroma/admin/announcements' const PLEROMA_POST_ANNOUNCEMENT_URL = '/api/admin/announcements/create'
const PLEROMA_EDIT_ANNOUNCEMENT_URL = id => `/api/v1/pleroma/admin/announcements/${id}` 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 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}` 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 }) => { 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) }) return fetch(url, { headers: authHeaders(credentials) })
.then((response) => { .then((response) => {
return new Promise((resolve, reject) => response.json() return new Promise((resolve, reject) => response.json()
@ -878,15 +879,30 @@ const postStatus = ({
const form = new FormData() const form = new FormData()
const pollOptions = poll.options || [] const pollOptions = poll.options || []
form.append('status', status) form.append('text', status)
form.append('source', 'Pleroma FE') form.append('source', 'Pleroma FE')
if (spoilerText) form.append('spoiler_text', spoilerText) if (spoilerText) form.append('cw', spoilerText)
if (visibility) form.append('visibility', visibility) if (visibility){
if (sensitive) form.append('sensitive', sensitive) 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 (contentType) form.append('content_type', contentType)
if (language) form.append('language', language) if (language) form.append('language', language)
mediaIds.forEach(val => { mediaIds.forEach(val => {
form.append('media_ids[]', val) form.append('mediaIds[]', val)
}) })
if (pollOptions.some(option => option !== '')) { if (pollOptions.some(option => option !== '')) {
const normalizedPoll = { const normalizedPoll = {
@ -902,7 +918,7 @@ const postStatus = ({
}) })
} }
if (inReplyToStatusId) { if (inReplyToStatusId) {
form.append('in_reply_to_id', inReplyToStatusId) form.append('replyId', inReplyToStatusId)
} }
if (quoteId) { if (quoteId) {
form.append('quote_id', quoteId) form.append('quote_id', quoteId)
@ -912,12 +928,13 @@ const postStatus = ({
} }
let postHeaders = authHeaders(credentials) let postHeaders = authHeaders(credentials)
postHeaders["Content-Type"] = 'application/json'
if (idempotencyKey) { if (idempotencyKey) {
postHeaders['idempotency-key'] = idempotencyKey postHeaders['idempotency-key'] = idempotencyKey
} }
return fetch(MASTODON_POST_STATUS_URL, { return fetch(MISSKEY_POST_NOTE_URL, {
body: form, body: JSON.stringify(Object.fromEntries(form)),
method: 'POST', method: 'POST',
headers: postHeaders headers: postHeaders
}) })
@ -941,11 +958,11 @@ const editStatus = ({
const pollOptions = poll.options || [] const pollOptions = poll.options || []
form.append('status', status) form.append('status', status)
if (spoilerText) form.append('spoiler_text', spoilerText) if (spoilerText) form.append('cw', spoilerText)
if (sensitive) form.append('sensitive', sensitive) if (sensitive) form.append('cw', spoilerText)
if (contentType) form.append('content_type', contentType) if (contentType) form.append('content_type', contentType)
mediaIds.forEach(val => { mediaIds.forEach(val => {
form.append('media_ids[]', val) form.append('mediaIds[]', val)
}) })
if (pollOptions.some(option => option !== '')) { if (pollOptions.some(option => option !== '')) {

View file

@ -96,7 +96,7 @@ export const parseUser = (data) => {
output.instance = data.akkoma.instance output.instance = data.akkoma.instance
output.status_ttl_days = data.akkoma.status_ttl_days output.status_ttl_days = data.akkoma.status_ttl_days
} }
output.relationship = {}
if (data.pleroma) { if (data.pleroma) {
const relationship = data.pleroma.relationship const relationship = data.pleroma.relationship
@ -261,8 +261,18 @@ export const parseSource = (data) => {
return output return output
} }
export const parseStatus = (data) => { export const parseStatus = (data_in) => {
var data = {}
const output = {} 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') const masto = data.hasOwnProperty('account')
if (masto) { if (masto) {
@ -282,8 +292,9 @@ export const parseStatus = (data) => {
output.tags = data.tags 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) { if (data.pleroma) {
const { pleroma } = data const { pleroma } = data
output.text = pleroma.content ? data.pleroma.content['text/plain'] : data.content output.text = pleroma.content ? data.pleroma.content['text/plain'] : data.content
@ -297,6 +308,9 @@ export const parseStatus = (data) => {
} else { } else {
output.text = data.content output.text = data.content
output.summary = data.spoiler_text 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) { if (data.akkoma) {
@ -398,7 +412,7 @@ export const parseStatus = (data) => {
if (data.hasOwnProperty('originalStatus')) { if (data.hasOwnProperty('originalStatus')) {
Object.assign(output, data.originalStatus) Object.assign(output, data.originalStatus)
} }
debugger;
return output return output
} }
@ -412,7 +426,7 @@ export const parseNotification = (data) => {
if (masto) { if (masto) {
output.type = mastoDict[data.type] || data.type output.type = mastoDict[data.type] || data.type
output.seen = data.pleroma.is_seen //output.seen = data.pleroma.is_seen
if (data.status) { if (data.status) {
output.status = isStatusNotification(output.type) ? parseStatus(data.status) : null output.status = isStatusNotification(output.type) ? parseStatus(data.status) : null
output.action = output.status // TODO: Refactor, this is unneeded output.action = output.status // TODO: Refactor, this is unneeded

View file

@ -8,7 +8,7 @@
"hidePostStats": false, "hidePostStats": false,
"hideSitename": false, "hideSitename": false,
"hideUserStats": false, "hideUserStats": false,
"loginMethod": "password", "loginMethod": "token",
"logo": "/static/logo.svg", "logo": "/static/logo.svg",
"logoMargin": ".1em", "logoMargin": ".1em",
"logoMask": true, "logoMask": true,