mirror of
				https://github.com/pierre42100/ComunicWeb
				synced 2025-11-04 12:14:12 +00:00 
			
		
		
		
	Can toggle admin status of a user
This commit is contained in:
		@@ -536,6 +536,30 @@ const ConvChatWindow = {
 | 
			
		||||
			});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			// Set / unset admin
 | 
			
		||||
			if(canRemoveUsers && member.user_id != userID()) {
 | 
			
		||||
				let removeLink = createElem2({
 | 
			
		||||
					type: "a",
 | 
			
		||||
					appendTo: status,
 | 
			
		||||
					innerHTML: (member.is_admin ? tr("Unset admin") : tr("Set admin"))
 | 
			
		||||
				})
 | 
			
		||||
 | 
			
		||||
				removeLink.addEventListener("click", async e => {
 | 
			
		||||
					e.preventDefault();
 | 
			
		||||
 | 
			
		||||
					try {
 | 
			
		||||
						await ConversationsInterface.toggleAdminStatus(conv.id, member.user_id, !member.is_admin);
 | 
			
		||||
 | 
			
		||||
						ConvChatWindow.reload(info);
 | 
			
		||||
					} catch(e) {
 | 
			
		||||
						console.error(e);
 | 
			
		||||
						notify(tr("Failed to toggle admin status of %1%!", {"1": user.fullName}), "danger");
 | 
			
		||||
					}
 | 
			
		||||
				})
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			add_space(status)
 | 
			
		||||
 | 
			
		||||
			// Remove user
 | 
			
		||||
			if(canRemoveUsers && member.user_id != userID()) {
 | 
			
		||||
				let removeLink = createElem2({
 | 
			
		||||
 
 | 
			
		||||
@@ -463,6 +463,21 @@ const ConversationsInterface = {
 | 
			
		||||
		}, true);
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Toggle admin status of a user
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param {number} convID Conversation ID
 | 
			
		||||
	 * @param {number} userID User ID
 | 
			
		||||
	 * @param {boolean} setAdmin
 | 
			
		||||
	 */
 | 
			
		||||
	toggleAdminStatus: async function(convID, userID, setAdmin) {
 | 
			
		||||
		await api("conversations/setAdmin", {
 | 
			
		||||
			convID: convID,
 | 
			
		||||
			userID: userID,
 | 
			
		||||
			setAdmin: setAdmin
 | 
			
		||||
		}, true);
 | 
			
		||||
	},
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Remove a user from a conversation
 | 
			
		||||
	 * 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user