Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
813cdcd
change link to chat button ,chang topic name
mohamadclefincode1998 May 19, 2026
66ce769
update README file
mohamadclefincode1998 May 19, 2026
e512d05
fix patch issue
mohamadclefincode1998 May 19, 2026
545f5ce
make link to just for message sender
mohamadclefincode1998 May 19, 2026
8c47432
fix mention error
mohamadclefincode1998 May 21, 2026
c7b22a1
fix search Contributor issu
mohamadclefincode1998 May 21, 2026
65242df
bump version to 1.3.904
mohamadclefincode1998 May 22, 2026
061eec9
bump version to 1.3.904
clefincode May 22, 2026
ce59b41
remove topic from message and reply topic
mohamadclefincode1998 Jun 9, 2026
6069331
add limited user doctype
mohamadclefincode1998 Jun 9, 2026
212a8e2
remove and reply topic - limited user doctype
clefincode Jun 10, 2026
d84b6d4
add close topic for realtime
mohamadclefincode1998 Jun 11, 2026
a67b026
per-user active topic selection with cross-session realtime sync
mohamadclefincode1998 Jun 11, 2026
d9e8208
per-user active topic selection with user-scoped close_topic sync
mohamadclefincode1998 Jun 11, 2026
cc62332
dapt "Read more" button and fade mask for dark mode
mohamadclefincode1998 Jun 11, 2026
ce7b1a4
per-user active topic selection with cross-session Realtime sync
clefincode Jun 13, 2026
454d0cc
fix : send to whatsapp error
mohamadclefincode1998 Jun 16, 2026
40ee40f
fix open chat for only email user
mohamadclefincode1998 Jun 16, 2026
aecdf4b
add limited user icon
mohamadclefincode1998 Jun 16, 2026
42ca97a
fix website user problem
mohamadclefincode1998 Jun 17, 2026
26cd920
bump version to 1.3.907
mohamadclefincode1998 Jun 17, 2026
2f5cca0
fix : send to whatsapp error
clefincode Jun 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
774 changes: 519 additions & 255 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clefincode_chat/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.3.903'
__version__ = '1.3.907'
7 changes: 5 additions & 2 deletions clefincode_chat/api/api_1_3_3/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from frappe import _
from frappe.desk.search import validate_and_sanitize_search_inputs


from packaging import version


TOPIC_COLOR_PALETTE = [
Expand Down Expand Up @@ -3603,7 +3603,7 @@ def search_in_message_content(user , query):
return my_messages
# ==========================================================================================
@frappe.whitelist()
def search_in_message_contents(channel, query, sub_channel=None):
def search_in_message_contents(channel, query, sub_channel=None, chat_topic=None):

if not channel or not query:
return {"results": []}
Expand All @@ -3616,6 +3616,9 @@ def search_in_message_contents(channel, query, sub_channel=None):
if sub_channel:
filters["sub_channel"] = sub_channel

if chat_topic:
filters["chat_topic"] = chat_topic

results = frappe.get_all(
"ClefinCode Chat Message",
filters=filters,
Expand Down
830 changes: 776 additions & 54 deletions clefincode_chat/api/api_1_3_4/api.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"platform",
"active",
"channel",
"active_chat_topic",
"last_message_read",
"unread_messages"
],
Expand All @@ -35,10 +36,16 @@
"label": "Channel"
},
{
"fieldname": "last_message_read",
"fieldtype": "Icon",
"in_list_view": 1,
"label": "Last Message Read"
"fieldname": "active_chat_topic",
"fieldtype": "Link",
"label": "Active Chat Topic",
"options": "ClefinCode Chat Topic"
},
{
"fieldname": "last_message_read",
"fieldtype": "Icon",
"in_list_view": 1,
"label": "Last Message Read"
},
{
"default": "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
"is_removed",
"remove_date",
"is_admin",
"channel_last_message_number",
"platform_profile",
"channel_last_message_number",
"active_chat_topic",
"platform_profile",
"platform_gateway",
"pending_messages"
],
Expand Down Expand Up @@ -87,12 +88,18 @@
"label": "Profile Id",
"options": "ClefinCode Chat Profile"
},
{
"fieldname": "platform_profile",
"fieldtype": "Link",
"label": "Platform",
"options": "DocType"
},
{
"fieldname": "active_chat_topic",
"fieldtype": "Link",
"label": "Active Chat Topic",
"options": "ClefinCode Chat Topic"
},
{
"fieldname": "platform_profile",
"fieldtype": "Link",
"label": "Platform",
"options": "DocType"
},
{
"fieldname": "platform_gateway",
"fieldtype": "Dynamic Link",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ class ClefinCodeChatProfile(Document):
def before_save(self):
if self.is_guest == 1 or self.is_support == 1:
self.token = frappe.generate_hash()
self.update_contact_from_details()
if getattr(frappe.flags, "skip_migrate_fcm_devices_contact_sync", False):
return

self.update_contact_from_details()

def before_insert(self):
if self.is_guest == 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"enable_mobile_notifications",
"with_message_content",
"enable_system_notification_on_mobile_app",
"limited_roles_section",
"limited_roles",
"column_break_jxln",
"max_edit_time",
"max_delete_time",
Expand Down Expand Up @@ -149,6 +151,17 @@
"fieldtype": "Check",
"label": "Enable System Notification on Mobile App"
},
{
"fieldname": "limited_roles_section",
"fieldtype": "Section Break",
"label": "Limited User Roles"
},
{
"fieldname": "limited_roles",
"fieldtype": "Table MultiSelect",
"label": "Limited Roles",
"options": "ClefinCode Limited Role"
},
{
"default": "7",
"fieldname": "max_delete_time",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"actions": [],
"allow_rename": 1,
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"role"
],
"fields": [
{
"fieldname": "role",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Role",
"options": "Role",
"reqd": 1
}
],
"istable": 1,
"links": [],
"module": "ClefinCode Chat",
"name": "ClefinCode Limited Role",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC",
"states": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from frappe.model.document import Document


