Sfoglia il codice sorgente

Can delete the Offline Messages sent to/from a user.

This is useful if the user is deleted.
Oren Hurvitz 11 anni fa
parent
commit
2d9d6fe922

+ 5 - 0
OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs

@@ -261,6 +261,11 @@ namespace OpenSim.OfflineIM
             return m_OfflineIMService.StoreMessage(im, out reason);
         }
 
+        public void DeleteMessages(UUID userID)
+        {
+            m_OfflineIMService.DeleteMessages(userID);
+        }
+
         #endregion
     }
 }

+ 8 - 0
OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs

@@ -117,6 +117,14 @@ namespace OpenSim.OfflineIM
             return true;
         }
 
+        public void DeleteMessages(UUID userID)
+        {
+            Dictionary<string, object> sendData = new Dictionary<string, object>();
+            sendData["UserID"] = userID;
+            
+            MakeRequest("DELETE", sendData);
+        }
+
         #endregion
 
 

+ 17 - 0
OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs

@@ -102,6 +102,8 @@ namespace OpenSim.OfflineIM
                         return HandleGet(request);
                     case "STORE":
                         return HandleStore(request);
+                    case "DELETE":
+                        return HandleDelete(request);
                 }
                 m_log.DebugFormat("[OFFLINE IM HANDLER]: unknown method request: {0}", method);
             }
@@ -158,6 +160,21 @@ namespace OpenSim.OfflineIM
             return Util.UTF8NoBomEncoding.GetBytes(xmlString);
         }
 
+        byte[] HandleDelete(Dictionary<string, object> request)
+        {
+            if (!request.ContainsKey("UserID"))
+            {
+                return FailureResult();
+            }
+            else
+            {
+                UUID userID = new UUID(request["UserID"].ToString());
+                m_OfflineIMService.DeleteMessages(userID);
+
+                return SuccessResult();
+            }
+        }
+
         #region Helpers
 
         private void NullResult(Dictionary<string, object> result, string reason)

+ 7 - 0
OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs

@@ -124,5 +124,12 @@ namespace OpenSim.OfflineIM
             return m_Database.Store(data);
 
         }
+
+        public void DeleteMessages(UUID userID)
+        {
+            m_Database.Delete("PrincipalID", userID.ToString());
+            m_Database.Delete("FromID", userID.ToString());
+        }
+
     }
 }

+ 7 - 0
OpenSim/Services/Interfaces/IOfflineIMService.cs

@@ -35,7 +35,14 @@ namespace OpenSim.Services.Interfaces
     public interface IOfflineIMService
     {
         List<GridInstantMessage> GetMessages(UUID principalID);
+        
         bool StoreMessage(GridInstantMessage im, out string reason);
+        
+        /// <summary>
+        /// Delete messages to or from this user (or group).
+        /// </summary>
+        /// <param name="userID">A user or group ID</param>
+        void DeleteMessages(UUID userID);
     }
 
     public class OfflineIMDataUtils