Skip to content

Commit

Permalink
Release v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
getcompass-opensource committed Aug 5, 2024
1 parent 85c7196 commit 2c2f598
Show file tree
Hide file tree
Showing 183 changed files with 7,686 additions and 408 deletions.
15 changes: 15 additions & 0 deletions go_event/api/conf/event.domino.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@
}
}
]
},
{
"subscriber": "php_federation",
"subscription_list": [
{
"trigger_type": 5,
"event": "system.subscriptions_refreshing_requested",
"extra": {
"module": "php_federation",
"type": 4,
"group": "default",
"error_limit": 0
}
}
]
}
],
"event_discrete_courier_count": ${COURIER_COUNT},
Expand Down
18 changes: 17 additions & 1 deletion go_event/api/conf/event.pivot.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,23 @@
"db": "system",
"table": "go_event_subscriber_list"
},
"subscription_list": [],
"subscription_list": [
{
"subscriber": "php_federation",
"subscription_list": [
{
"trigger_type": 5,
"event": "system.subscriptions_refreshing_requested",
"extra": {
"module": "php_federation",
"type": 4,
"group": "default",
"error_limit": 0
}
}
]
}
],
"event_discrete_courier_count": ${COURIER_COUNT},
"event_discrete_courier_delay": ${DELIVERY_DELAY},
"task_discrete_courier_count": ${COURIER_COUNT},
Expand Down
4 changes: 4 additions & 0 deletions go_event/api/conf/socket.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@
"jitsi_socket_url": "${ENTRYPOINT_PIVOT}",
"jitsi_socket_module": {
"php_jitsi": "/api/socket/jitsi/"
},
"federation_socket_url": "${ENTRYPOINT_FEDERATION}",
"federation_socket_module": {
"php_federation": "/api/socket/federation/"
}
}
11 changes: 10 additions & 1 deletion go_event/api/conf/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type SocketConfigStruct struct {
IntegrationSocketModule map[string]string `json:"integration_socket_module"`
JitsiSocketUrl string `json:"jitsi_socket_url"`
JitsiSocketModule map[string]string `json:"jitsi_socket_module"`
FederationSocketUrl string `json:"federation_socket_url"`
FederationSocketModule map[string]string `json:"federation_socket_module"`
}

// переменная содержащая конфигурацию
Expand Down Expand Up @@ -160,10 +162,17 @@ func GetModuleSocketUrl(module string) (string, error) {
return socketConfig.IntegrationSocketUrl + integrationModuleSocketPath, nil
}

// получаем ссылку для модуля из premise
// получаем ссылку для модуля из jitsi
jitsiModuleSocketPath, isJitsiModuleExist := socketConfig.JitsiSocketModule[module]
if isJitsiModuleExist {
return socketConfig.JitsiSocketUrl + jitsiModuleSocketPath, nil
}

// получаем ссылку для модуля federation
federationModuleSocketPath, isFederationModuleExist := socketConfig.FederationSocketModule[module]
if isFederationModuleExist {
return socketConfig.FederationSocketUrl + federationModuleSocketPath, nil
}

return "", fmt.Errorf("unknown module %s", module)
}
21 changes: 11 additions & 10 deletions go_event/api/includes/type/event_broker/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,9 @@ var eventGeneratorStore = struct {
mx: sync.Mutex{},
}

type GeneratorEventData struct {
Name string `json:"name"` // имя генератора
Period int `json:"period"` // с каким периодом он выбрасывает события
SubscriptionItem Event.SubscriptionItem `json:"subscription_item"` // предмет подписки
EventData json.RawMessage `json:"event_data"` // какие данные генератор добавлять в событие
}

