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
Melanie Thielker 2010-07-03 20:27:00 +02:00
parent e4739523d3
commit edcfaf60c9
4 changed files with 85 additions and 34 deletions

View File

@ -156,15 +156,30 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
return;
}
// Force timestamp to server time to avoid "Saved on" headers
// being generated for online users
im.timestamp = (uint)Util.UnixTimeSinceEpoch();
DateTime dt = DateTime.UtcNow;
if (dialog == (byte)InstantMessageDialog.MessageFromAgent ||
dialog == (byte)InstantMessageDialog.MessageFromObject)
// Ticks from UtcNow, but make it look like local. Evil, huh?
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)
{

View File

@ -192,6 +192,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
// Needed for proper state management for stored group
// 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);
if (s != null)
s.EventManager.TriggerIncomingInstantMessage(im);
@ -201,35 +212,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
private void UndeliveredMessage(GridInstantMessage im)
{
if (im.dialog == 19)
im.offline = 1; // We want them pushed out to the server
if ((im.offline != 0)
&& (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages)))
if (im.dialog != (byte)InstantMessageDialog.MessageFromObject &&
im.dialog != (byte)InstantMessageDialog.MessageFromAgent &&
im.dialog != (byte)InstantMessageDialog.GroupNotice &&
im.dialog != (byte)InstantMessageDialog.InventoryOffered)
{
// It's not delivered. Make sure the scope id is saved
// 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());
return;
}
bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>(
"POST", m_RestURL+"/SaveMessage/", im);
// It's not delivered. Make sure the scope id is saved
// 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)
{
IClientAPI client = FindClient(new UUID(im.fromAgentID));
if (client == null)
return;
bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>(
"POST", m_RestURL+"/SaveMessage/", im);
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()));
}
if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
{
IClientAPI client = FindClient(new UUID(im.fromAgentID));
if (client == null)
return;
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()));
}
}
}

View File

@ -3730,8 +3730,11 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos);
{
CollidingMessage.Colliders = colliding;
foreach (SceneObjectGroup att in Attachments)
Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
lock (m_attachments)
{
foreach (SceneObjectGroup att in m_attachments)
Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
}
}
}

View File

@ -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
// 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());
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)
//{
msg.fromAgentName = m_host.Name;//client.FirstName + " " + client.LastName;// fromAgentName;