Skip to content

Commit ec4f03c

Browse files
authored
Merge pull request #2018 from The-Commit-Company/develop
Merging develop into main
2 parents f8b345f + 6b79501 commit ec4f03c

2 files changed

Lines changed: 18 additions & 13 deletions

File tree

frontend/src/hooks/useActiveSocketConnection.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ export const useActiveSocketConnection = () => {
1919
console.log("Socket connection failed", socketConnectionCount.current)
2020
// If the socket connection fails more than 2 times, then show an error message
2121
if (socketConnectionCount.current === 2) {
22-
toast.error("Realtime events are not working. Please try refreshing the page.", {
23-
duration: 5000
24-
})
22+
const isToastActive = toast.getToasts().some(toast => toast.id === "socket-connection-error")
23+
if (!isToastActive) {
24+
toast.error("Realtime events are not working. Please try refreshing the page.", {
25+
duration: 5000,
26+
closeButton: true,
27+
id: "socket-connection-error"
28+
})
29+
}
2530
} else {
2631
// Else try to connect to socket
2732
socket?.connect()

raven/permissions.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ def check_app_permission():
2222
def raven_user_has_permission(doc, user=None, ptype=None):
2323

2424
if doc.type == "Bot":
25-
# Anyone with Raven User role can change the bot details
26-
if user != "Guest":
27-
if ptype == "read":
28-
return True
29-
else:
30-
roles = frappe.get_roles()
31-
if "Raven Admin" in roles:
32-
return True
25+
# Anyone with Raven User role can view the bot details
26+
if ptype == "read":
27+
return True
28+
29+
# Raven Admins can change the bot details
30+
roles = frappe.get_roles(user=user)
31+
if "Raven Admin" in roles:
32+
return True
3333
else:
3434
# Only the user can change their own details
3535
if doc.user == user:
@@ -158,7 +158,7 @@ def channel_has_permission(doc, user=None, ptype=None):
158158
if channel_member.get("is_admin"):
159159
return True
160160
# If the user is a Raven Admin, they can update or delete the channel
161-
roles = frappe.get_roles()
161+
roles = frappe.get_roles(user=user)
162162
if "Raven Admin" in roles:
163163
return True
164164

@@ -257,7 +257,7 @@ def channel_member_has_permission(doc, user=None, ptype=None):
257257
if channel_member.get("is_admin"):
258258
return True
259259
# If the user is a Raven Admin, they can update the channel member
260-
roles = frappe.get_roles()
260+
roles = frappe.get_roles(user=user)
261261
if "Raven Admin" in roles:
262262
return True
263263

0 commit comments

Comments
 (0)