add biting support for users and notes

This commit is contained in:
notfire 2024-12-01 13:26:14 -05:00
parent 0e25b94186
commit bb3cc22732
Signed by: notfire
GPG key ID: 3AFDACAAB4E56B16
8 changed files with 61 additions and 2 deletions

View file

@ -9,7 +9,8 @@ import {
faShareAlt,
faExternalLinkAlt,
faHistory,
faFilePen
faFilePen,
faTooth
} from '@fortawesome/free-solid-svg-icons'
import {
faBookmark as faBookmarkReg,
@ -27,7 +28,8 @@ library.add(
faExternalLinkAlt,
faFlag,
faHistory,
faFilePen
faFilePen,
faTooth
)
const ExtraButtons = {
@ -163,6 +165,9 @@ const ExtraButtons = {
},
hideRedraftStatusConfirmDialog () {
this.showingRedraftDialog = false
},
biteNote () {
this.$store.dispatch('biteNote', this.status.id)
}
},
computed: {

View file

@ -9,6 +9,17 @@
>
<template #content="{close}">
<div class="dropdown-menu">
<button
v-if="!ownStatus"
class="button-default dropdown-item dropdown-item-icon"
@click.prevent="biteNote"
@click="close"
>
<FAIcon
fixed-width
icon="tooth"
/><span>{{ $t("status.bite_note") }}</span>
</button>
<button
v-if="canMute && !status.thread_muted"
class="button-default dropdown-item dropdown-item-icon"

View file

@ -193,6 +193,9 @@ export default {
},
mentionUser () {
this.$store.dispatch('openPostStatusModal', { replyTo: true, repliedUser: this.user })
},
biteUser () {
return this.$store.dispatch('biteUser', this.user.id)
}
}
}

View file

@ -252,6 +252,15 @@
{{ $t('user_card.mention') }}
</button>
</div>
<div>
<button
class="btn button-default btn-block"
:disabled="user.deactivated || relationship.blocked_by"
@click="biteUser"
>
{{ $t('user_card.bite') }}
</button>
</div>
<ModerationTools
v-if="loggedIn.role === 'admin'"
:user="user"

View file

@ -961,6 +961,7 @@
"ancestor_follow": "See {numReplies} other reply under this post | See {numReplies} other replies under this post",
"ancestor_follow_with_icon": "{icon} {text}",
"attachment_stop_flash": "Stop Flash player",
"bite_note": "Bite",
"bookmark": "Bookmark",
"collapse_attachments": "Collapse attachments",
"copy_link": "Copy link to post",
@ -1124,6 +1125,7 @@
"approve_confirm_accept_button": "Yes, accept",
"approve_confirm_cancel_button": "No, cancel",
"approve_confirm_title": "Approve follow request",
"bite": "Bite",
"block": "Block",
"block_confirm": "Are you sure you want to block {user}?",
"block_confirm_accept_button": "Yes, block",

View file

@ -776,6 +776,9 @@ const statuses = {
},
setVirtualHeight ({ commit }, { statusId, height }) {
commit('setVirtualHeight', { statusId, height })
},
biteNote (store, id) {
return store.rootState.api.backendInteractor.biteNote({ id })
}
},
mutations

View file

@ -54,6 +54,10 @@ const unblockUser = (store, id) => {
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
}
const biteUser = (store, id) => {
return store.rootState.api.backendInteractor.biteUser({ id })
}
const removeUserFromFollowers = (store, id) => {
return store.rootState.api.backendInteractor.removeUserFromFollowers({ id })
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
@ -380,6 +384,9 @@ const users = {
unblockUsers (store, ids = []) {
return Promise.all(ids.map(id => unblockUser(store, id)))
},
biteUser (store, id) {
return biteUser(store, id)
},
fetchMutes (store, args) {
const { reset } = args || {}

View file

@ -72,6 +72,8 @@ 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`
const MASTODON_UNMUTE_USER_URL = id => `/api/v1/accounts/${id}/unmute`
const MASTODON_BITE_USER_URL = id => `/api/v1/users/${id}/bite`
const MASTODON_BITE_NOTE_URL = id => `/api/v1/statuses/${id}/bite`
const MASTODON_REMOVE_USER_FROM_FOLLOWERS = id => `/api/v1/accounts/${id}/remove_from_followers`
const MASTODON_SUBSCRIBE_USER = id => `/api/v1/pleroma/accounts/${id}/subscribe`
const MASTODON_UNSUBSCRIBE_USER = id => `/api/v1/pleroma/accounts/${id}/unsubscribe`
@ -314,6 +316,21 @@ const unblockUser = ({ id, credentials }) => {
}).then((data) => data.json())
}
const biteUser = ({ id, credentials }) => {
return fetch(MASTODON_BITE_USER_URL(id), {
headers: authHeaders(credentials),
method: 'POST'
}).then((data) => data.json())
}
const biteNote = ({ id, credentials }) => {
return fetch(MASTODON_BITE_NOTE_URL(id), {
headers: authHeaders(credentials),
method: 'POST'
}).then((data) => data.json())
}
const removeUserFromFollowers = ({ id, credentials }) => {
return fetch(MASTODON_REMOVE_USER_FROM_FOLLOWERS(id), {
headers: authHeaders(credentials),
@ -1760,6 +1777,8 @@ const apiService = {
unmuteConversation,
blockUser,
unblockUser,
biteUser,
biteNote,
removeUserFromFollowers,
fetchUser,
fetchUserRelationship,