Add function to list all rooms with participants, export to rooms.txt
- New menu point C: List all rooms WITH participants - Uses GROUP_CONCAT to combine participants into one column - Tests multiple JOIN variants (user_id, attendee_id, actor_id) - Saves to rooms.txt Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@ -244,6 +244,7 @@ show_menu() {
|
|||||||
echo -e "${YELLOW}8.${NC} Chat-Info anzeigen"
|
echo -e "${YELLOW}8.${NC} Chat-Info anzeigen"
|
||||||
echo -e "${YELLOW}9.${NC} Alle Räume auflisten (-> rooms.txt)"
|
echo -e "${YELLOW}9.${NC} Alle Räume auflisten (-> rooms.txt)"
|
||||||
echo -e "${YELLOW}B.${NC} rooms.txt anzeigen"
|
echo -e "${YELLOW}B.${NC} rooms.txt anzeigen"
|
||||||
|
echo -e "${YELLOW}C.${NC} Alle Räume MIT Teilnehmern (-> rooms.txt)"
|
||||||
echo -e "${YELLOW}A.${NC} Teilnehmer eines Chats auflisten"
|
echo -e "${YELLOW}A.${NC} Teilnehmer eines Chats auflisten"
|
||||||
echo -e "${YELLOW}D.${NC} Debug-Informationen"
|
echo -e "${YELLOW}D.${NC} Debug-Informationen"
|
||||||
echo -e "${YELLOW}0.${NC} Beenden"
|
echo -e "${YELLOW}0.${NC} Beenden"
|
||||||
@ -431,7 +432,7 @@ show_rooms_file() {
|
|||||||
|
|
||||||
if [ ! -f "$file" ]; then
|
if [ ! -f "$file" ]; then
|
||||||
echo -e "${RED}Fehler: Datei $file existiert nicht!${NC}"
|
echo -e "${RED}Fehler: Datei $file existiert nicht!${NC}"
|
||||||
echo -e "Bitte zuerst Menüpunkt 9 (Alle Räume auflisten) ausführen.${NC}"
|
echo -e "Bitte zuerst Menüpunkt 9 oder C ausführen.${NC}"
|
||||||
read -p "Enter..." && return
|
read -p "Enter..." && return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -444,13 +445,115 @@ show_rooms_file() {
|
|||||||
read -p "Enter..."
|
read -p "Enter..."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_rooms_with_participants() {
|
||||||
|
show_menu
|
||||||
|
echo -e "\n${YELLOW}Alle Räume MIT Teilnehmern auflisten${NC}\n"
|
||||||
|
|
||||||
|
local output_file="./rooms.txt"
|
||||||
|
|
||||||
|
echo "Lese Räume mit Teilnehmern aus Datenbank..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Hauptabfrage mit GROUP_CONCAT für Teilnehmer
|
||||||
|
mysql -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" -e "
|
||||||
|
SELECT
|
||||||
|
r.token AS Token,
|
||||||
|
r.name AS Name,
|
||||||
|
CASE r.type
|
||||||
|
WHEN 0 THEN 'Einzel'
|
||||||
|
WHEN 1 THEN 'Gruppe'
|
||||||
|
WHEN 2 THEN 'öffentlich'
|
||||||
|
WHEN 3 THEN 'privat'
|
||||||
|
WHEN 7 THEN 'föderiert'
|
||||||
|
ELSE CONCAT('Unbekannt (', r.type, ')')
|
||||||
|
END AS Typ,
|
||||||
|
GROUP_CONCAT(DISTINCT u.uid ORDER BY u.uid SEPARATOR ', ') AS Teilnehmer,
|
||||||
|
r.id AS ID
|
||||||
|
FROM \`${DB_PREFIX}talk_rooms\` r
|
||||||
|
LEFT JOIN \`${DB_PREFIX}talk_attendees\` a ON a.room_id = r.id
|
||||||
|
LEFT JOIN \`${DB_PREFIX}users\` u ON a.user_id = u.uid
|
||||||
|
GROUP BY r.token, r.name, r.type, r.id
|
||||||
|
ORDER BY r.name ASC
|
||||||
|
" > "$output_file" 2>"$output_file.err"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ] || [ ! -s "$output_file" ]; then
|
||||||
|
# Alternative: mit attendee_id
|
||||||
|
mysql -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" -e "
|
||||||
|
SELECT
|
||||||
|
r.token AS Token,
|
||||||
|
r.name AS Name,
|
||||||
|
CASE r.type
|
||||||
|
WHEN 0 THEN 'Einzel'
|
||||||
|
WHEN 1 THEN 'Gruppe'
|
||||||
|
WHEN 2 THEN 'öffentlich'
|
||||||
|
WHEN 3 THEN 'privat'
|
||||||
|
WHEN 7 THEN 'föderiert'
|
||||||
|
ELSE CONCAT('Unbekannt (', r.type, ')')
|
||||||
|
END AS Typ,
|
||||||
|
GROUP_CONCAT(DISTINCT u.uid ORDER BY u.uid SEPARATOR ', ') AS Teilnehmer,
|
||||||
|
r.id AS ID
|
||||||
|
FROM \`${DB_PREFIX}talk_rooms\` r
|
||||||
|
LEFT JOIN \`${DB_PREFIX}talk_attendees\` a ON a.room_id = r.id
|
||||||
|
LEFT JOIN \`${DB_PREFIX}users\` u ON a.attendee_id = u.uid
|
||||||
|
GROUP BY r.token, r.name, r.type, r.id
|
||||||
|
ORDER BY r.name ASC
|
||||||
|
" > "$output_file" 2>"$output_file.err"
|
||||||
|
|
||||||
|
if [ $? -ne 0 ] || [ ! -s "$output_file" ]; then
|
||||||
|
# Alternative: mit actor_id
|
||||||
|
mysql -h "$DB_HOST" -u "$DB_USER" -p"$DB_PASS" "$DB_NAME" -e "
|
||||||
|
SELECT
|
||||||
|
r.token AS Token,
|
||||||
|
r.name AS Name,
|
||||||
|
CASE r.type
|
||||||
|
WHEN 0 THEN 'Einzel'
|
||||||
|
WHEN 1 THEN 'Gruppe'
|
||||||
|
WHEN 2 THEN 'öffentlich'
|
||||||
|
WHEN 3 THEN 'privat'
|
||||||
|
WHEN 7 THEN 'föderiert'
|
||||||
|
ELSE CONCAT('Unbekannt (', r.type, ')')
|
||||||
|
END AS Typ,
|
||||||
|
GROUP_CONCAT(DISTINCT u.uid ORDER BY u.uid SEPARATOR ', ') AS Teilnehmer,
|
||||||
|
r.id AS ID
|
||||||
|
FROM \`${DB_PREFIX}talk_rooms\` r
|
||||||
|
LEFT JOIN \`${DB_PREFIX}talk_attendees\` a ON a.room_id = r.id AND a.actor_type = 'users'
|
||||||
|
LEFT JOIN \`${DB_PREFIX}users\` u ON a.actor_id = u.uid
|
||||||
|
GROUP BY r.token, r.name, r.type, r.id
|
||||||
|
ORDER BY r.name ASC
|
||||||
|
" > "$output_file" 2>"$output_file.err"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -s "$output_file" ]; then
|
||||||
|
echo -e "${RED}Fehler: Konnte Räume mit Teilnehmern nicht abfragen!${NC}"
|
||||||
|
if [ -s "$output_file.err" ]; then
|
||||||
|
echo -e "${RED}MySQL-Fehler:${NC}"
|
||||||
|
cat "$output_file.err"
|
||||||
|
rm -f "$output_file.err"
|
||||||
|
fi
|
||||||
|
read -p "Enter..." && return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Ausgabe anzeigen
|
||||||
|
echo -e "${GREEN}=================================================================${NC}"
|
||||||
|
echo -e "${GREEN} Nextcloud Talk Räume MIT Teilnehmern (gespeichert in $output_file)${NC}"
|
||||||
|
echo -e "${GREEN}=================================================================${NC}"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
cat "$output_file"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo -e "${GREEN}Die Liste wurde in $output_file gespeichert.${NC}"
|
||||||
|
read -p "Enter..."
|
||||||
|
}
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# HAUPT SCHLEIFE
|
# HAUPT SCHLEIFE
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
show_menu
|
show_menu
|
||||||
read -p "Wählen Sie [0-9,A,B,D]: " choice
|
read -p "Wählen Sie [0-9,A-C,D]: " choice
|
||||||
case $choice in
|
case $choice in
|
||||||
1) create_chat ;;
|
1) create_chat ;;
|
||||||
2) add_user_to_chat ;;
|
2) add_user_to_chat ;;
|
||||||
@ -462,6 +565,7 @@ while true; do
|
|||||||
8) show_chat_info ;;
|
8) show_chat_info ;;
|
||||||
9) list_all_rooms ;;
|
9) list_all_rooms ;;
|
||||||
B|b) show_rooms_file ;;
|
B|b) show_rooms_file ;;
|
||||||
|
C|c) list_rooms_with_participants ;;
|
||||||
A|a) list_room_participants ;;
|
A|a) list_room_participants ;;
|
||||||
D|d) show_debug ;;
|
D|d) show_debug ;;
|
||||||
0) echo -e "\n${GREEN}Auf Wiedersehen!${NC}" && exit 0 ;;
|
0) echo -e "\n${GREEN}Auf Wiedersehen!${NC}" && exit 0 ;;
|
||||||
|
|||||||
Reference in New Issue
Block a user