ピン留めを解除することができるようにしたり

This commit is contained in:
syuilo
2018-09-24 16:26:12 +09:00
parent 7b4c307c46
commit 59d67d3140
6 changed files with 128 additions and 46 deletions

View File

@@ -7,7 +7,7 @@ import renderRemove from '../../remote/activitypub/renderer/remove';
import packAp from '../../remote/activitypub/renderer';
import { deliver } from '../../queue';
export async function deliverPinnedChange(userId: mongo.ObjectID, oldId?: mongo.ObjectID, newId?: mongo.ObjectID) {
export async function deliverPinnedChange(userId: mongo.ObjectID, noteId: mongo.ObjectID, isAddition: boolean) {
const user = await User.findOne({
_id: userId
});
@@ -20,21 +20,11 @@ export async function deliverPinnedChange(userId: mongo.ObjectID, oldId?: mongo.
const target = `${config.url}/users/${user._id}/collections/featured`;
if (oldId) {
const oldItem = `${config.url}/notes/${oldId}`;
const content = packAp(renderRemove(user, target, oldItem));
queue.forEach(inbox => {
deliver(user, content, inbox);
});
}
if (newId) {
const newItem = `${config.url}/notes/${newId}`;
const content = packAp(renderAdd(user, target, newItem));
queue.forEach(inbox => {
deliver(user, content, inbox);
});
}
const item = `${config.url}/notes/${noteId}`;
const content = packAp(isAddition ? renderAdd(user, target, item) : renderRemove(user, target, item));
queue.forEach(inbox => {
deliver(user, content, inbox);
});
}
/**