// MakeEventGenerator создает новый генератор событий
// генераторы существуют глобально, поэтому в изоляции компаний не записываются
func MakeEventGenerator(eventType string, period int, data json.RawMessage) {
func MakeEventGenerator(eventType string, period int, data json.RawMessage, onlyForGlobal bool) {

eventGeneratorStore.mx.Lock()
defer eventGeneratorStore.mx.Unlock()
Expand Down Expand Up @@ -60,8 +53,16 @@ func MakeEventGenerator(eventType string, period int, data json.RawMessage) {
go isolationRoutine(isolation, generator)
}

// пробегаемся по всем изоляциям и запускаем в них рутины генераторов
CompanyConfig.IterateOverActive(eventGeneratorStore.generatorList[eventType])
if onlyForGlobal {

// запускаем рутину генератора в глобальной изоляции
eventGeneratorStore.generatorList[eventType](Isolation.Global())
} else {

// пробегаемся по всем изоляциям и запускаем в них рутины генераторов
CompanyConfig.IterateOverActive(eventGeneratorStore.generatorList[eventType])
}

_ = Generator.StartGenerator(generator)
}

Expand Down
2 changes: 1 addition & 1 deletion go_event/api/includes/type/event_broker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func onEventGeneratorAdded(_ *Isolation.Isolation, appEvent *Event.ApplicationEv
// обрабатываем подписку на событие генератора
_ = ProcessSubscriptionRequest(&eventData)

MakeEventGenerator(generatorData.SubscriptionItem.Event, generatorData.Period, generatorData.EventData)
MakeEventGenerator(generatorData.SubscriptionItem.Event, generatorData.Period, generatorData.EventData, generatorData.OnlyForGlobal)
return nil
}

Expand Down
9 changes: 5 additions & 4 deletions go_event/api/includes/type/event_data/system_event_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ var SystemEventBrokerEventList = struct {

// SystemEventBrokerEventGeneratorAdded структура для события отправки рейтинга
type SystemEventBrokerEventGeneratorAdded struct {
EventName string `json:"name"` // имя генератора
Period int `json:"period"` // с каким периодом он выбрасывает события
SubscriptionItem Event.SubscriptionItem `json:"subscription_item"` // предмет подписки
EventData json.RawMessage `json:"event_data"` // какие данные генератор добавлять в событие
EventName string `json:"name"` // имя генератора
Period int `json:"period"` // с каким периодом он выбрасывает события
SubscriptionItem Event.SubscriptionItem `json:"subscription_item"` // предмет подписки
EventData json.RawMessage `json:"event_data"` // какие данные генератор добавлять в событие
OnlyForGlobal bool `json:"only_for_global,omitempty"` // флаг, генератор только для Isolation.Global()
}

// SystemEventBrokerEventGeneratorRemoved структура для события отправки рейтинга
Expand Down
2 changes: 2 additions & 0 deletions join_web/web/src/api/_stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const captchaPublicKeyState = atom("");
export const authenticationTokenState = atom("");

export const availableAuthMethodListState = atom<string[]>([]);
export const ssoProtocolState = atom("");
export const dictionaryDataState = atomWithImmer<ApiGlobalStartDictionaryData>({ auth_sso_start_button_text: "" });
export const userInfoDataState = atomWithImmer<ApiUserInfoData|null>(null);

Expand Down Expand Up @@ -59,6 +60,7 @@ export const passwordInputState = atom("");
export const confirmPasswordState = atom("");
export const needShowForgotPasswordButtonState = atom(true);
export const isNeedShowCreateProfileDialogAfterSsoRegistrationState = atom(false);
export const isNeedShowCreateProfileDialogAfterLdapRegistrationState = atom(false);

export const confirmCodeState = atom<string[]>(Array(6).fill(""));

Expand Down
3 changes: 3 additions & 0 deletions join_web/web/src/api/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export const LANG_CODES: Lang[] = ["ru", "en", "de", "fr", "es", "it"];
export const AUTH_MAIL_SCENARIO_SHORT = "short_confirm";
export const AUTH_MAIL_SCENARIO_FULL = "full_confirm";

export const SSO_PROTOCOL_OIDC = "oidc";
export const SSO_PROTOCOL_LDAP = "ldap";

export type AUTH_MAIL_SCENARIO_SHORT = "short_confirm";
export type AUTH_MAIL_SCENARIO_FULL = "full_confirm";

Expand Down
38 changes: 16 additions & 22 deletions join_web/web/src/api/auth.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,62 @@
import {useGetResponse} from "./_index.ts";
import {useMutation, useQueryClient} from "@tanstack/react-query";
import {useNavigatePage} from "../components/hooks.ts";
import { useGetResponse } from "./_index.ts";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { useNavigateDialog, useNavigatePage } from "../components/hooks.ts";
import useIsJoinLink from "../lib/useIsJoinLink.ts";
import {useSetAtom} from "jotai";
import {authenticationTokenState} from "./_stores.ts";
import { useSetAtom } from "jotai";
import { authenticationTokenState } from "./_stores.ts";

export function useApiAuthLogout() {

const getResponse = useGetResponse("pivot");
const queryClient = useQueryClient();
const isJoinLink = useIsJoinLink();
const {navigateToPage} = useNavigatePage();
const { navigateToPage } = useNavigatePage();
const { navigateToDialog } = useNavigateDialog();

return useMutation({

retry: false,
networkMode: "always",
mutationFn: async () => {

const body = new URLSearchParams();
return getResponse<object>("auth/logout", body);
},
async onSuccess() {

await queryClient.invalidateQueries({queryKey: ["global/start"]});
await queryClient.invalidateQueries({ queryKey: ["global/start"] });

// только в случае если это join ссылка - перекидываем на welcome, иначе в GlobalStartProvider самообработается корректно
if (isJoinLink) {

await queryClient.invalidateQueries({queryKey: ["joinlink/prepare", window.location.href]});
await queryClient.invalidateQueries({ queryKey: ["joinlink/prepare", window.location.href] });
navigateToPage("welcome");
navigateToDialog("auth_email_phone_number");
}
}
},
});
}

export type ApiAuthGenerateTokenAcceptArgs = {
join_link_uniq: undefined|string;
join_link_uniq: undefined | string;
};

export type ApiAuthGenerateToken = {
authentication_token: string,
expires_at: number
}
authentication_token: string;
expires_at: number;
};

