From e77ca65e575e4f8f7645aec879b73b87ba505f49 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 6 Jun 2011 17:46:34 -0700 Subject: This should make offline IMs work again. It should work for incoming foreign IMs where the local recipient is offline. I can't test any of this, because I don't run an offline IM server. --- .../InstantMessage/HGMessageTransferModule.cs | 5 ++- .../HypergridService/HGInstantMessageService.cs | 51 ++++++++++++++++++++-- 2 files changed, 51 insertions(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs index 4de197e..dee86df 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs @@ -213,7 +213,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage } } } - result(success); + if (!success && !foreigner) + HandleUndeliveredMessage(im, result); + else + result(success); }); return; diff --git a/OpenSim/Services/HypergridService/HGInstantMessageService.cs b/OpenSim/Services/HypergridService/HGInstantMessageService.cs index 4f68e55..66cf4de 100644 --- a/OpenSim/Services/HypergridService/HGInstantMessageService.cs +++ b/OpenSim/Services/HypergridService/HGInstantMessageService.cs @@ -67,6 +67,10 @@ namespace OpenSim.Services.HypergridService protected static Dictionary m_UserLocationMap = new Dictionary(); private static ExpiringCache m_RegionCache; + private static string m_RestURL; + private static bool m_ForwardOfflineGroupMessages; + private static bool m_InGatekeeper; + public HGInstantMessageService(IConfigSource config) : this(config, null) { @@ -81,8 +85,6 @@ namespace OpenSim.Services.HypergridService { m_Initialized = true; - m_log.DebugFormat("[HG IM SERVICE]: Starting..."); - IConfig serverConfig = config.Configs["HGInstantMessageService"]; if (serverConfig == null) throw new Exception(String.Format("No section HGInstantMessageService in config file")); @@ -90,6 +92,9 @@ namespace OpenSim.Services.HypergridService string gridService = serverConfig.GetString("GridService", String.Empty); string presenceService = serverConfig.GetString("PresenceService", String.Empty); string userAgentService = serverConfig.GetString("UserAgentService", String.Empty); + m_InGatekeeper = serverConfig.GetBoolean("InGatekeeper", false); + m_log.DebugFormat("[HG IM SERVICE]: Starting... InRobust? {0}", m_InGatekeeper); + if (gridService == string.Empty || presenceService == string.Empty) throw new Exception(String.Format("Incomplete specifications, InstantMessage Service cannot function.")); @@ -101,6 +106,21 @@ namespace OpenSim.Services.HypergridService m_RegionCache = new ExpiringCache(); + IConfig cnf = config.Configs["Messaging"]; + if (cnf == null) + { + return; + } + + m_RestURL = cnf.GetString("OfflineMessageURL", string.Empty); + if (m_RestURL == string.Empty) + { + m_log.Error("[HG IM SERVICE]: Offline IMs enabled, but no URL is given"); + return; + } + + m_ForwardOfflineGroupMessages = cnf.GetBoolean("ForwardOfflineGroupMessages", false); + } } @@ -109,13 +129,21 @@ namespace OpenSim.Services.HypergridService m_log.DebugFormat("[HG IM SERVICE]: Received message from {0} to {1}", im.fromAgentID, im.toAgentID); UUID toAgentID = new UUID(im.toAgentID); + bool success = false; if (m_IMSimConnector != null) { //m_log.DebugFormat("[XXX] SendIMToRegion local im connector"); - return m_IMSimConnector.SendInstantMessage(im); + success = m_IMSimConnector.SendInstantMessage(im); } else - return TrySendInstantMessage(im, "", true, false); + { + success = TrySendInstantMessage(im, "", true, false); + } + + if (!success && m_InGatekeeper) // we do this only in the Gatekeeper IM service + UndeliveredMessage(im); + + return success; } public bool OutgoingInstantMessage(GridInstantMessage im, string url, bool foreigner) @@ -129,6 +157,7 @@ namespace OpenSim.Services.HypergridService upd.RegionID = UUID.Zero; return TrySendInstantMessage(im, upd, true, foreigner); } + } protected bool TrySendInstantMessage(GridInstantMessage im, object previousLocation, bool firstTime, bool foreigner) @@ -313,5 +342,19 @@ namespace OpenSim.Services.HypergridService } } + + private bool UndeliveredMessage(GridInstantMessage im) + { + if (m_RestURL != string.Empty && (im.offline != 0) + && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages))) + { + return SynchronousRestObjectPoster.BeginPostObject( + "POST", m_RestURL + "/SaveMessage/", im); + + } + + else + return false; + } } } -- cgit v1.1