aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorMelanie Thielker2010-07-03 20:27:00 +0200
committerMelanie Thielker2010-07-03 20:27:00 +0200
commitedcfaf60c99b7cde324621c2ffcfbb16e4eb4c5e (patch)
treed48676190d41a69cb6aebff794c6291cd93198c4 /OpenSim/Region/CoreModules
parentMerge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/ca... (diff)
downloadopensim-SC-edcfaf60c99b7cde324621c2ffcfbb16e4eb4c5e.zip
opensim-SC-edcfaf60c99b7cde324621c2ffcfbb16e4eb4c5e.tar.gz
opensim-SC-edcfaf60c99b7cde324621c2ffcfbb16e4eb4c5e.tar.bz2
opensim-SC-edcfaf60c99b7cde324621c2ffcfbb16e4eb4c5e.tar.xz
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.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs27
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs65
2 files changed, 60 insertions, 32 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index a7aa4ea..ffdac58 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -156,16 +156,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
156 return; 156 return;
157 } 157 }
158 158
159 // Force timestamp to server time to avoid "Saved on" headers 159 DateTime dt = DateTime.UtcNow;
160 // being generated for online users
161 im.timestamp = (uint)Util.UnixTimeSinceEpoch();
162 160
163 if (dialog == (byte)InstantMessageDialog.MessageFromAgent || 161 // Ticks from UtcNow, but make it look like local. Evil, huh?
164 dialog == (byte)InstantMessageDialog.MessageFromObject) 162 dt = DateTime.SpecifyKind(dt, DateTimeKind.Local);
163
164 try
165 {
166 // Convert that to the PST timezone
167 TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles");
168 dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo);
169 }
170 catch
165 { 171 {
166 im.offline = 1; 172 m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp.");
167 } 173 }
168 174
175 // And make it look local again to fool the unix time util
176 dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc);
177
178 im.timestamp = (uint)Util.ToUnixTime(dt);
179
180 // If client is null, this message comes from storage and IS offline
181 if (client != null)
182 im.offline = 0;
183
169 if (m_TransferModule != null) 184 if (m_TransferModule != null)
170 { 185 {
171 m_TransferModule.SendInstantMessage(im, 186 m_TransferModule.SendInstantMessage(im,
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
index a2dc91f..feeb9e6 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs
@@ -192,6 +192,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
192 // Needed for proper state management for stored group 192 // Needed for proper state management for stored group
193 // invitations 193 // invitations
194 // 194 //
195
196 im.offline = 1;
197
198 // Reconstruct imSessionID
199 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
200 {
201 UUID fromAgentID = new UUID(im.fromAgentID);
202 UUID sessionID = fromAgentID ^ client.AgentId;
203 im.imSessionID = new Guid(sessionID.ToString());
204 }
205
195 Scene s = FindScene(client.AgentId); 206 Scene s = FindScene(client.AgentId);
196 if (s != null) 207 if (s != null)
197 s.EventManager.TriggerIncomingInstantMessage(im); 208 s.EventManager.TriggerIncomingInstantMessage(im);
@@ -201,35 +212,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
201 212
202 private void UndeliveredMessage(GridInstantMessage im) 213 private void UndeliveredMessage(GridInstantMessage im)
203 { 214 {
204 if (im.dialog == 19) 215 if (im.dialog != (byte)InstantMessageDialog.MessageFromObject &&
205 im.offline = 1; // We want them pushed out to the server 216 im.dialog != (byte)InstantMessageDialog.MessageFromAgent &&
206 if ((im.offline != 0) 217 im.dialog != (byte)InstantMessageDialog.GroupNotice &&
207 && (!im.fromGroup || (im.fromGroup && m_ForwardOfflineGroupMessages))) 218 im.dialog != (byte)InstantMessageDialog.InventoryOffered)
208 { 219 {
209 // It's not delivered. Make sure the scope id is saved 220 return;
210 // We don't need the imSessionID here anymore, overwrite it 221 }
211 Scene scene = FindScene(new UUID(im.fromAgentID));
212 if (scene == null)
213 scene = m_SceneList[0];
214 im.imSessionID = new Guid(scene.RegionInfo.ScopeID.ToString());
215 222
216 bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>( 223 // It's not delivered. Make sure the scope id is saved
217 "POST", m_RestURL+"/SaveMessage/", im); 224 // We don't need the imSessionID here anymore, overwrite it
225 Scene scene = FindScene(new UUID(im.fromAgentID));
226 if (scene == null)
227 scene = m_SceneList[0];
228 im.imSessionID = new Guid(scene.RegionInfo.ScopeID.ToString());
218 229
219 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) 230 bool success = SynchronousRestObjectPoster.BeginPostObject<GridInstantMessage, bool>(
220 { 231 "POST", m_RestURL+"/SaveMessage/", im);
221 IClientAPI client = FindClient(new UUID(im.fromAgentID)); 232
222 if (client == null) 233 if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent)
223 return; 234 {
224 235 IClientAPI client = FindClient(new UUID(im.fromAgentID));
225 client.SendInstantMessage(new GridInstantMessage( 236 if (client == null)
226 null, new UUID(im.toAgentID), 237 return;
227 "System", new UUID(im.fromAgentID), 238
228 (byte)InstantMessageDialog.MessageFromAgent, 239 client.SendInstantMessage(new GridInstantMessage(
229 "User is not logged in. "+ 240 null, new UUID(im.toAgentID),
230 (success ? "Message saved." : "Message not saved"), 241 "System", new UUID(im.fromAgentID),
231 false, new Vector3())); 242 (byte)InstantMessageDialog.MessageFromAgent,
232 } 243 "User is not logged in. "+
244 (success ? "Message saved." : "Message not saved"),
245 false, new Vector3()));
233 } 246 }
234 } 247 }
235 } 248 }