mirror of
https://iceshrimp.dev/iceshrimp/iceshrimp
synced 2024-12-12 13:48:10 +09:00
wip
This commit is contained in:
parent
207332d71f
commit
925815d67e
@ -31,7 +31,7 @@ export default async (user: IUser, content: {
|
|||||||
visibility?: string;
|
visibility?: string;
|
||||||
uri?: string;
|
uri?: string;
|
||||||
app?: IApp;
|
app?: IApp;
|
||||||
}) => new Promise<IPost>(async (res, rej) => {
|
}, silent = false) => new Promise<IPost>(async (res, rej) => {
|
||||||
if (content.createdAt == null) content.createdAt = new Date();
|
if (content.createdAt == null) content.createdAt = new Date();
|
||||||
if (content.visibility == null) content.visibility = 'public';
|
if (content.visibility == null) content.visibility = 'public';
|
||||||
|
|
||||||
@ -120,26 +120,28 @@ export default async (user: IUser, content: {
|
|||||||
_id: false
|
_id: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const note = await renderNote(user, post);
|
if (!silent) {
|
||||||
const content = renderCreate(note);
|
const note = await renderNote(user, post);
|
||||||
content['@context'] = context;
|
const content = renderCreate(note);
|
||||||
|
content['@context'] = context;
|
||||||
|
|
||||||
Promise.all(followers.map(({ follower }) => {
|
Promise.all(followers.map(({ follower }) => {
|
||||||
if (isLocalUser(follower)) {
|
if (isLocalUser(follower)) {
|
||||||
// Publish event to followers stream
|
// Publish event to followers stream
|
||||||
stream(follower._id, 'post', postObj);
|
stream(follower._id, 'post', postObj);
|
||||||
} else {
|
} else {
|
||||||
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーなら投稿を配信
|
// フォロワーがリモートユーザーかつ投稿者がローカルユーザーなら投稿を配信
|
||||||
if (isLocalUser(user)) {
|
if (isLocalUser(user)) {
|
||||||
createHttp({
|
createHttp({
|
||||||
type: 'deliver',
|
type: 'deliver',
|
||||||
user,
|
user,
|
||||||
content,
|
content,
|
||||||
to: follower.account.inbox
|
to: follower.account.inbox
|
||||||
}).save();
|
}).save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}));
|
||||||
}));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// チャンネルへの投稿
|
// チャンネルへの投稿
|
||||||
|
@ -58,7 +58,7 @@ async function createImage(resolver: Resolver, actor: IRemoteUser, image) {
|
|||||||
return await uploadFromUrl(image.url, actor);
|
return await uploadFromUrl(image.url, actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createNote(resolver: Resolver, actor: IRemoteUser, note) {
|
async function createNote(resolver: Resolver, actor: IRemoteUser, note, silent = false) {
|
||||||
if (
|
if (
|
||||||
('attributedTo' in note && actor.account.uri !== note.attributedTo) ||
|
('attributedTo' in note && actor.account.uri !== note.attributedTo) ||
|
||||||
typeof note.id !== 'string'
|
typeof note.id !== 'string'
|
||||||
@ -86,7 +86,7 @@ async function createNote(resolver: Resolver, actor: IRemoteUser, note) {
|
|||||||
const inReplyTo = await resolver.resolve(note.inReplyTo) as any;
|
const inReplyTo = await resolver.resolve(note.inReplyTo) as any;
|
||||||
const actor = await resolvePerson(inReplyTo.attributedTo);
|
const actor = await resolvePerson(inReplyTo.attributedTo);
|
||||||
if (isRemoteUser(actor)) {
|
if (isRemoteUser(actor)) {
|
||||||
reply = await createNote(resolver, actor, inReplyTo);
|
reply = await createNote(resolver, actor, inReplyTo, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -102,5 +102,5 @@ async function createNote(resolver: Resolver, actor: IRemoteUser, note) {
|
|||||||
viaMobile: false,
|
viaMobile: false,
|
||||||
geo: undefined,
|
geo: undefined,
|
||||||
uri: note.id
|
uri: note.id
|
||||||
});
|
}, silent);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user