Fix: Hashtagがupdateできない (#5285)
This commit is contained in:
parent
59493a0cd9
commit
fc78c75bab
1 changed files with 19 additions and 19 deletions
|
@ -13,7 +13,7 @@ export async function updateHashtag(user: User, tag: string, isUserAttached = fa
|
||||||
|
|
||||||
if (index != null) {
|
if (index != null) {
|
||||||
const q = Hashtags.createQueryBuilder('tag').update()
|
const q = Hashtags.createQueryBuilder('tag').update()
|
||||||
.where('tag.name = :name', { name: tag });
|
.where('name = :name', { name: tag });
|
||||||
|
|
||||||
const set = {} as any;
|
const set = {} as any;
|
||||||
|
|
||||||
|
@ -21,45 +21,45 @@ export async function updateHashtag(user: User, tag: string, isUserAttached = fa
|
||||||
if (inc) {
|
if (inc) {
|
||||||
// 自分が初めてこのタグを使ったなら
|
// 自分が初めてこのタグを使ったなら
|
||||||
if (!index.attachedUserIds.some(id => id === user.id)) {
|
if (!index.attachedUserIds.some(id => id === user.id)) {
|
||||||
set.attachedUserIds = () => `array_append(tag.attachedUserIds, '${user.id}')`;
|
set.attachedUserIds = () => `array_append("attachedUserIds", '${user.id}')`;
|
||||||
set.attachedUsersCount = () => `tag.attachedUsersCount + 1`;
|
set.attachedUsersCount = () => `"attachedUsersCount" + 1`;
|
||||||
}
|
}
|
||||||
// 自分が(ローカル内で)初めてこのタグを使ったなら
|
// 自分が(ローカル内で)初めてこのタグを使ったなら
|
||||||
if (Users.isLocalUser(user) && !index.attachedLocalUserIds.some(id => id === user.id)) {
|
if (Users.isLocalUser(user) && !index.attachedLocalUserIds.some(id => id === user.id)) {
|
||||||
set.attachedLocalUserIds = () => `array_append(tag.attachedLocalUserIds, '${user.id}')`;
|
set.attachedLocalUserIds = () => `array_append("attachedLocalUserIds", '${user.id}')`;
|
||||||
set.attachedLocalUsersCount = () => `tag.attachedLocalUsersCount + 1`;
|
set.attachedLocalUsersCount = () => `"attachedLocalUsersCount" + 1`;
|
||||||
}
|
}
|
||||||
// 自分が(リモートで)初めてこのタグを使ったなら
|
// 自分が(リモートで)初めてこのタグを使ったなら
|
||||||
if (Users.isRemoteUser(user) && !index.attachedRemoteUserIds.some(id => id === user.id)) {
|
if (Users.isRemoteUser(user) && !index.attachedRemoteUserIds.some(id => id === user.id)) {
|
||||||
set.attachedRemoteUserIds = () => `array_append(tag.attachedRemoteUserIds, '${user.id}')`;
|
set.attachedRemoteUserIds = () => `array_append("attachedRemoteUserIds", '${user.id}')`;
|
||||||
set.attachedRemoteUsersCount = () => `tag.attachedRemoteUsersCount + 1`;
|
set.attachedRemoteUsersCount = () => `"attachedRemoteUsersCount" + 1`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
set.attachedUserIds = () => `array_remove(tag.attachedUserIds, '${user.id}')`;
|
set.attachedUserIds = () => `array_remove("attachedUserIds", '${user.id}')`;
|
||||||
set.attachedUsersCount = () => `tag.attachedUsersCount - 1`;
|
set.attachedUsersCount = () => `"attachedUsersCount" - 1`;
|
||||||
if (Users.isLocalUser(user)) {
|
if (Users.isLocalUser(user)) {
|
||||||
set.attachedLocalUserIds = () => `array_remove(tag.attachedLocalUserIds, '${user.id}')`;
|
set.attachedLocalUserIds = () => `array_remove("attachedLocalUserIds", '${user.id}')`;
|
||||||
set.attachedLocalUsersCount = () => `tag.attachedLocalUsersCount - 1`;
|
set.attachedLocalUsersCount = () => `"attachedLocalUsersCount" - 1`;
|
||||||
} else {
|
} else {
|
||||||
set.attachedRemoteUserIds = () => `array_remove(tag.attachedRemoteUserIds, '${user.id}')`;
|
set.attachedRemoteUserIds = () => `array_remove("attachedRemoteUserIds", '${user.id}')`;
|
||||||
set.attachedRemoteUsersCount = () => `tag.attachedRemoteUsersCount - 1`;
|
set.attachedRemoteUsersCount = () => `"attachedRemoteUsersCount" - 1`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 自分が初めてこのタグを使ったなら
|
// 自分が初めてこのタグを使ったなら
|
||||||
if (!index.mentionedUserIds.some(id => id === user.id)) {
|
if (!index.mentionedUserIds.some(id => id === user.id)) {
|
||||||
set.mentionedUserIds = () => `array_append(tag.mentionedUserIds, '${user.id}')`;
|
set.mentionedUserIds = () => `array_append("mentionedUserIds", '${user.id}')`;
|
||||||
set.mentionedUsersCount = () => `tag.mentionedUsersCount + 1`;
|
set.mentionedUsersCount = () => `"mentionedUsersCount" + 1`;
|
||||||
}
|
}
|
||||||
// 自分が(ローカル内で)初めてこのタグを使ったなら
|
// 自分が(ローカル内で)初めてこのタグを使ったなら
|
||||||
if (Users.isLocalUser(user) && !index.mentionedLocalUserIds.some(id => id === user.id)) {
|
if (Users.isLocalUser(user) && !index.mentionedLocalUserIds.some(id => id === user.id)) {
|
||||||
set.mentionedLocalUserIds = () => `array_append(tag.mentionedLocalUserIds, '${user.id}')`;
|
set.mentionedLocalUserIds = () => `array_append("mentionedLocalUserIds", '${user.id}')`;
|
||||||
set.mentionedLocalUsersCount = () => `tag.mentionedLocalUsersCount + 1`;
|
set.mentionedLocalUsersCount = () => `"mentionedLocalUsersCount" + 1`;
|
||||||
}
|
}
|
||||||
// 自分が(リモートで)初めてこのタグを使ったなら
|
// 自分が(リモートで)初めてこのタグを使ったなら
|
||||||
if (Users.isRemoteUser(user) && !index.mentionedRemoteUserIds.some(id => id === user.id)) {
|
if (Users.isRemoteUser(user) && !index.mentionedRemoteUserIds.some(id => id === user.id)) {
|
||||||
set.mentionedRemoteUserIds = () => `array_append(tag.mentionedRemoteUserIds, '${user.id}')`;
|
set.mentionedRemoteUserIds = () => `array_append("mentionedRemoteUserIds", '${user.id}')`;
|
||||||
set.mentionedRemoteUsersCount = () => `tag.mentionedRemoteUsersCount + 1`;
|
set.mentionedRemoteUsersCount = () => `"mentionedRemoteUsersCount" + 1`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue