mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
19 lines
543 B
JavaScript
Executable File
19 lines
543 B
JavaScript
Executable File
import { UserFollow } from "@db_models"
|
|
|
|
export default async (user_id) => {
|
|
// get followers of the user
|
|
const followers = await UserFollow.find({
|
|
to: user_id,
|
|
})
|
|
|
|
// send event to ws clients (if are connected)
|
|
followers.forEach((follow) => {
|
|
const connectedClient = global.websocket_instance.clients.find((client) => {
|
|
return client.user_id === follow.user_id
|
|
})
|
|
|
|
if (connectedClient) {
|
|
connectedClient.socket.emit("friend.disconnected", user_id)
|
|
}
|
|
})
|
|
} |