Package io.meeds.chat.service
Class MatrixService
java.lang.Object
io.meeds.chat.service.MatrixService
-
Constructor Summary
ConstructorsConstructorDescriptionMatrixService(MatrixRoomStorage matrixRoomStorage, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.storage.api.IdentityStorage identityStorage, org.exoplatform.services.organization.OrganizationService organizationService, MatrixHttpClient matrixHttpClient) -
Method Summary
Modifier and TypeMethodDescriptioncreateDirectMessagingRoom(DirectMessagingRoom directMessagingRoom) createRoom(org.exoplatform.social.core.space.model.Space space) This function do : - Create a room on Matrix - Links the room to the space on Meeds - Update room permissionscreateRoomForSpaceOnMatrix(org.exoplatform.social.core.space.model.Space space) Creates a room on Matrix for the spacevoiddeleteRoom(String roomId) Delete a Matrix roomvoiddisableAccount(String matrixUsername) extractUserId(String fullMatrixUserId) Extracts the user ID from the full User Id on Matrixorg.exoplatform.social.core.identity.model.IdentityfindUserByMatrixId(String userIdOnMatrix) Searches for a user having the provided Matrix IDlonggetDirectMessagingRoom(String firstParticipant, String secondParticipant) getDMRoomByRoomId(String roomId) Returns the DM room by room IDgetJWTSessionToken(String userNameOnMatrix) Returns the JWT for user authenticationgetMatrixDMRoomsOfUser(String user) getMatrixIdForUser(String userName) Get the matrix ID of a defined usergetRoomBySpace(org.exoplatform.social.core.space.model.Space space) Returns the ID of the room linked to a spacegetRoomSettings(String roomId) org.exoplatform.social.core.space.model.SpacegetSpaceByRoomId(String roomId) Returns the Space linked to the roomReturns a list of all space roomsvoidinit()booleanisUserMemberOfGroup(String userName, String groupId) voidjoinUserToRoom(String roomId, String matrixIdOfUser) voidkickUserFromRoom(String roomId, String matrixIdOfUser, String message) linkSpaceToMatrixRoom(org.exoplatform.social.core.space.model.Space space, String roomId) records the matrix ID of the room linked to the spacevoidmakeUserAdminInRoom(String matrixRoomId, String matrixIdOfUser) processRooms(RoomList roomList, String currentUserName) Process the Matrix rooms and adds the missing information of users and spacesvoidrenameRoom(String roomId, String spaceDisplayName) saveUserAccount(org.exoplatform.services.organization.User user, boolean isNew, boolean isEnableUserOperation) Saves a new user on MatrixvoidupdateRoomAvatar(org.exoplatform.social.core.space.model.Space space, String roomId) booleanupdateRoomDescription(String roomId, String description) booleanupdateRoomSettings(String roomId, MatrixRoomPermissions matrixRoomPermissions) voidupdateUserAvatar(org.exoplatform.social.core.identity.model.Profile profile, String userMatrixID) voidupdateUserDisplayName(String matrixFullID, String newDisplayName) updateUserPresence(String userIdOnMatrix, String presence, String statusMessage) update the user presence status on MatrixuploadFileOnMatrix(String fileName, String mimeType, byte[] fileBytes)
-
Constructor Details
-
MatrixService
public MatrixService(MatrixRoomStorage matrixRoomStorage, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.storage.api.IdentityStorage identityStorage, org.exoplatform.services.organization.OrganizationService organizationService, MatrixHttpClient matrixHttpClient)
-
-
Method Details
-
init
@PostConstruct public void init() throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException- Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
updateUserDisplayName
-
getRoomBySpace
Returns the ID of the room linked to a space- Parameters:
space-- Returns:
- the roomId linked to the space
-
getSpaceByRoomId
Returns the Space linked to the room- Parameters:
roomId- the Matrix room ID- Returns:
- the space
-
getDMRoomByRoomId
Returns the DM room by room ID- Parameters:
roomId- the Matrix room ID- Returns:
- the Direct messaging room
-
getById
-
linkSpaceToMatrixRoom
public SpaceRoom linkSpaceToMatrixRoom(org.exoplatform.social.core.space.model.Space space, String roomId) records the matrix ID of the room linked to the space- Parameters:
space- the SpaceroomId- the ID of the matrix room- Returns:
- the room ID
-
createRoomForSpaceOnMatrix
public String createRoomForSpaceOnMatrix(org.exoplatform.social.core.space.model.Space space) throws Exception Creates a room on Matrix for the space- Parameters:
space- the space- Returns:
- String representing the room id
- Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedExceptionException
-
getMatrixIdForUser
Get the matrix ID of a defined user- Parameters:
userName- of the user- Returns:
- the matrix ID
-
getJWTSessionToken
Returns the JWT for user authentication- Parameters:
userNameOnMatrix- the username of the current user- Returns:
- String
-
saveUserAccount
public String saveUserAccount(org.exoplatform.services.organization.User user, boolean isNew, boolean isEnableUserOperation) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException Saves a new user on Matrix- Parameters:
user- the user to create on MatrixisNew- boolean if the user is new, then true- Returns:
- String the matrix user ID
- Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
uploadFileOnMatrix
public String uploadFileOnMatrix(String fileName, String mimeType, byte[] fileBytes) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException - Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
updateUserAvatar
public void updateUserAvatar(org.exoplatform.social.core.identity.model.Profile profile, String userMatrixID) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException - Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
disableAccount
public void disableAccount(String matrixUsername) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException - Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
updateRoomDescription
public boolean updateRoomDescription(String roomId, String description) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException - Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
updateRoomAvatar
public void updateRoomAvatar(org.exoplatform.social.core.space.model.Space space, String roomId) throws Exception - Throws:
Exception
-
getRoomSettings
public MatrixRoomPermissions getRoomSettings(String roomId) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException - Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
updateRoomSettings
public boolean updateRoomSettings(String roomId, MatrixRoomPermissions matrixRoomPermissions) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException - Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
kickUserFromRoom
public void kickUserFromRoom(String roomId, String matrixIdOfUser, String message) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException - Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
joinUserToRoom
public void joinUserToRoom(String roomId, String matrixIdOfUser) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException - Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
renameRoom
public void renameRoom(String roomId, String spaceDisplayName) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException - Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
makeUserAdminInRoom
public void makeUserAdminInRoom(String matrixRoomId, String matrixIdOfUser) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException - Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
createRoom
This function do : - Create a room on Matrix - Links the room to the space on Meeds - Update room permissions- Parameters:
space- The space- Returns:
- The room ID
- Throws:
Exception
-
getAllLinkedRooms
public long getAllLinkedRooms() -
getDirectMessagingRoom
public DirectMessagingRoom getDirectMessagingRoom(String firstParticipant, String secondParticipant) -
deleteRoom
public void deleteRoom(String roomId) throws org.exoplatform.ws.frameworks.json.impl.JsonException, IOException, InterruptedException Delete a Matrix room- Parameters:
roomId- the room identifier- Throws:
org.exoplatform.ws.frameworks.json.impl.JsonExceptionIOExceptionInterruptedException
-
createDirectMessagingRoom
public DirectMessagingRoom createDirectMessagingRoom(DirectMessagingRoom directMessagingRoom) throws org.exoplatform.commons.ObjectAlreadyExistsException - Throws:
org.exoplatform.commons.ObjectAlreadyExistsException
-
getMatrixDMRoomsOfUser
-
isUserMemberOfGroup
- Throws:
Exception
-
getSpaceRooms
Returns a list of all space rooms- Returns:
- List of Space rooms
-
findUserByMatrixId
public org.exoplatform.social.core.identity.model.Identity findUserByMatrixId(String userIdOnMatrix) Searches for a user having the provided Matrix ID- Parameters:
userIdOnMatrix- the ID of the user on Matrix- Returns:
- The identity of the user
-
processRooms
Process the Matrix rooms and adds the missing information of users and spaces- Parameters:
roomList- the room list received from Matrix par sync APIcurrentUserName- the current user- Returns:
- the roo List after processing
-
extractUserId
Extracts the user ID from the full User Id on Matrix- Parameters:
fullMatrixUserId- the full Matrix user Id- Returns:
- the user Identifier
-
updateUserPresence
update the user presence status on Matrix- Parameters:
userIdOnMatrix- the user Id on Matrixpresence- the presence value: online , unavailable, offlinestatusMessage- a personalized status message
-