Fix IMs the right way. This sets it up so that timestamps are actually
in PST (to match viewer time), does correct storage and retrieval of IMs, corrects the session ID and makes sure IMs don't get marked "saved" if they're live. Removes the group IM save option, which our group IM module never had in the first place, as saving group chatter makes no sense at all.avinationmerge
parent
e4739523d3
commit
edcfaf60c9
|
@ -156,15 +156,30 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force timestamp to server time to avoid "Saved on" headers
|
DateTime dt = DateTime.UtcNow;
|
||||||
// being generated for online users
|
|
||||||
im.timestamp = (uint)Util.UnixTimeSinceEpoch();
|
|
||||||
|
|
||||||
if (dialog == (byte)InstantMessageDialog.MessageFromAgent ||
|
// Ticks from UtcNow, but make it look like local. Evil, huh?
|
||||||
dialog == (byte)InstantMessageDialog.MessageFromObject)
|
dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
im.offline = 1;
|
// Convert that to the PST timezone
|
||||||
|
TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
|
||||||
|
dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// And make it look local again to fool the unix time util
|
||||||
|
dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
|
||||||
|
|
||||||
|
im.timestamp = (uint)Util.ToUnixTime(dt);
|
||||||
|
|
||||||
|
// If client is null, this message comes from storage and IS offline
|
||||||
|
if (client != null)
|
||||||
|
im.offline = 0;
|
||||||
|
|
||||||
if (m_TransferModule != null)
|
if (m_TransferModule != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -192,6 +192,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||||
// Needed for proper state management for stored group
|
// Needed for proper state management for stored group
|
||||||
// invitations
|
// invitations
|
||||||
//
|
//
|
||||||
|
|
||||||
|
im.offline = 1;
|
||||||
|
|
||||||
|
// Reconstruct imSessionID
|
||||||
|
if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
|
||||||
|
{
|
||||||
|
UUID fromAgentID = new UUID(im.fromAgentID);
|
||||||
|
UUID sessionID = fromAgentID ^ client.AgentId;
|
||||||
|
im.imSessionID = new Guid(sessionID.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
Scene s = FindScene(client.AgentId);
|
Scene s = FindScene(client.AgentId);
|
||||||
if (s != null)
|
if (s != null)
|
||||||
s.EventManager.TriggerIncomingInstantMessage(im);
|
s.EventManager.TriggerIncomingInstantMessage(im);
|
||||||
|
@ -201,35 +212,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
|
||||||
|
|
||||||
private void UndeliveredMessage(GridInstantMessage im)
|
private void UndeliveredMessage(GridInstantMessage im)
|
||||||
{
|
{
|
||||||
if (im.dialog == 19)
|
if (im.dialog != (byte)InstantMessageDialog.MessageFromObject &&
|
||||||
im.offline = 1; // We want them pushed out to the server
|
im.dialog != (byte)InstantMessageDialog.MessageFromAgent &&
|
||||||
if ((im.offline != 0)
|
im.dialog != (byte)InstantMessageDialog.GroupNotice &&
|
||||||
&& (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages)))
|
im.dialog != (byte)InstantMessageDialog.InventoryOffered)
|
||||||
{
|
{
|
||||||
// It's not delivered. Make sure the scope id is saved
|
return;
|
||||||
// We don't need the imSessionID here anymore, overwrite it
|
}
|
||||||
Scene scene = FindScene(new UUID(im.fromAgentID));
|
|
||||||
if (scene == null)
|
|
||||||
scene = m_SceneList[0];
|
|
||||||
im.imSessionID = new Guid(scene.RegionInfo.ScopeID.ToString());
|
|
||||||
|
|
||||||
bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>(
|
// It's not delivered. Make sure the scope id is saved
|
||||||
"POST", m_RestURL+"/SaveMessage/", im);
|
// We don't need the imSessionID here anymore, overwrite it
|
||||||
|
Scene scene = FindScene(new UUID(im.fromAgentID));
|
||||||
|
if (scene == null)
|
||||||
|
scene = m_SceneList[0];
|
||||||
|
im.imSessionID = new Guid(scene.RegionInfo.ScopeID.ToString());
|
||||||
|
|
||||||
if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
|
bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>(
|
||||||
{
|
"POST", m_RestURL+"/SaveMessage/", im);
|
||||||
IClientAPI client = FindClient(new UUID(im.fromAgentID));
|
|
||||||
if (client == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
client.SendInstantMessage(new GridInstantMessage(
|
if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
|
||||||
null, new UUID(im.toAgentID),
|
{
|
||||||
"System", new UUID(im.fromAgentID),
|
IClientAPI client = FindClient(new UUID(im.fromAgentID));
|
||||||
(byte)InstantMessageDialog.MessageFromAgent,
|
if (client == null)
|
||||||
"User is not logged in. "+
|
return;
|
||||||
(success ? "Message saved." : "Message not saved"),
|
|
||||||
false, new Vector3()));
|
client.SendInstantMessage(new GridInstantMessage(
|
||||||
}
|
null, new UUID(im.toAgentID),
|
||||||
|
"System", new UUID(im.fromAgentID),
|
||||||
|
(byte)InstantMessageDialog.MessageFromAgent,
|
||||||
|
"User is not logged in. "+
|
||||||
|
(success ? "Message saved." : "Message not saved"),
|
||||||
|
false, new Vector3()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3730,8 +3730,11 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos);
|
||||||
{
|
{
|
||||||
CollidingMessage.Colliders = colliding;
|
CollidingMessage.Colliders = colliding;
|
||||||
|
|
||||||
foreach (SceneObjectGroup att in Attachments)
|
lock (m_attachments)
|
||||||
Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
|
{
|
||||||
|
foreach (SceneObjectGroup att in m_attachments)
|
||||||
|
Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3252,7 +3252,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
|
msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
|
||||||
// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
|
// m_log.Debug("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
|
||||||
// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
|
// m_log.Debug("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
|
||||||
msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp;
|
DateTime dt = DateTime.UtcNow;
|
||||||
|
|
||||||
|
// Ticks from UtcNow, but make it look like local. Evil, huh?
|
||||||
|
dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Convert that to the PST timezone
|
||||||
|
TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
|
||||||
|
dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// No logging here, as it could be VERY spammy
|
||||||
|
}
|
||||||
|
|
||||||
|
// And make it look local again to fool the unix time util
|
||||||
|
dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
|
||||||
|
|
||||||
|
msg.timestamp = (uint)Util.ToUnixTime(dt);
|
||||||
|
|
||||||
//if (client != null)
|
//if (client != null)
|
||||||
//{
|
//{
|
||||||
msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;
|
msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;
|
||||||
|
|
Loading…
Reference in New Issue