fix: removeFavoritedUser
This commit is contained in:
parent
72f3d9ec9b
commit
c23570c25d
|
@ -2,6 +2,20 @@ import RemoveFavorite from '~/common/packets/remove-favorite.packet';
|
|||
|
||||
import {allModels} from '~/server/models/registrar';
|
||||
|
||||
export const removeFavoritedUser = async (socket, user, other) => {
|
||||
const {Favorite} = allModels();
|
||||
const favorites = await user.getFavorites();
|
||||
const toRemove = favorites.find(({channel}) => channel === `/u/${other.redditUsername}`);
|
||||
if (toRemove) {
|
||||
await Favorite.destroy({
|
||||
where: {
|
||||
id: toRemove.id,
|
||||
},
|
||||
});
|
||||
socket.to(`/user/${user.id}`, new RemoveFavorite(`/u/${other.redditUsername}`));
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
Packet: RemoveFavorite,
|
||||
validator: () => true,
|
||||
|
|
|
@ -1,23 +1,10 @@
|
|||
import {Op} from 'sequelize';
|
||||
|
||||
import RemoveFavorite from '~/common/packets/remove-favorite.packet';
|
||||
import RemoveFriend from '~/common/packets/remove-friend.packet';
|
||||
|
||||
import {allModels} from '~/server/models/registrar';
|
||||
|
||||
export const removeFavoritedUser = async (socket, user, other) => {
|
||||
const {Favorite} = allModels();
|
||||
const favorites = await user.getFavorites();
|
||||
const toRemove = favorites.find(({channel}) => channel === `/u/${other.redditUsername}`);
|
||||
if (toRemove) {
|
||||
await Favorite.destroy({
|
||||
where: {
|
||||
id: toRemove.id,
|
||||
},
|
||||
});
|
||||
socket.to(`/user/${user.id}`, new RemoveFavorite(`/u/${other.redditUsername}`));
|
||||
}
|
||||
};
|
||||
import {removeFavoritedUser} from './remove-favorite';
|
||||
|
||||
export default {
|
||||
Packet: RemoveFriend,
|
||||
|
|
Loading…
Reference in New Issue
Block a user