Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop

This commit is contained in:
Nuwan 2024-03-21 00:31:47 +05:30
commit a420767446
4 changed files with 48 additions and 18 deletions

View File

@ -1,6 +1,6 @@
class AddAcceptDesktopNotificationsToUsers < ActiveRecord::Migration
def self.up
execute("ALTER TABLE public.users ADD COLUMN accept_desktop_notifications BOOLEAN DEFAULT false;")
execute("ALTER TABLE public.users ADD COLUMN accept_desktop_notifications BOOLEAN; UPDATE public.users SET accept_desktop_notifications = FALSE; ALTER TABLE public.users ALTER COLUMN accept_desktop_notifications SET DEFAULT FALSE;")
end
def self.down
execute("ALTER TABLE public.users DROP COLUMN accept_desktop_notifications;")

View File

@ -3,8 +3,17 @@ module JamRuby
DEFAULT_ENVIRONMENT = 'public'
CLIENT_PREFIX = 'JamClient'
CLIENT_PREFIX_MODERN = 'JamClientModern'
PRODUCTS = ["#{CLIENT_PREFIX}/Win32", "#{CLIENT_PREFIX}/MacOSX", "#{CLIENT_PREFIX}/JamBlaster", "#{CLIENT_PREFIX}/JamBlasterClient"]
PRODUCTS = [
"#{CLIENT_PREFIX}/Win32",
"#{CLIENT_PREFIX}/MacOSX",
"#{CLIENT_PREFIX}/JamBlaster",
"#{CLIENT_PREFIX}/JamBlasterClient",
"#{CLIENT_PREFIX_MODERN}/Win32",
"#{CLIENT_PREFIX_MODERN}/MacOSX-Intel",
"#{CLIENT_PREFIX_MODERN}/MacOSX-M"
]
self.primary_key = 'id'
attr_accessible :version, :uri, :sha1, :environment, :product, as: :admin
@ -34,8 +43,8 @@ module JamRuby
Notification.send_client_update(product, version, determine_url, size)
end
def self.find_client_by_os(os, environment=DEFAULT_ENVIRONMENT)
ArtifactUpdate.find_by_product_and_environment("#{CLIENT_PREFIX}/#{os}", environment)
def self.find_client_by_os(product, os, environment=DEFAULT_ENVIRONMENT)
ArtifactUpdate.find_by_product_and_environment("#{product}/#{os}", environment)
end
def determine_url

View File

@ -1531,13 +1531,13 @@
//this custom url scheme is loaded and as a result the JamKazam app loads create session window.
function initCustomUrlScheme(){
//an example URL would be: https://www.jamkazam.com/client#/createSession/custom~yes|privacy~2|description~hello|inviteeIds~1,2,3,4
const hash = decodeURIComponent(context.location.hash);
const qStr = hash.substring(hash.lastIndexOf('/') + 1);
var hash = decodeURIComponent(context.location.hash);
var qStr = hash.substring(hash.lastIndexOf('/') + 1);
//decode the query params according to the custom format
const qParamsArr = qStr.split('|');
let isCustom, privacy, description, inviteeIds;
var qParamsArr = qStr.split('|');
var isCustom, privacy, description, inviteeIds;
qParamsArr.forEach(function(q){
const qp = q.split('~')
var qp = q.split('~')
if(qp[0] === 'custom') isCustom = qp[1]
if(qp[0] === 'privacy') privacy = qp[1]
if(qp[0] === 'description') description = qp[1]
@ -1567,9 +1567,9 @@
waitUntilSessionCreated().then(function(){
//now async send invitations
if(createSessionSettings.newSessionId && inviteeIds !== undefined){
const inviteUserIds = inviteeIds.split(',');
var inviteUserIds = inviteeIds.split(',');
inviteUserIds.forEach(function(inviteId){
const invite = {
var invite = {
music_session: createSessionSettings.newSessionId,
receiver: inviteId
};
@ -1587,10 +1587,10 @@
function waitUntilSessionCreated(){
return new Promise(function(resolve, reject){
const maxAttempts = 5;
let attempt = 0;
var maxAttempts = 5;
var attempt = 0;
try{
const sessionCreateInterval = setInterval(function(){
var sessionCreateInterval = setInterval(function(){
attempt++;
console.log('_DEBUG_ trying to get the sessionId....', attempt)
if(createSessionSettings.newSessionId){

View File

@ -123,7 +123,7 @@ module JamWebsockets
sleep 1
end
}
end
end
def start(connect_time_stale_client, connect_time_expire_client, connect_time_stale_browser, connect_time_expire_browser, options={:host => "localhost", :port => 5672, :max_connections_per_user => 10, :gateway => 'default', :allow_dynamic_registration => true, :chat_enabled => true, :chat_blast => true}, &block)
@ -790,6 +790,7 @@ module JamWebsockets
end
def handle_login(client, options, override_ip = nil, connecting = true)
puts("====handle_login====", options)
username = options["username"]
password = options["password"]
token = options["token"]
@ -798,6 +799,8 @@ module JamWebsockets
client_type = options["client_type"]
machine_fingerprint = options["machine"]
os = options["os"]
product = options["product"].nil? ? JamRuby::ArtifactUpdate::CLIENT_PREFIX : options['
product']
udp_reachable = options["udp_reachable"].nil? ? true : options["udp_reachable"] == 'true'
jamblaster_serial_no = options["jamblaster_serial_no"]
ipv4_link_local = options["ipv4_link_local"]
@ -1001,9 +1004,12 @@ module JamWebsockets
end
end
end
puts "========================="
puts "O/S = #{os}"
puts "========================="
# if we have OS data, try to grab client update data and let the client have it
update = ArtifactUpdate.find_client_by_os(os) if client_type == Connection::TYPE_CLIENT && os
update = ArtifactUpdate.find_client_by_os(product, os) if client_type == Connection::TYPE_CLIENT && os
client_update = update.update_data if update
@ -1053,7 +1059,7 @@ module JamWebsockets
end
end
# if we have OS data, try to grab client update data and let the client have it
update = ArtifactUpdate.find_client_by_os(os) if client_type == Connection::TYPE_CLIENT && os
update = ArtifactUpdate.find_client_by_os(product, os) if client_type == Connection::TYPE_CLIENT && os
client_update = update.update_data if update
@ -1536,6 +1542,21 @@ module JamWebsockets
end
end
def periodical_update_user_last_seen
active_users_ids = @client_lookup.map { |client_id, client_context| client_context.active ? client_context.user.id : nil }.compact.uniq
if active_users_ids.any?
sql = %{
update users set last_jam_updated_at = now(), last_jam_updated_reason='#{User::JAM_REASON_PRESENT}' where users.id in (#{active_users_ids.map{|id| "'#{id}'"}.join(',')});
}
@log.info("SQL #{sql}")
ConnectionManager.active_record_transaction do |connection_manager, conn|
conn.exec(sql)
end
end
end
def periodical_stats_dump
# assume 60 seconds per status dump