forked from FoundKeyGang/FoundKey
backend: improve documentation of pin/update functions
This commit is contained in:
parent
f17485d8a2
commit
f2f547172e
2 changed files with 21 additions and 11 deletions
|
@ -12,11 +12,11 @@ import { deliverToFollowers } from '@/remote/activitypub/deliver-manager.js';
|
|||
import { deliverToRelays } from '../relay.js';
|
||||
|
||||
/**
|
||||
* 指定した投稿をピン留めします
|
||||
* @param user
|
||||
* @param noteId
|
||||
* Pin a given post to a user profile.
|
||||
* @param user the user to pin the note to
|
||||
* @param noteId ID of note to pin
|
||||
*/
|
||||
export async function addPinned(user: { id: User['id']; host: User['host']; }, noteId: Note['id']) {
|
||||
export async function addPinned(user: { id: User['id']; host: User['host']; }, noteId: Note['id']): Promise<void> {
|
||||
// Fetch pinee
|
||||
const note = await Notes.findOneBy({
|
||||
id: noteId,
|
||||
|
@ -51,11 +51,11 @@ export async function addPinned(user: { id: User['id']; host: User['host']; }, n
|
|||
}
|
||||
|
||||
/**
|
||||
* 指定した投稿のピン留めを解除します
|
||||
* @param user
|
||||
* @param noteId
|
||||
* Unpin a given post from a user profile.
|
||||
* @param user the user to unpin a note from
|
||||
* @param noteId ID of note to unpin
|
||||
*/
|
||||
export async function removePinned(user: { id: User['id']; host: User['host']; }, noteId: Note['id']) {
|
||||
export async function removePinned(user: { id: User['id']; host: User['host']; }, noteId: Note['id']): Promise<void> {
|
||||
// Fetch unpinee
|
||||
const note = await Notes.findOneBy({
|
||||
id: noteId,
|
||||
|
@ -77,7 +77,13 @@ export async function removePinned(user: { id: User['id']; host: User['host']; }
|
|||
}
|
||||
}
|
||||
|
||||
export async function deliverPinnedChange(userId: User['id'], noteId: Note['id'], isAddition: boolean) {
|
||||
/**
|
||||
* Notify followers and relays when a note is pinned/unpinned.
|
||||
* @param userId ID of user
|
||||
* @param noteId ID of note
|
||||
* @param isAddition whether the note was pinned or unpinned
|
||||
*/
|
||||
export async function deliverPinnedChange(userId: User['id'], noteId: Note['id'], isAddition: boolean): Promise<void> {
|
||||
const user = await Users.findOneBy({ id: userId });
|
||||
if (user == null) throw new Error('user not found');
|
||||
|
||||
|
|
|
@ -6,11 +6,15 @@ import { renderPerson } from '@/remote/activitypub/renderer/person.js';
|
|||
import { deliverToFollowers } from '@/remote/activitypub/deliver-manager.js';
|
||||
import { deliverToRelays } from '../relay.js';
|
||||
|
||||
export async function publishToFollowers(userId: User['id']) {
|
||||
/**
|
||||
* Send an Update activity to a user's followers.
|
||||
* @param userId ID of user
|
||||
*/
|
||||
export async function publishToFollowers(userId: User['id']): Promise<void> {
|
||||
const user = await Users.findOneBy({ id: userId });
|
||||
if (user == null) throw new Error('user not found');
|
||||
|
||||
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーならUpdateを配信
|
||||
// Deliver Update if the follower is a remote user and the poster is a local user
|
||||
if (Users.isLocalUser(user)) {
|
||||
const content = renderActivity(renderUpdate(await renderPerson(user), user));
|
||||
deliverToFollowers(user, content);
|
||||
|
|
Loading…
Reference in a new issue