13 lines
418 B
JavaScript
13 lines
418 B
JavaScript
import {ModelMap} from '@latus/db';
|
|
|
|
export default async (latus, socket, user, other) => {
|
|
const {Favorite} = ModelMap(latus);
|
|
const favorite = await Favorite.findOne(
|
|
{where: {channel: `/u/${other.redditUsername}`, user_id: user.id}},
|
|
);
|
|
if (favorite) {
|
|
await Favorite.destroy({where: {id: favorite.id}});
|
|
socket.to(`/u/${user.id}`).send(['RemoveFavorite', `/u/${other.redditUsername}`]);
|
|
}
|
|
};
|