fix(realtime): Restrict updates to only last modified or current user (#33034)

This commit is contained in:
gavin 2022-11-18 17:17:54 +05:30 committed by GitHub
parent df096688f7
commit dd2493a541
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 9 additions and 7 deletions

View File

@ -20,7 +20,6 @@ frappe.ui.form.on('Opening Invoice Creation Tool', {
frm.dashboard.reset();
frm.doc.import_in_progress = true;
}
if (data.user != frappe.session.user) return;
if (data.count == data.total) {
setTimeout(() => {
frm.doc.import_in_progress = false;

View File

@ -260,10 +260,10 @@ def publish(index, total, doctype):
dict(
title=_("Opening Invoice Creation In Progress"),
message=_("Creating {} out of {} {}").format(index + 1, total, doctype),
user=frappe.session.user,
count=index + 1,
total=total,
),
user=frappe.session.user,
)

View File

@ -25,7 +25,7 @@ frappe.ui.form.on('POS Closing Entry', {
frappe.realtime.on('closing_process_complete', async function(data) {
await frm.reload_doc();
if (frm.doc.status == 'Failed' && frm.doc.error_message && data.user == frappe.session.user) {
if (frm.doc.status == 'Failed' && frm.doc.error_message) {
frappe.msgprint({
title: __('POS Closing Failed'),
message: frm.doc.error_message,

View File

@ -430,7 +430,7 @@ def create_merge_logs(invoice_by_customer, closing_entry=None):
finally:
frappe.db.commit()
frappe.publish_realtime("closing_process_complete", {"user": frappe.session.user})
frappe.publish_realtime("closing_process_complete", user=frappe.session.user)
def cancel_merge_logs(merge_logs, closing_entry=None):
@ -457,7 +457,7 @@ def cancel_merge_logs(merge_logs, closing_entry=None):
finally:
frappe.db.commit()
frappe.publish_realtime("closing_process_complete", {"user": frappe.session.user})
frappe.publish_realtime("closing_process_complete", user=frappe.session.user)
def enqueue_job(job, **kwargs):

View File

@ -1345,7 +1345,7 @@ class QuickBooksMigrator(Document):
)[0]["name"]
def _publish(self, *args, **kwargs):
frappe.publish_realtime("quickbooks_progress_update", *args, **kwargs)
frappe.publish_realtime("quickbooks_progress_update", *args, **kwargs, user=self.modified_by)
def _get_unique_account_name(self, quickbooks_name, number=0):
if number:

View File

@ -304,6 +304,7 @@ class TallyMigration(Document):
frappe.publish_realtime(
"tally_migration_progress_update",
{"title": title, "message": message, "count": count, "total": total},
user=self.modified_by,
)
def _import_master_data(self):

View File

@ -146,7 +146,9 @@ class ImportSupplierInvoice(Document):
def publish(self, title, message, count, total):
frappe.publish_realtime(
"import_invoice_update", {"title": title, "message": message, "count": count, "total": total}
"import_invoice_update",
{"title": title, "message": message, "count": count, "total": total},
user=self.modified_by,
)