src/lib/Services/CreateService.js
/**
     * Creates invitations, sends them to interlocutors and stores them for future introspection.
     * @param {string} userDataUrl: chat storage URL.
     * @param {string} userWebId: chat creator WebId.
     * @param {string[]} interlocutorWebIds: all interlocutors WebIds.
     * @param {SemanticChat} semanticChat: SemanticChat/Group instance.
     */
Creates invitations, sends them to interlocutors and stores them for future introspection.
@param {string} userDataUrl: chat storage URL.
Creates invitations sends them to interlocutors and stores them for future introspection . @param { string } userDataUrl : chat storage URL .
async storeAndSendInvitations(userDataUrl, userWebId, interlocutorWebIds, semanticChat) {
        var id = userWebId;
        interlocutorWebIds.forEach(async (interlocutorWebId) => {
            if (interlocutorWebIds.length > 1) {
                id = "Group/" + semanticChat.interlocutorName + "----" + userWebId;
                interlocutorWebIds.forEach(async interlocWebId => {
                    if (interlocWebId !== interlocutorWebId) {
                        id += "----" + (interlocWebId.id ? interlocWebId.id : interlocWebId);
                    }
                });
            }
            var invitation = await this.generateInvitation(userDataUrl, semanticChat.getUrl(), id, (interlocutorWebId.id ? interlocutorWebId.id : interlocutorWebId));
            try {
                await this.uploader.executeSPARQLUpdateForUser(userDataUrl, `INSERT DATA{${invitation.forprivate}}`);
            } catch (e) {
                logger.error("Could not add chat to WebId.");
                logger.error(e);
            }
            try {
                await this.uploader.sendToInterlocutorInbox(await this.baseService.getInboxUrl(interlocutorWebId.id ? interlocutorWebId.id : interlocutorWebId), invitation.forinbox);
            } catch (e) {
                this.logger.error("Could not send invitation to interlocutor.");
                this.logger.error(e);
            }
        });
    }
async storeAndSendInvitations ( userDataUrl , userWebId , interlocutorWebIds , semanticChat ) { var id = userWebId ; interlocutorWebIds . forEach ( async ( interlocutorWebId ) => { if ( interlocutorWebIds . length > 1 ) { id = "Group/" + semanticChat . interlocutorName + "----" + userWebId ; interlocutorWebIds . forEach ( async interlocWebId => { if ( interlocWebId !== interlocutorWebId ) { id += "----" + ( interlocWebId . id ? interlocWebId . id : interlocWebId ) ; } } ) ; } var invitation = await this . generateInvitation ( userDataUrl , semanticChat . getUrl ( ) , id , ( interlocutorWebId . id ? interlocutorWebId . id : interlocutorWebId ) ) ; try { await this . uploader . executeSPARQLUpdateForUser ( userDataUrl , ` ${ invitation . forprivate } ` ) ; } catch ( e ) { logger . error ( "Could not add chat to WebId." ) ; logger . error ( e ) ; } try { await this . uploader . sendToInterlocutorInbox ( await this . baseService . getInboxUrl ( interlocutorWebId . id ? interlocutorWebId . id : interlocutorWebId ) , invitation . forinbox ) ; } catch ( e ) { this . logger . error ( "Could not send invitation to interlocutor." ) ; this . logger . error ( e ) ; } } ) ; }
Creates invitations, sends them to interlocutors and stores them for future introspection.
Creates invitations sends them to interlocutors and stores them for future introspection .