MCPcopy Create free account
hub / github.com/daodst/chat / RejoinCluster

Function RejoinCluster

clientapi/routing/cluster.go:21–70  ·  view source on GitHub ↗

RejoinCluster

(req *http.Request, device *api.Device, roomId string,
	cfg *config.ClientAPI,
	profileAPI api.ClientUserAPI, rsAPI roomserverAPI.ClientRoomserverAPI,
	asAPI appserviceAPI.AppServiceInternalAPI, federation *gomatrixserverlib.FederationClient)

Source from the content-addressed store, hash-verified

19
20// RejoinCluster
21func 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}
71func SendInviteAsRoomOwner(ctx context.Context,
72 profileAPI userapi.ClientUserAPI,
73 roomID, userID, reason string,

Callers

nothing calls this directly

Calls 4

SendLeaveAsRoomOwnerFunction · 0.85
SendInviteAsRoomOwnerFunction · 0.85
ContextMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected