Federation tweaks

This commit is contained in:
G. Gibson 2026-06-02 00:28:14 -07:00
parent 29d9266ca3
commit fe0656b79c
2 changed files with 61 additions and 7 deletions

View file

@ -1,18 +1,53 @@
#
module GxG
#
GXG_FEDERATION = {:title => "Untitled", :uuid => nil, :access_url => nil, :available => {}, :connections => {}}
GXG_FEDERATION = {:title => "Untitled", :uuid => nil, :access_url => nil, :servers => {}, :connections => {}}
GXG_FEDERATION_SAFETY = Mutex.new
def self.federation_servers()
result = {}
::GxG::GXG_FEDERATION_SAFETY.synchronize {
::GxG::GXG_FEDERATION[:available].each_pair do |uuid, server|
::GxG::GXG_FEDERATION[:servers].each_pair do |uuid, server|
result[(uuid.to_s.to_sym)] = server
end
}
result
end
#
def self.add_federation_server(the_server=nil)
result = false
if the_server.is_a?(::GxG::Networking::GxGRemoteServer)
::GxG::GXG_FEDERATION_SAFETY.synchronize {
::GxG::GXG_FEDERATION[:servers][(the_server.uuid)] = the_server
}
result = true
end
result
end
#
def self.remove_federation_server(the_reference=nil)
result = nil
if the_reference.is_any?(::String, ::Symbol)
if ::GxG::valid_uuid?(the_reference.to_s.to_sym)
the_uuid = the_reference.to_s.to_sym
else
the_uuid = nil
manifest = ::GxG::federation_servers()
manifest.each_pair do |uuid,server|
if server.title == the_reference.to_s
the_uuid = uuid
break
end
end
end
end
if the_uuid
::GxG::GXG_FEDERATION_SAFETY.synchronize {
result = ::GxG::GXG_FEDERATION[:servers].delete(the_uuid)
}
end
result
end
#
module Messages
class Channel
#

View file

@ -3915,7 +3915,9 @@ module GxG
@clients[(service)].login(@uri.username, @uri.password)
#
end
@status = :connected
unless ::GxG::add_federation_server(self)
raise Exception.new("Failure to register remote server #{@hostname.to_s}")
end
self
end
#
@ -3992,12 +3994,28 @@ module GxG
end
#
def login(username=nil, password=nil)
#
@services.keys.each do |service|
@clients[(service)].login(username, password)
result = false
unless username
username = @uri.username
end
unless password
password = @uri.password
end
#
true
#
@services.keys.each do |service|
if @clients[(service)].login(username, password)
result = true
else
result = false
break
end
end
if result
@status = :available
end
#
result
end
#
def logout
@ -4005,6 +4023,7 @@ module GxG
@services.keys.each do |service|
@clients[(service)].logout
end
@status = :unavailable
#
true
end