Package org.vrspace.server.api
Class Groups
java.lang.Object
org.vrspace.server.api.ApiBase
org.vrspace.server.api.ClientControllerBase
org.vrspace.server.api.Groups
@RestController
@RequestMapping("/vrspace/api/groups")
public class Groups
extends ClientControllerBase
Manipulate user groups. All of these operations require a session with a
valid user currently logged in. So: login with either github, fb, google, and
enter a world before trying any of these. Only group members can read and
write group messages. Groups can public or private: everybody can join public
groups, and private groups require invitation by group owner(s). Temporary
groups are deleted after owner disconnects. Direct messaging groups are
always private.
- Author:
- joe
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAccept invitation to a private group.voidAllow a user (who asked) to join a private group.voidAsk to join a private group.voidattach(jakarta.servlet.http.HttpSession session, String fileName, String contentType, String groupId, String messageId, org.springframework.web.multipart.MultipartFile fileData) Add an attachment to a message: upload file to the server, and notify all message recipients.create(String name, Optional<Boolean> isPublic, Optional<Boolean> isTemporary, Optional<Boolean> isDirect, jakarta.servlet.http.HttpSession session) Create a group.voiddeleteGroup(String groupId, jakarta.servlet.http.HttpSession session) Delete a group.voidRemove an attachment from a message.org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBodygetAttachment(jakarta.servlet.http.HttpSession session, jakarta.servlet.http.HttpServletResponse response, String groupId, String messageId, String fileName) Get an attachment for a message.Get a group.voidInvite a user to a group.voidJoin a public group.voidKick a user from a group.voidLeave a group.listInvites(jakarta.servlet.http.HttpSession session) List pending invitations to groups for the current user.listMyGroups(jakarta.servlet.http.HttpSession session) List all user groups the user is member of.listOwnedGroups(jakarta.servlet.http.HttpSession session) List all user groups the user owns.listOwners(String groupId, jakarta.servlet.http.HttpSession session) List owners of a group.listRequests(String groupId, jakarta.servlet.http.HttpSession session) List pending requests to join the group.listUnreadGroups(jakarta.servlet.http.HttpSession session) List groups containing unread messages.listUnreadMessages(String groupId, jakarta.servlet.http.HttpSession session) List unread messages for the groupvoidshareWorld(String groupId, GroupMessage worldShare, jakarta.servlet.http.HttpSession session) Share a world link with the group.Show all members of a group.voidUpdate a group.Write something to a group.Methods inherited from class org.vrspace.server.api.ClientControllerBase
findClient, findClient, getAuthorisedClient, getAuthorisedClient, isAuthenticatedMethods inherited from class org.vrspace.server.api.ApiBase
currentUserName, isAuthenticated
-
Field Details
-
PATH
- See Also:
-
-
Constructor Details
-
Groups
public Groups()
-
-
Method Details
-
listMyGroups
@GetMapping @ResponseBody public List<UserGroup> listMyGroups(jakarta.servlet.http.HttpSession session) List all user groups the user is member of. -
listOwnedGroups
@GetMapping("/owned") @ResponseBody public List<UserGroup> listOwnedGroups(jakarta.servlet.http.HttpSession session) List all user groups the user owns. -
create
@PostMapping(produces="application/json") @ResponseStatus(CREATED) public UserGroup create(String name, Optional<Boolean> isPublic, Optional<Boolean> isTemporary, Optional<Boolean> isDirect, jakarta.servlet.http.HttpSession session) Create a group.- Parameters:
name- Group nameisPublic- Create a public group? Defaults to false.isTemporary- Create a temporary group? Defaults to false.isDirect- Create a direct messaging group? Defaults to false.
-
update
@PutMapping(produces="application/json") public void update(@RequestBody UserGroup group, jakarta.servlet.http.HttpSession session) Update a group.- Parameters:
group- updated group
-
deleteGroup
@DeleteMapping("/{groupId}") public void deleteGroup(@PathVariable String groupId, jakarta.servlet.http.HttpSession session) Delete a group. A group can only be deleted by the owner(s). -
getGroup
@GetMapping("/{groupId}") public UserGroup getGroup(@PathVariable String groupId, jakarta.servlet.http.HttpSession session) Get a group. -
show
@GetMapping("/{groupId}/show") public List<Client> show(@PathVariable String groupId, jakarta.servlet.http.HttpSession session) Show all members of a group. -
join
@PostMapping("/{groupId}/join") public void join(@PathVariable String groupId, jakarta.servlet.http.HttpSession session) Join a public group. -
invite
@PostMapping("/{groupId}/invite") public void invite(@PathVariable String groupId, String clientId, jakarta.servlet.http.HttpSession session) Invite a user to a group. Only group owner(s) can invite users to private groups. Invited users have to accept invitation. Offline users may get web push notification, if these are configured.- Parameters:
groupId- Group to invite toclientId- Client to invite
-
ask
@PostMapping("/{groupId}/ask") public void ask(@PathVariable String groupId, jakarta.servlet.http.HttpSession session) Ask to join a private group. Group owner needs to allow new members to join. -
accept
@PostMapping("/{groupId}/accept") public void accept(@PathVariable String groupId, jakarta.servlet.http.HttpSession session) Accept invitation to a private group. -
allow
@PostMapping("/{groupId}/allow") public void allow(@PathVariable String groupId, String clientId, jakarta.servlet.http.HttpSession session) Allow a user (who asked) to join a private group. Only group owner(s) can do that.- Parameters:
groupId- Group to joinclientId- Client that asked to join
-
leave
@PostMapping("/{groupId}/leave") public void leave(@PathVariable String groupId, jakarta.servlet.http.HttpSession session) Leave a group. Group owners can not leave. Also used to reject invitation to join the group. -
kick
@PostMapping("/{groupId}/kick") public void kick(@PathVariable String groupId, String clientId, jakarta.servlet.http.HttpSession session) Kick a user from a group. Only group owner(s) can do that. Also used to reject request to join.- Parameters:
groupId- Where to kick fromclientId- Whom to kick
-
write
@PostMapping("/{groupId}/write") public String write(@PathVariable String groupId, @RequestBody String text, jakarta.servlet.http.HttpSession session) Write something to a group. Online users are notified right away over the web socket, offline users may get web push notification, if these are configured.- Parameters:
groupId- The grouptext- The message- Returns:
- message UUID
-
listRequests
@GetMapping("/{groupId}/requests") public List<GroupMember> listRequests(@PathVariable String groupId, jakarta.servlet.http.HttpSession session) List pending requests to join the group. Only group owners can do that.- Parameters:
groupId-
-
listInvites
@GetMapping("/invitations") public List<GroupMember> listInvites(jakarta.servlet.http.HttpSession session) List pending invitations to groups for the current user. -
listUnreadGroups
@GetMapping("/unread") public List<UserGroup> listUnreadGroups(jakarta.servlet.http.HttpSession session) List groups containing unread messages.- Returns:
- List of groups having unread messages
-
listUnreadMessages
@GetMapping("/{groupId}/unread") public List<GroupMessage> listUnreadMessages(@PathVariable String groupId, jakarta.servlet.http.HttpSession session) List unread messages for the group- Parameters:
groupId- group identifier- Returns:
- List of unread messages in the group
-
listOwners
@GetMapping("/{groupId}/owners") public List<Client> listOwners(@PathVariable String groupId, jakarta.servlet.http.HttpSession session) List owners of a group. Needed e.g. to ask to join a private group.- Parameters:
groupId- group identifier- Returns:
- List of users owning the group
-
attach
@PutMapping("/{groupId}/{messageId}/attachment") public void attach(jakarta.servlet.http.HttpSession session, String fileName, String contentType, @PathVariable String groupId, @PathVariable String messageId, @RequestPart org.springframework.web.multipart.MultipartFile fileData) Add an attachment to a message: upload file to the server, and notify all message recipients.- Parameters:
fileName-contentType-groupId-messageId-fileData-
-
detach
@DeleteMapping("/{groupId}/{messageId}/attachment") public void detach(jakarta.servlet.http.HttpSession session, String fileName, @PathVariable String groupId, @PathVariable String messageId) Remove an attachment from a message. Removes the file from the server and notifies all other clients.- Parameters:
fileName-groupId-messageId-
-
getAttachment
@GetMapping("/{groupId}/{messageId}/attachment/{fileName}") public org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody getAttachment(jakarta.servlet.http.HttpSession session, jakarta.servlet.http.HttpServletResponse response, @PathVariable String groupId, @PathVariable String messageId, @PathVariable String fileName) Get an attachment for a message. Only users that can read the message can do that.- Parameters:
groupId-messageId-fileName-- Returns:
-