export function useApiAuthGenerateToken() {

const getResponse = useGetResponse("pivot");
const setAuthenticationToken = useSetAtom(authenticationTokenState);

return useMutation({

retry: false,
networkMode: "always",
mutationFn: async ({ join_link_uniq }: ApiAuthGenerateTokenAcceptArgs) => {

const body = new URLSearchParams();

if (join_link_uniq !== undefined) {
body.append("join_link_uniq", join_link_uniq);
}

const response = await getResponse<ApiAuthGenerateToken>("auth/generateToken", body);
setAuthenticationToken(response.authentication_token)
setAuthenticationToken(response.authentication_token);

return response;
},
Expand Down
105 changes: 105 additions & 0 deletions join_web/web/src/api/auth/ldap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { useGetResponse } from "../_index.ts";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { ApiUserInfoData } from "../_types.ts";
import {
authState,
firstAuthState,
isNeedShowCreateProfileDialogAfterLdapRegistrationState,
isRegistrationState,
userInfoDataState,
} from "../_stores.ts";
import { useSetAtom } from "jotai";
import useIsJoinLink from "../../lib/useIsJoinLink.ts";
import { useNavigateDialog, useNavigatePage } from "../../components/hooks.ts";

export type ApiFederationLdapAuthTryAuthenticateArgs = {
username: string;
password: string;
};

export type ApiFederationLdapAuthTryAuthenticate = {
ldap_auth_token: string;
};

export function useApiFederationLdapAuthTryAuthenticate() {
const getResponse = useGetResponse("federation");

return useMutation({
retry: false,
networkMode: "always",
mutationFn: async ({ username, password }: ApiFederationLdapAuthTryAuthenticateArgs) => {
const body = new URLSearchParams({
username: username,
password: password,
});

return await getResponse<ApiFederationLdapAuthTryAuthenticate>("ldap/auth/tryAuthenticate", body);
},
});
}

export type ApiPivotAuthLdapBeginArgs = {
ldap_auth_token: string;
join_link?: string;
};

export type ApiPivotAuthLdapBegin = {
authentication_token: string;
need_fill_profile: 0 | 1;
user_info: ApiUserInfoData;
};

export function useApiPivotAuthLdapBegin() {
const getResponse = useGetResponse("pivot");
const setAuth = useSetAtom(authState);
const setFirstAuth = useSetAtom(firstAuthState);
const setUserInfoDataState = useSetAtom(userInfoDataState);
const setIsNeedShowCreateProfileDialogAfterLdapRegistration = useSetAtom(
isNeedShowCreateProfileDialogAfterLdapRegistrationState
);
const setRegistrationState = useSetAtom(isRegistrationState);
const queryClient = useQueryClient();
const isJoinLink = useIsJoinLink();
const { navigateToDialog } = useNavigateDialog();
const { navigateToPage } = useNavigatePage();

return useMutation({
retry: false,
networkMode: "always",
mutationFn: async ({ ldap_auth_token, join_link }: ApiPivotAuthLdapBeginArgs) => {
const body = new URLSearchParams({
ldap_auth_token: ldap_auth_token,
});

if (join_link !== undefined && /join\/[a-zA-Z0-9]+\/?/.test(join_link)) {
body.append("join_link", join_link);
}

return getResponse<ApiPivotAuthLdapBegin>("auth/ldap/begin", body, {});
},

async onSuccess(response) {
setFirstAuth(true);
if (response.need_fill_profile === 1) {
setRegistrationState(true);
setIsNeedShowCreateProfileDialogAfterLdapRegistration(true);
}

await queryClient.invalidateQueries({ queryKey: ["global/start"] });
if (isJoinLink) {
await queryClient.invalidateQueries({ queryKey: ["joinlink/prepare", window.location.href] });
}

setAuth(null);
setUserInfoDataState(response.user_info);

if (response.need_fill_profile === 1) {
navigateToPage("auth");
navigateToDialog("auth_create_profile");
} else {
navigateToPage("token");
navigateToDialog("token_page");
}
},
});
}
Loading

0 comments on commit 2c2f598

Please sign in to comment.