Changeset View
Changeset View
Standalone View
Standalone View
lib/actions/link-actions.js
// @flow | // @flow | ||||
import type { | import type { | ||||
FetchInviteLinksResponse, | FetchInviteLinksResponse, | ||||
InviteLinkVerificationRequest, | InviteLinkVerificationRequest, | ||||
InviteLinkVerificationResponse, | InviteLinkVerificationResponse, | ||||
CreateOrUpdatePublicLinkRequest, | |||||
InviteLink, | |||||
} from '../types/link-types.js'; | } from '../types/link-types.js'; | ||||
import type { CallServerEndpoint } from '../utils/call-server-endpoint.js'; | import type { CallServerEndpoint } from '../utils/call-server-endpoint.js'; | ||||
const verifyInviteLinkActionTypes = Object.freeze({ | const verifyInviteLinkActionTypes = Object.freeze({ | ||||
started: 'VERIFY_INVITE_LINK_STARTED', | started: 'VERIFY_INVITE_LINK_STARTED', | ||||
success: 'VERIFY_INVITE_LINK_SUCCESS', | success: 'VERIFY_INVITE_LINK_SUCCESS', | ||||
failed: 'VERIFY_INVITE_LINK_FAILED', | failed: 'VERIFY_INVITE_LINK_FAILED', | ||||
}); | }); | ||||
Show All 27 Lines | const fetchPrimaryInviteLinks = | ||||
): (() => Promise<FetchInviteLinksResponse>) => | ): (() => Promise<FetchInviteLinksResponse>) => | ||||
async () => { | async () => { | ||||
const response = await callServerEndpoint('fetch_primary_invite_links'); | const response = await callServerEndpoint('fetch_primary_invite_links'); | ||||
return { | return { | ||||
links: response.links, | links: response.links, | ||||
}; | }; | ||||
}; | }; | ||||
const createOrUpdatePublicLinkActionTypes = Object.freeze({ | |||||
started: 'CREATE_OR_UPDATE_PUBLIC_LINK_STARTED', | |||||
success: 'CREATE_OR_UPDATE_PUBLIC_LINK_SUCCESS', | |||||
failed: 'CREATE_OR_UPDATE_PUBLIC_LINK_FAILED', | |||||
}); | |||||
const createOrUpdatePublicLink = | |||||
( | |||||
callServerEndpoint: CallServerEndpoint, | |||||
): ((request: CreateOrUpdatePublicLinkRequest) => Promise<InviteLink>) => | |||||
async request => { | |||||
const response = await callServerEndpoint('create_or_update_public_link', { | |||||
name: request.name, | |||||
communityID: request.communityID, | |||||
}); | |||||
return { | |||||
name: response.name, | |||||
primary: response.primary, | |||||
role: response.role, | |||||
communityID: response.communityID, | |||||
expirationTime: response.expirationTime, | |||||
limitOfUses: response.limitOfUses, | |||||
numberOfUses: response.numberOfUses, | |||||
}; | |||||
}; | |||||
export { | export { | ||||
verifyInviteLinkActionTypes, | verifyInviteLinkActionTypes, | ||||
verifyInviteLink, | verifyInviteLink, | ||||
fetchPrimaryInviteLinkActionTypes, | fetchPrimaryInviteLinkActionTypes, | ||||
fetchPrimaryInviteLinks, | fetchPrimaryInviteLinks, | ||||
createOrUpdatePublicLinkActionTypes, | |||||
createOrUpdatePublicLink, | |||||
}; | }; |