Version 0.8.1 - Ajout des tooltips et du playlistshare
This commit is contained in:
		@@ -153,6 +153,22 @@ module.exports.getUsers = function () {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
module.exports.getUsersList = function () {
 | 
			
		||||
 | 
			
		||||
    var userList = new Array()
 | 
			
		||||
    const userDB = JSON.parse(fs.readFileSync(__glob.USERS))
 | 
			
		||||
 | 
			
		||||
    for(var user of userDB) {
 | 
			
		||||
 | 
			
		||||
        userList.push({"username": user.user.username, "global_name":user.user.global_name, "avatar": user.user.avatar, "id": user.user.id})
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return userList
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
module.exports.getUser = function (token) {
 | 
			
		||||
    return users.get(token)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,8 @@ const { LogType } = require("./sub-log");
 | 
			
		||||
var { List } = require("./sub-list")
 | 
			
		||||
const discord = require("./discord-bot")
 | 
			
		||||
const subplayer = require("./sub-player")
 | 
			
		||||
const fs = require("fs")
 | 
			
		||||
const fs = require("fs");
 | 
			
		||||
const { type } = require("os");
 | 
			
		||||
var playlists = {}
 | 
			
		||||
const plog = new LogType("Playlist-Manager")
 | 
			
		||||
 | 
			
		||||
@@ -41,6 +42,23 @@ module.exports.addPlaylist = function (id, name) {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports.copyPlaylist = function (id, from, dest) {
 | 
			
		||||
    this.getUser(dest)
 | 
			
		||||
    check()
 | 
			
		||||
    let playlistDest = playlists[dest][from]
 | 
			
		||||
    if(!playlistDest) {
 | 
			
		||||
        plog.log("Ajout de la playlist à l'utilisateur \"" + id  + "\" dans la base de donnée Playlist !")
 | 
			
		||||
        playlists[dest][from] = playlists[id][from]
 | 
			
		||||
 | 
			
		||||
        fs.writeFileSync(__glob.PLAYLIST, JSON.stringify(playlists, null, 2))
 | 
			
		||||
    } else {
 | 
			
		||||
 | 
			
		||||
        plog.log("L'utilisateur \"" + dest  + "\" à déjà une playlist avec le nom "+ from + " dans la base de donnée Playlist !")
 | 
			
		||||
    
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports.removePlaylist = function (id, name) {
 | 
			
		||||
    check()
 | 
			
		||||
    if(playlists[id][name]) {
 | 
			
		||||
 
 | 
			
		||||
@@ -274,6 +274,26 @@ function IOConnection(io) {
 | 
			
		||||
      
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        GetRequest(io, socket, "USER_LIST", () => {  
 | 
			
		||||
            var cookies = socket.handshake.headers.cookie
 | 
			
		||||
            cookies = cook.parse(cookies)
 | 
			
		||||
            var token = cookies.token
 | 
			
		||||
 | 
			
		||||
            const user = auth.getUser(token)
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
            if(user.admin == true) {
 | 
			
		||||
                
 | 
			
		||||
                const users_data = auth.getUsersList()
 | 
			
		||||
 | 
			
		||||
                socket.emit("ANSWER/GET/USER_LIST", users_data)
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
          
 | 
			
		||||
      
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -667,7 +687,7 @@ function IOConnection(io) {
 | 
			
		||||
                    subplayer.report(null, null, data)
 | 
			
		||||
 | 
			
		||||
                    const user = auth.getUser(token)
 | 
			
		||||
                    io.emit("NOTIFICATION", {"image_src": "https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.vecteezy.com%2Fvector-art%2F19521981-green-check-mark-vector-icon-with-circle-checkmark-illustration&psig=AOvVaw1-8kuUXImHNwIoVvySyiSK&ust=1694119774978000&source=images&cd=vfe&opi=89978449&ved=0CBAQjRxqFwoTCLjb2YzuloEDFQAAAAAdAAAAABAE", "text": "Votre rapport de bug a été correctement envoyé !" })
 | 
			
		||||
                    socket.emit("NOTIFICATION", {"image_src": "https://static.vecteezy.com/system/resources/previews/019/521/981/non_2x/green-check-mark-icon-with-circle-checkmark-illustration-free-vector.jpg", "text": "Votre rapport de bug a été correctement envoyé !" })
 | 
			
		||||
                
 | 
			
		||||
                } else {
 | 
			
		||||
 | 
			
		||||
@@ -998,6 +1018,44 @@ function IOConnection(io) {
 | 
			
		||||
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
        socket.on("SEND/SEND_PLAYLIST", async (key, dest) => {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            var cookies = socket.handshake.headers.cookie
 | 
			
		||||
 | 
			
		||||
            if(cookies) {
 | 
			
		||||
 | 
			
		||||
                cookies = cook.parse(cookies)
 | 
			
		||||
                var token = cookies.token
 | 
			
		||||
                 
 | 
			
		||||
                if(auth.checkUser(token)) {
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
                    var user = auth.getUser(token)
 | 
			
		||||
                    var userId = user.user.id
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    subplaylist.copyPlaylist(userId, key, dest)
 | 
			
		||||
                    
 | 
			
		||||
                    io.sockets.emit("DO_UPDATE_PLAYLIST")
 | 
			
		||||
                    socket.emit("NOTIFICATION", {"image_src": "https://static.vecteezy.com/system/resources/previews/019/521/981/non_2x/green-check-mark-icon-with-circle-checkmark-illustration-free-vector.jpg", "text": "La playlist a été correctement envoyé ! (Si le destinataire a déjà une playlist avec le même nom, l'opération est annulé" })
 | 
			
		||||
                    io.emit("ANSWER/SEND/SEND_PLAYLIST/OK")
 | 
			
		||||
                
 | 
			
		||||
                } else {
 | 
			
		||||
 | 
			
		||||
                    io.emit("ANSWER/SEND/SEND_PLAYLIST", {"error":"USER_DONT_EXIST"})
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                io.emit("ANSWER/SEND/SEND_PLAYLIST", {"error":"TOKEN_NOT_FINDED"})
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
         
 | 
			
		||||
           
 | 
			
		||||
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        socket.on("SEND/ADD_SONG_TO_PLAYLIST", async (data, song) => {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user