RejoinCluster
(req *http.Request, device *api.Device, roomId string, cfg *config.ClientAPI, profileAPI api.ClientUserAPI, rsAPI roomserverAPI.ClientRoomserverAPI, asAPI appserviceAPI.AppServiceInternalAPI, federation *gomatrixserverlib.FederationClient)
| 19 | |
| 20 | // RejoinCluster |
| 21 | func RejoinCluster(req *http.Request, device *api.Device, roomId string, |
| 22 | cfg *config.ClientAPI, |
| 23 | profileAPI api.ClientUserAPI, rsAPI roomserverAPI.ClientRoomserverAPI, |
| 24 | asAPI appserviceAPI.AppServiceInternalAPI, federation *gomatrixserverlib.FederationClient) util.JSONResponse { |
| 25 | local, _, err := gomatrixserverlib.SplitID('@', device.UserID) |
| 26 | if err != nil { |
| 27 | return util.ErrorResponse(err) |
| 28 | } |
| 29 | |
| 30 | isinEquipmentGroup, err := new_feature.JudgeIsinEquipmentGroup(roomId, local) |
| 31 | if err != nil { |
| 32 | return util.ErrorResponse(err) |
| 33 | } |
| 34 | if isinEquipmentGroup { |
| 35 | |
| 36 | conflictUsers, err := new_db.GetConflictUsers(device.UserID, roomId) |
| 37 | if err != nil { |
| 38 | util.GetLogger(req.Context()).Error(err) |
| 39 | } |
| 40 | if len(conflictUsers) > 0 { |
| 41 | for i, _ := range conflictUsers { |
| 42 | SendLeaveAsRoomOwner(req.Context(), profileAPI, roomId, conflictUsers[i], "cluster_addr_conflict", cfg, rsAPI, asAPI, time.Now()) |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | _, domain, err := gomatrixserverlib.SplitID('!', roomId) |
| 47 | if err != nil { |
| 48 | return util.ErrorResponse(err) |
| 49 | } |
| 50 | if domain == cfg.Matrix.ServerName { |
| 51 | |
| 52 | return SendInviteAsRoomOwner(req.Context(), profileAPI, roomId, device.UserID, "from_cluster", cfg, rsAPI, asAPI, time.Now()) |
| 53 | } else { |
| 54 | // ,federationapiinvite |
| 55 | |
| 56 | res, err := federation.SendInviteAsOwner(req.Context(), domain, make(map[string]interface{})) |
| 57 | if err != nil { |
| 58 | return util.ErrorResponse(err) |
| 59 | } |
| 60 | return util.JSONResponse{ |
| 61 | Code: http.StatusOK, |
| 62 | JSON: res, |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | return util.JSONResponse{ |
| 67 | Code: http.StatusForbidden, |
| 68 | JSON: jsonerror.Unknown("not in the cluster"), |
| 69 | } |
| 70 | } |
| 71 | func SendInviteAsRoomOwner(ctx context.Context, |
| 72 | profileAPI userapi.ClientUserAPI, |
| 73 | roomID, userID, reason string, |
nothing calls this directly
no test coverage detected