package com.example.punyaria;

import java.util.HashMap;
import java.util.Map;

public class ChatMessage {
    private String username;
    private String message;
    private String timestamp;
    private String konselingID; // Tambahkan variabel konselingID

    private String imageUrl; // Tambahkan variabel imageUrl

    // Empty constructor required for Firebase
    public ChatMessage() {
        // Default constructor required for calls to DataSnapshot.getValue(ChatMessage.class)
    }

    // Constructor with arguments
    public ChatMessage(String username, String message, String timestamp, String konselingID, String imageUrl) {
        this.username = username;
        this.message = message;
        this.timestamp = timestamp;
        this.konselingID = konselingID; // Inisialisasi konselingID
        this.imageUrl = imageUrl; // Inisialisasi imageUrl
    }

    // Getters and setters
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }

    // Getter and setter for konselingID
    public String getKonselingID() {
        return konselingID;
    }

    public void setKonselingID(String konselingID) {
        this.konselingID = konselingID;
    }

    // Getter and setter for imageUrl
    public String getImageUrl() {
        return imageUrl;
    }

    public void setImageUrl(String imageUrl) {
        this.imageUrl = imageUrl;
    }

    // Method to convert ChatMessage object into a Map
    public Map<String, Object> toMap() {
        HashMap<String, Object> result = new HashMap<>();
        result.put("username", username);
        result.put("message", message);
        result.put("timestamp", timestamp);
        result.put("konselingID", konselingID); // Include konselingID in the map
        result.put("imageUrl", imageUrl); // Include imageUrl in the map
        return result;
    }

    public boolean isImage() {
        // Pemeriksaan apakah pesan adalah pesan gambar
        // Misalnya, Anda dapat memeriksa apakah imageUrl tidak kosong
        return imageUrl != null && !imageUrl.isEmpty();
    }
}
