| 226 | } |
| 227 | |
| 228 | Json TeamManager::invite(Json const& arguments) { |
| 229 | RecursiveMutexLocker lock(m_mutex); |
| 230 | auto inviteeName = Text::stripEscapeCodes(arguments.getString("inviteeName")); |
| 231 | |
| 232 | if (inviteeName.empty()) |
| 233 | return "inviteeNotFound"; |
| 234 | |
| 235 | auto inviterUuid = Uuid(arguments.getString("inviterUuid")); |
| 236 | |
| 237 | JsonArray invited; |
| 238 | for (auto& entry : m_connectedPlayers) { |
| 239 | if (!Text::stripEscapeCodes(entry.first).beginsWith(inviteeName, String::CaseInsensitive)) |
| 240 | continue; |
| 241 | |
| 242 | for (auto& inviteeUuid : entry.second) { |
| 243 | Invitation invitation; |
| 244 | invitation.inviterUuid = inviterUuid; |
| 245 | invitation.inviterName = arguments.getString("inviterName"); |
| 246 | m_invitations[inviteeUuid] = invitation; |
| 247 | invited.append(JsonArray{entry.first, inviteeUuid.hex()}); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | if (!invited.empty()) |
| 252 | return invited; |
| 253 | else |
| 254 | return "inviteeNotFound"; |
| 255 | } |
| 256 | |
| 257 | Json TeamManager::pollInvitation(Json const& arguments) { |
| 258 | RecursiveMutexLocker lock(m_mutex); |
nothing calls this directly
no test coverage detected