[plugin-architecture-implementation] - fix for disable downloadable
This commit is contained in:
parent
14c59a90a7
commit
3761fc333b
@ -168,11 +168,6 @@ trait MakePresentationDownloadReqMsgHdlr extends RightsManagementTrait {
|
||||
val originalFileExt = originalFilename.split("\\.").last
|
||||
val convertedFileExt = if (convertedFileName != "") convertedFileName.split("\\.").last else ""
|
||||
|
||||
val downloadableExtension: String = if (m.body.typeOfExport == "Converted") convertedFileExt
|
||||
else originalFileExt
|
||||
PresentationSender.broadcastSetPresentationDownloadableEvtMsg(bus, meetingId, "DEFAULT_PRESENTATION_POD",
|
||||
"not-used", presId, true, originalFilename, downloadableExtension)
|
||||
|
||||
val convertedFileURI = if (convertedFileName != "") List("presentation", "download", meetingId,
|
||||
s"${presId}?presFilename=${presId}.${convertedFileExt}&filename=${convertedFileName}").mkString("", File.separator, "")
|
||||
else ""
|
||||
|
@ -33,6 +33,8 @@ trait PresentationConversionCompletedSysPubMsgHdlr {
|
||||
msg.body.code,
|
||||
presVO,
|
||||
)
|
||||
|
||||
val originalDownloadableExtension = pres.name.split("\\.").last
|
||||
PresentationSender.broadcastSetPresentationDownloadableEvtMsg(
|
||||
bus,
|
||||
meetingId,
|
||||
@ -40,7 +42,8 @@ trait PresentationConversionCompletedSysPubMsgHdlr {
|
||||
msg.header.userId,
|
||||
pres.id,
|
||||
pres.downloadable,
|
||||
pres.name
|
||||
pres.name,
|
||||
originalDownloadableExtension
|
||||
)
|
||||
|
||||
val presWithConvertedName = PresentationInPod(pres.id, pres.name, pres.current, pres.pages,
|
||||
|
@ -5,25 +5,6 @@ import org.bigbluebutton.common2.msgs._
|
||||
import org.bigbluebutton.core.bus.MessageBus
|
||||
|
||||
object PresentationSender {
|
||||
def broadcastSetPresentationDownloadableEvtMsg(
|
||||
bus: MessageBus,
|
||||
meetingId: String,
|
||||
podId: String, userId: String,
|
||||
presentationId: String,
|
||||
downloadable: Boolean,
|
||||
presFilename: String,
|
||||
): Unit = {
|
||||
broadcastSetPresentationDownloadableEvtMsgLogic(
|
||||
bus,
|
||||
meetingId,
|
||||
podId,
|
||||
userId,
|
||||
presentationId,
|
||||
downloadable,
|
||||
presFilename,
|
||||
"pdf",
|
||||
)
|
||||
}
|
||||
def broadcastSetPresentationDownloadableEvtMsg(
|
||||
bus: MessageBus,
|
||||
meetingId: String,
|
||||
@ -33,28 +14,6 @@ object PresentationSender {
|
||||
downloadable: Boolean,
|
||||
presFilename: String,
|
||||
downloadableExtension: String
|
||||
): Unit = {
|
||||
broadcastSetPresentationDownloadableEvtMsgLogic(
|
||||
bus,
|
||||
meetingId,
|
||||
podId,
|
||||
userId,
|
||||
presentationId,
|
||||
downloadable,
|
||||
presFilename,
|
||||
downloadableExtension,
|
||||
)
|
||||
}
|
||||
|
||||
def broadcastSetPresentationDownloadableEvtMsgLogic(
|
||||
bus: MessageBus,
|
||||
meetingId: String,
|
||||
podId: String,
|
||||
userId: String,
|
||||
presentationId: String,
|
||||
downloadable: Boolean,
|
||||
presFilename: String,
|
||||
downloadableExtension: String,
|
||||
): Unit = {
|
||||
val routing = Routing.addMsgToClientRouting(
|
||||
MessageTypes.BROADCAST_TO_MEETING,
|
||||
|
@ -31,8 +31,11 @@ trait SetPresentationDownloadablePubMsgHdlr extends RightsManagementTrait {
|
||||
pod <- PresentationPodsApp.getPresentationPod(state, podId)
|
||||
pres <- pod.getPresentation(presentationId)
|
||||
} yield {
|
||||
val downloadableExtension = if (msg.body.typeOfExport == "Original")
|
||||
pres.name.split("\\.").last else pres.filenameConverted.split("\\.").last
|
||||
|
||||
PresentationSender.broadcastSetPresentationDownloadableEvtMsg(bus, meetingId, pod.id,
|
||||
msg.header.userId, presentationId, downloadable, pres.name)
|
||||
msg.header.userId, presentationId, downloadable, pres.name, downloadableExtension)
|
||||
|
||||
val pods = state.presentationPodManager.setPresentationDownloadableInPod(pod.id, presentationId, downloadable)
|
||||
state.update(pods)
|
||||
|
@ -33,7 +33,8 @@ case class RemovePresentationPubMsgBody(podId: String, presentationId: String)
|
||||
|
||||
object SetPresentationDownloadablePubMsg { val NAME = "SetPresentationDownloadablePubMsg" }
|
||||
case class SetPresentationDownloadablePubMsg(header: BbbClientMsgHeader, body: SetPresentationDownloadablePubMsgBody) extends StandardMsg
|
||||
case class SetPresentationDownloadablePubMsgBody(podId: String, presentationId: String, downloadable: Boolean)
|
||||
case class SetPresentationDownloadablePubMsgBody(podId: String, presentationId: String, downloadable: Boolean,
|
||||
typeOfExport: String)
|
||||
|
||||
object ResizeAndMovePagePubMsg { val NAME = "ResizeAndMovePagePubMsg" }
|
||||
case class ResizeAndMovePagePubMsg(header: BbbClientMsgHeader, body: ResizeAndMovePagePubMsgBody) extends StandardMsg
|
||||
|
@ -1,7 +1,6 @@
|
||||
package org.bigbluebutton.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
@ -10,8 +9,6 @@ import java.util.regex.Pattern;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.bigbluebutton.presentation.SupportedFileTypes;
|
||||
|
||||
public final class Util {
|
||||
|
||||
private static final Pattern MEETING_ID_PATTERN = Pattern.compile("^[a-z0-9-]+$");
|
||||
@ -116,21 +113,12 @@ public final class Util {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void deleteAllDownloadableMarksInPresentations(File presFileDir, String presId) {
|
||||
String regexString = "\\.(" + String.join("|",
|
||||
SupportedFileTypes.getSupportedFileTypes()) + ")\\.downloadable";
|
||||
File[] filesWithDownloadMark = presFileDir.listFiles(new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.matches(presId + regexString);
|
||||
}
|
||||
});
|
||||
|
||||
// Iterate through all of downloadable marks to delete them. Pattern is:
|
||||
// <presentationId>.<extension>.downloadable
|
||||
for (File downloadableMark: filesWithDownloadMark) {
|
||||
if (downloadableMark != null && downloadableMark.exists()) {
|
||||
downloadableMark.delete();
|
||||
public static void deleteAllDownloadableMarksInPresentations(File presFileDir) {
|
||||
// Delete files with .downloadable at the end of its filename
|
||||
File[] presFiles = presFileDir.listFiles();
|
||||
for (File presFile : presFiles) {
|
||||
if (presFile.isFile() && presFile.getName().endsWith(".downloadable")) {
|
||||
presFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,7 +131,7 @@ public final class Util {
|
||||
) throws IOException {
|
||||
File downloadMarker = Util.getPresFileDownloadMarker(presFileDir, presId, downloadableExtension);
|
||||
if (downloadable && downloadMarker != null && ! downloadMarker.exists()) {
|
||||
Util.deleteAllDownloadableMarksInPresentations(presFileDir, presId);
|
||||
Util.deleteAllDownloadableMarksInPresentations(presFileDir);
|
||||
downloadMarker.createNewFile();
|
||||
} else if (!downloadable && downloadMarker != null && downloadMarker.exists()) {
|
||||
downloadMarker.delete();
|
||||
|
@ -63,10 +63,6 @@ public final class SupportedFileTypes {
|
||||
}
|
||||
});
|
||||
|
||||
public static List<String> getSupportedFileTypes() {
|
||||
return SUPPORTED_FILE_LIST;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns if the file with extension is supported.
|
||||
*/
|
||||
|
@ -66,9 +66,8 @@ public class PresentationFileProcessor {
|
||||
private void processMakePresentationDownloadableMsg(UploadedPresentation pres) {
|
||||
try {
|
||||
File presentationFileDir = pres.getUploadedFile().getParentFile();
|
||||
if (!pres.getFilenameConverted().equals("")){
|
||||
String fileExtensionConverted;
|
||||
fileExtensionConverted = FilenameUtils.getExtension(pres.getFilenameConverted());
|
||||
if (!pres.getFilenameConverted().equals("")) {
|
||||
String fileExtensionConverted = FilenameUtils.getExtension(pres.getFilenameConverted());
|
||||
Util.makePresentationDownloadable(presentationFileDir, pres.getId(), pres.isDownloadable(),
|
||||
fileExtensionConverted);
|
||||
|
||||
|
@ -22,7 +22,7 @@ export default async function handlePresentationExport({ body }, meetingId) {
|
||||
check(typeOfExport, String);
|
||||
|
||||
if (typeOfExport === 'Original' || typeOfExport === 'Converted') {
|
||||
if (typeOfExport.indexOf('Converted') !== -1) {
|
||||
if (typeOfExport === 'Converted') {
|
||||
await setOriginalUriDownload(
|
||||
meetingId,
|
||||
presId,
|
||||
|
@ -3,7 +3,7 @@ import { check } from 'meteor/check';
|
||||
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
|
||||
export default function setPresentationDownloadable(presentationId, downloadable) {
|
||||
export default function setPresentationDownloadable(presentationId, downloadable, typeOfExport) {
|
||||
const REDIS_CONFIG = Meteor.settings.private.redis;
|
||||
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
||||
const EVENT_NAME = 'SetPresentationDownloadablePubMsg';
|
||||
@ -15,11 +15,13 @@ export default function setPresentationDownloadable(presentationId, downloadable
|
||||
check(requesterUserId, String);
|
||||
check(downloadable, Match.Maybe(Boolean));
|
||||
check(presentationId, String);
|
||||
check(typeOfExport, Match.Maybe(String));
|
||||
|
||||
const payload = {
|
||||
presentationId,
|
||||
podId: 'DEFAULT_PRESENTATION_POD',
|
||||
downloadable,
|
||||
typeOfExport,
|
||||
};
|
||||
|
||||
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
||||
|
@ -362,7 +362,7 @@ class PresentationUploader extends Component {
|
||||
this.deepMergeUpdateFileKey = this.deepMergeUpdateFileKey.bind(this);
|
||||
this.updateFileKey = this.updateFileKey.bind(this);
|
||||
this.getPresentationsToShow = this.getPresentationsToShow.bind(this);
|
||||
this.handleToggleDownloadable = this.handleToggleDownloadable.bind(this);
|
||||
this.handleDownloadableChange = this.handleDownloadableChange.bind(this);
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
@ -670,12 +670,10 @@ class PresentationUploader extends Component {
|
||||
return null;
|
||||
}
|
||||
|
||||
handleToggleDownloadable(item) {
|
||||
const { dispatchTogglePresentationDownloadable } = this.props;
|
||||
handleDownloadableChange(item, typeOfExport, downloadable) {
|
||||
const { dispatchChangePresentationDownloadable } = this.props;
|
||||
|
||||
const oldDownloadableState = item.isDownloadable;
|
||||
|
||||
dispatchTogglePresentationDownloadable(item, !oldDownloadableState);
|
||||
dispatchChangePresentationDownloadable(item, downloadable, typeOfExport);
|
||||
}
|
||||
|
||||
handleDismiss() {
|
||||
@ -711,6 +709,7 @@ class PresentationUploader extends Component {
|
||||
const observer = (exportation, stopped) => {
|
||||
this.deepMergeUpdateFileKey(item.id, 'exportation', exportation);
|
||||
|
||||
console.log("Vou descobrir se manda duas vezes por aqui ----> ", item, type, exportation.status)
|
||||
if (exportation.status === EXPORT_STATUSES.EXPORTED && stopped) {
|
||||
if (type === 'Original' || type === 'Converted') {
|
||||
if (!item.isDownloadable) {
|
||||
@ -759,6 +758,8 @@ class PresentationUploader extends Component {
|
||||
});
|
||||
}
|
||||
};
|
||||
console.log("Vou descobrir se manda duas vezes por aqui ---(2)-> ", item, type)
|
||||
|
||||
|
||||
exportPresentation(item.id, observer, type);
|
||||
}
|
||||
@ -1089,7 +1090,7 @@ class PresentationUploader extends Component {
|
||||
isDownloadable={isDownloadable}
|
||||
allowDownloadOriginal={allowDownloadOriginal}
|
||||
allowDownloadWithAnnotations={allowDownloadWithAnnotations}
|
||||
handleToggleDownloadable={this.handleToggleDownloadable}
|
||||
handleDownloadableChange={this.handleDownloadableChange}
|
||||
item={item}
|
||||
closeModal={() => Session.set('showUploadPresentationView', false)}
|
||||
handleDownloadingOfPresentation={(type) => this
|
||||
|
@ -36,7 +36,7 @@ export default withTracker(() => {
|
||||
const {
|
||||
dispatchDisableDownloadable,
|
||||
dispatchEnableDownloadable,
|
||||
dispatchTogglePresentationDownloadable,
|
||||
dispatchChangePresentationDownloadable,
|
||||
exportPresentation,
|
||||
} = Service;
|
||||
const isOpen = isPresentationEnabled() && (Session.get('showUploadPresentationView') || false);
|
||||
@ -56,7 +56,7 @@ export default withTracker(() => {
|
||||
renderPresentationItemStatus: PresUploaderToast.renderPresentationItemStatus,
|
||||
dispatchDisableDownloadable,
|
||||
dispatchEnableDownloadable,
|
||||
dispatchTogglePresentationDownloadable,
|
||||
dispatchChangePresentationDownloadable,
|
||||
exportPresentation,
|
||||
isOpen,
|
||||
selectedToBeNextCurrent: Session.get('selectedToBeNextCurrent') || null,
|
||||
|
@ -38,7 +38,7 @@ const propTypes = {
|
||||
formatMessage: PropTypes.func.isRequired,
|
||||
}).isRequired,
|
||||
handleDownloadingOfPresentation: PropTypes.func.isRequired,
|
||||
handleToggleDownloadable: PropTypes.func.isRequired,
|
||||
handleDownloadableChange: PropTypes.func.isRequired,
|
||||
isDownloadable: PropTypes.bool.isRequired,
|
||||
item: PropTypes.shape({
|
||||
id: PropTypes.string.isRequired,
|
||||
@ -74,7 +74,7 @@ class PresentationDownloadDropdown extends PureComponent {
|
||||
const {
|
||||
intl,
|
||||
handleDownloadingOfPresentation,
|
||||
handleToggleDownloadable,
|
||||
handleDownloadableChange,
|
||||
isDownloadable,
|
||||
allowDownloadOriginal,
|
||||
allowDownloadWithAnnotations,
|
||||
@ -87,14 +87,16 @@ class PresentationDownloadDropdown extends PureComponent {
|
||||
const { filenameConverted, filename, downloadableExtension } = item;
|
||||
const convertedFileExtension = filenameConverted?.split('.').slice(-1)[0];
|
||||
const originalFileExtension = filename?.split('.').slice(-1)[0];
|
||||
const toggleDownloadOriginalPresentation = (enableDownload, isConverted) => {
|
||||
handleToggleDownloadable(item);
|
||||
const changeDownloadOriginalOrConvertedPresentation = (enableDownload, isConverted) => {
|
||||
let typeOfExport;
|
||||
if (isConverted) {
|
||||
typeOfExport = 'Converted';
|
||||
} else {
|
||||
typeOfExport = 'Original';
|
||||
}
|
||||
handleDownloadableChange(item, typeOfExport, enableDownload);
|
||||
if (enableDownload) {
|
||||
if (isConverted) {
|
||||
handleDownloadingOfPresentation('Converted');
|
||||
} else {
|
||||
handleDownloadingOfPresentation('Original');
|
||||
}
|
||||
handleDownloadingOfPresentation(typeOfExport);
|
||||
}
|
||||
closeModal();
|
||||
};
|
||||
@ -107,7 +109,7 @@ class PresentationDownloadDropdown extends PureComponent {
|
||||
dataTest: 'disableOriginalPresentationDownload',
|
||||
label: intl.formatMessage(intlMessages.disableOriginalPresentationDownload,
|
||||
{ 0: originalFileExtension }),
|
||||
onClick: () => toggleDownloadOriginalPresentation(false, false),
|
||||
onClick: () => changeDownloadOriginalOrConvertedPresentation(false, false),
|
||||
});
|
||||
} else {
|
||||
this.menuItems.push({
|
||||
@ -115,7 +117,7 @@ class PresentationDownloadDropdown extends PureComponent {
|
||||
dataTest: 'enableOriginalPresentationDownload',
|
||||
label: intl.formatMessage(intlMessages.enableOriginalPresentationDownload,
|
||||
{ 0: originalFileExtension }),
|
||||
onClick: () => toggleDownloadOriginalPresentation(true, false),
|
||||
onClick: () => changeDownloadOriginalOrConvertedPresentation(true, false),
|
||||
});
|
||||
}
|
||||
if ((!!filenameConverted && filenameConverted !== '')
|
||||
@ -127,7 +129,7 @@ class PresentationDownloadDropdown extends PureComponent {
|
||||
dataTest: 'disableOriginalPresentationDownload',
|
||||
label: intl.formatMessage(intlMessages.disableOriginalPresentationDownload,
|
||||
{ 0: convertedFileExtension }),
|
||||
onClick: () => toggleDownloadOriginalPresentation(false, true),
|
||||
onClick: () => changeDownloadOriginalOrConvertedPresentation(false, true),
|
||||
});
|
||||
} else {
|
||||
this.menuItems.push({
|
||||
@ -135,7 +137,7 @@ class PresentationDownloadDropdown extends PureComponent {
|
||||
dataTest: 'enableOriginalPresentationDownload',
|
||||
label: intl.formatMessage(intlMessages.enableOriginalPresentationDownload,
|
||||
{ 0: convertedFileExtension }),
|
||||
onClick: () => toggleDownloadOriginalPresentation(true, true),
|
||||
onClick: () => changeDownloadOriginalOrConvertedPresentation(true, true),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -79,8 +79,8 @@ const getPresentations = () => Presentations
|
||||
};
|
||||
});
|
||||
|
||||
const dispatchTogglePresentationDownloadable = (presentation, newState) => {
|
||||
makeCall('setPresentationDownloadable', presentation.id, newState);
|
||||
const dispatchChangePresentationDownloadable = (presentation, newState, typeOfExport) => {
|
||||
makeCall('setPresentationDownloadable', presentation.id, newState, typeOfExport);
|
||||
};
|
||||
|
||||
const observePresentationConversion = (
|
||||
@ -487,7 +487,7 @@ export default {
|
||||
handleSavePresentation,
|
||||
getPresentations,
|
||||
persistPresentationChanges,
|
||||
dispatchTogglePresentationDownloadable,
|
||||
dispatchChangePresentationDownloadable,
|
||||
setPresentation,
|
||||
requestPresentationUploadToken,
|
||||
getExternalUploadData,
|
||||
|
Loading…
Reference in New Issue
Block a user