class ClefinCodeLimitedRole(Document):
pass
84 changes: 45 additions & 39 deletions clefincode_chat/patches/v1_3_4/migrate_fcm_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,53 @@


def execute():
frappe.reload_doc(
"clefincode_chat",
"doctype",
"clefincode_chat_profile_fcm_device"
)

frappe.reload_doc(
"clefincode_chat",
"doctype",
"clefincode_chat_profile"
)

profiles = frappe.get_all(
"ClefinCode Chat Profile",
fields=["name", "registration_token", "platform"]
)

for profile in profiles:
if not profile.registration_token:
continue

doc = frappe.get_doc("ClefinCode Chat Profile", profile.name)

already_exists = any(
row.registration_token == profile.registration_token
for row in (doc.get("fcm_devices") or [])
frappe.flags.skip_migrate_fcm_devices_contact_sync = True

try:
frappe.reload_doc(
"clefincode_chat",
"doctype",
"clefincode_chat_profile_fcm_device"
)

frappe.reload_doc(
"clefincode_chat",
"doctype",
"clefincode_chat_profile"
)

profiles = frappe.get_all(
"ClefinCode Chat Profile",
fields=["name", "registration_token", "platform"]
)

if already_exists:
continue
for profile in profiles:
if not profile.registration_token:
continue

doc = frappe.get_doc("ClefinCode Chat Profile", profile.name)

already_exists = any(
row.registration_token == profile.registration_token
for row in (doc.get("fcm_devices") or [])
)

if already_exists:
continue

doc.append("fcm_devices", {
"device_id": "legacy",
"registration_token": profile.registration_token,
"platform": profile.platform or "",
"app_version": "",
"device_name": "",
"is_active": 1,
"last_seen": now_datetime()
})

doc.append("fcm_devices", {
"device_id": "legacy",
"registration_token": profile.registration_token,
"platform": profile.platform or "",
"app_version": "",
"device_name": "",
"is_active": 1,
"last_seen": now_datetime()
})
doc.save(ignore_permissions=True)

doc.save(ignore_permissions=True)
frappe.db.commit()

frappe.db.commit()
finally:
frappe.flags.skip_migrate_fcm_devices_contact_sync = False
2 changes: 1 addition & 1 deletion clefincode_chat/public/js/clefincode_chat.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ window.CCChatContactList = ChatContactList;
async function get_settings(token) {
const res = await frappe.call({
type: "GET",
method: "clefincode_chat.api.api_1_2_1.api.get_settings",
method: "clefincode_chat.api.api_1_3_4.api.get_settings",
args: {
token: token,
},
Expand Down
67 changes: 66 additions & 1 deletion clefincode_chat/public/js/components/chat_portal_space.js
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,15 @@ performSearchLocal(query) {
this.$chatbot_container.find("[data-message-name]").each(function () {
const $msg = $(this);
const name = $msg.data("message-name");

const $longBody = $msg.find(".message-text-body.long-message-body");
if ($longBody.length) {
$longBody
.removeClass("long-message-body")
.addClass("long-message-expanded");
$msg.find(".chat-read-more-btn").remove();
}

const $bubble = $msg.find(".message-bubble").first();

const originalHtml = $bubble.html();
Expand Down Expand Up @@ -715,6 +724,14 @@ navigateToSearchResult() {
const $msg = this.$chatbot_container.find(`#msg-${name}`);
if (!$msg.length) return;

const $longBody = $msg.find(".message-text-body.long-message-body");
if ($longBody.length) {
$longBody
.removeClass("long-message-body")
.addClass("long-message-expanded");
$msg.find(".chat-read-more-btn").remove();
}

this.$chatbot_container.find(".search-highlight-active")
.removeClass("search-highlight-active");

Expand Down Expand Up @@ -1055,6 +1072,29 @@ me.$chatbot_container.on("click.portal", ".reply-link", function () {
const $msg = me.$chatbot_container.find(`#msg-${target}`);
if ($msg.length) $msg[0].scrollIntoView({ behavior: "smooth", block: "center" });
});
// Read more for long messages
me.$chatbot_container.on("click.portal", ".chat-read-more-btn", function (e) {
e.preventDefault();
e.stopPropagation();
const $btn = $(this);
const $textBody = $btn.siblings(".message-text-body").first();
if (!$textBody.length) return;

let step = parseInt($textBody.attr("data-read-more-step") || "0", 10);
const nextStep = step + 1;

if (nextStep >= 3) {
$textBody
.removeClass("long-message-body")
.addClass("long-message-expanded");
$btn.remove();
} else {
const heights = [200, 400, 600];
$textBody.css("max-height", heights[nextStep] + "px");
$textBody.attr("data-read-more-step", nextStep);
}
});

// Toggle search bar
me.$chatbot_space.on("click.portal", ".toggle-search", function () {
const $search = me.$chatbot_space.find(".chat-search");
Expand Down Expand Up @@ -1340,7 +1380,32 @@ me.$chatbot_space.on("click.portal", ".search-clear", () => {
`);
}

$message_element.append($sanitized_content);
let $contentToAppend = $sanitized_content;

if (!is_deleted && type !== "info-message") {
const plainText = content.replace(/<[^>]*>/g, "");
const isTextOnly =
!/<\s*(img|video|audio|source|canvas)\b/i.test(content) &&
!content.includes("data-audio");

if (isTextOnly && plainText.length > 300) {
const $wrapper = $(
'<div class="message-text-body long-message-body" data-read-more-step="0">'
);
$wrapper.append($sanitized_content.contents());
$contentToAppend = $wrapper;
}
}

$message_element.append($contentToAppend);
if ($contentToAppend.is(".long-message-body")) {
const $readMoreBtn = $(
'<button type="button" class="chat-read-more-btn">' +
__("Read more") +
"</button>"
);
$message_element.append($readMoreBtn);
}
const isDark = document.documentElement.dataset.themeMode === "dark";
const deleteIcon = isDark
? "/assets/clefincode_chat/icons/delete.png"
Expand Down
10 changes: 10 additions & 0 deletions clefincode_chat/public/js/components/erpnext_chat_contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,16 @@ const isSystemManager = roles.includes("System Manager");
if (contact_element.hasClass("options-icon")) {
return;
}
const contacts = this.profile.contact_details || [];
const onlyEmail = contacts.length > 0 &&
contacts.every(c => c.contact_type === "Email");

if (onlyEmail) {
this.handle_mail_icon_click({
data: () => contacts[0].contact_info
});
return;
}

// Handle based on contact type
if (contact_element.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion clefincode_chat/public/js/components/erpnext_chat_info.js
Original file line number Diff line number Diff line change
Expand Up @@ -1862,7 +1862,7 @@ save_all_contacts(dialog) {

this.chat_space.$chat_space
.find(`.chat-topic-separator[data-topic-name="${safe}"] .topic-separator-title`)
.text(`${__("Topic")}: ${subject}`);
.text(subject);

this.chat_space.$chat_space
.find(`.message-bubble[data-topic-name="${safe}"]`)
Expand Down
Loading