diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs | 23 | ||||
-rw-r--r-- | OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs | 43 |
2 files changed, 63 insertions, 3 deletions
diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs index 71c3c73..9969086 100644 --- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs | |||
@@ -91,6 +91,9 @@ namespace OpenSim.Server.Handlers.Friends | |||
91 | case "deletefriend": | 91 | case "deletefriend": |
92 | return DeleteFriend(request); | 92 | return DeleteFriend(request); |
93 | 93 | ||
94 | case "deletefriend_string": | ||
95 | return DeleteFriendString(request); | ||
96 | |||
94 | } | 97 | } |
95 | m_log.DebugFormat("[FRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method); | 98 | m_log.DebugFormat("[FRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method); |
96 | } | 99 | } |
@@ -184,7 +187,25 @@ namespace OpenSim.Server.Handlers.Friends | |||
184 | else | 187 | else |
185 | return FailureResult(); | 188 | return FailureResult(); |
186 | } | 189 | } |
187 | 190 | ||
191 | byte[] DeleteFriendString(Dictionary<string, object> request) | ||
192 | { | ||
193 | string principalID = string.Empty; | ||
194 | if (request.ContainsKey("PRINCIPALID")) | ||
195 | principalID = request["PRINCIPALID"].ToString(); | ||
196 | else | ||
197 | m_log.WarnFormat("[FRIENDS HANDLER]: no principalID in request to delete friend"); | ||
198 | string friend = string.Empty; | ||
199 | if (request.ContainsKey("FRIEND")) | ||
200 | friend = request["FRIEND"].ToString(); | ||
201 | |||
202 | bool success = m_FriendsService.Delete(principalID, friend); | ||
203 | if (success) | ||
204 | return SuccessResult(); | ||
205 | else | ||
206 | return FailureResult(); | ||
207 | } | ||
208 | |||
188 | #endregion | 209 | #endregion |
189 | 210 | ||
190 | #region Misc | 211 | #region Misc |
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs index dde7875..a83d0e8 100644 --- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs +++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs | |||
@@ -88,6 +88,8 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
88 | case "newfriendship": | 88 | case "newfriendship": |
89 | return NewFriendship(request); | 89 | return NewFriendship(request); |
90 | 90 | ||
91 | case "deletefriendship": | ||
92 | return DeleteFriendship(request); | ||
91 | } | 93 | } |
92 | m_log.DebugFormat("[HGFRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method); | 94 | m_log.DebugFormat("[HGFRIENDS HANDLER]: unknown method {0} request {1}", method.Length, method); |
93 | } | 95 | } |
@@ -143,11 +145,21 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
143 | 145 | ||
144 | // OK, can proceed | 146 | // OK, can proceed |
145 | FriendInfo friend = new FriendInfo(request); | 147 | FriendInfo friend = new FriendInfo(request); |
148 | UUID friendID; | ||
149 | string tmp = string.Empty; | ||
150 | if (!Util.ParseUniversalUserIdentifier(friend.Friend, out friendID, out tmp, out tmp, out tmp, out tmp)) | ||
151 | return FailureResult(); | ||
152 | |||
153 | m_log.DebugFormat("[HGFRIENDS HANDLER]: New friendship {0} {1}", friend.PrincipalID, friend.Friend); | ||
154 | |||
155 | // If the friendship already exists, return fail | ||
156 | FriendInfo[] finfos = m_FriendsService.GetFriends(friend.PrincipalID); | ||
157 | foreach (FriendInfo finfo in finfos) | ||
158 | if (finfo.Friend.StartsWith(friendID.ToString())) | ||
159 | return FailureResult(); | ||
146 | 160 | ||
147 | // the user needs to confirm when he gets home | 161 | // the user needs to confirm when he gets home |
148 | bool success = m_FriendsService.StoreFriend(friend.PrincipalID.ToString(), friend.Friend, 0); | 162 | bool success = m_FriendsService.StoreFriend(friend.PrincipalID.ToString(), friend.Friend, 0); |
149 | //if (success) | ||
150 | // m_FriendsService.StoreFriend(friend.Friend, friend.PrincipalID.ToString(), 1); | ||
151 | 163 | ||
152 | if (success) | 164 | if (success) |
153 | return SuccessResult(); | 165 | return SuccessResult(); |
@@ -155,6 +167,33 @@ namespace OpenSim.Server.Handlers.Hypergrid | |||
155 | return FailureResult(); | 167 | return FailureResult(); |
156 | } | 168 | } |
157 | 169 | ||
170 | byte[] DeleteFriendship(Dictionary<string, object> request) | ||
171 | { | ||
172 | FriendInfo friend = new FriendInfo(request); | ||
173 | string secret = string.Empty; | ||
174 | if (request.ContainsKey("SECRET")) | ||
175 | secret = request["SECRET"].ToString(); | ||
176 | |||
177 | if (secret == string.Empty) | ||
178 | return FailureResult(); | ||
179 | |||
180 | FriendInfo[] finfos = m_FriendsService.GetFriends(friend.PrincipalID); | ||
181 | foreach (FriendInfo finfo in finfos) | ||
182 | { | ||
183 | // We check the secret here | ||
184 | if (finfo.Friend.StartsWith(friend.Friend) && finfo.Friend.EndsWith(secret)) | ||
185 | { | ||
186 | m_log.DebugFormat("[HGFRIENDS HANDLER]: Delete friendship {0} {1}", friend.PrincipalID, friend.Friend); | ||
187 | m_FriendsService.Delete(friend.PrincipalID, finfo.Friend); | ||
188 | m_FriendsService.Delete(finfo.Friend, friend.PrincipalID.ToString()); | ||
189 | |||
190 | return SuccessResult(); | ||
191 | } | ||
192 | } | ||
193 | |||
194 | return FailureResult(); | ||
195 | } | ||
196 | |||
158 | #endregion | 197 | #endregion |
159 | 198 | ||
160 | #region Misc | 199 | #region Misc |