Sanitized public release v1.0.3

Source-Tag: v1.0.3
Manifest-SHA256: b7b09bf48f9e092ed8ad82f99c0319d6c3837d0a1549bd0cc4a374276c0f3896
This commit is contained in:
NIA Sanitized Release Publisher
2026-07-20 22:35:36 +00:00
commit 7141326ea0
41 changed files with 6397 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
(function() {
'use strict';
var weechat = angular.module('weechat');
var neoDropCrypto = require('./neodrop-crypto');
weechat.factory('imgur', ['$rootScope', 'settings', function($rootScope, settings) {
var BASE = '{{DROPS_ORIGIN}}';
var showErrorMsg = function(message) {
$rootScope.uploadError = true;
$rootScope.uploadErrorMessage = message || 'Encrypted upload failed.';
if (!$rootScope.$$phase) $rootScope.$apply();
setTimeout(function() {
$rootScope.uploadError = false;
if (!$rootScope.$$phase) $rootScope.$apply();
}, 5000);
};
var process = function(file, callback) {
if (!file || typeof file.size !== 'number') return;
if (file.size > neoDropCrypto.LARGE_MAX) {
showErrorMsg('NeoDrop files are limited to 1 GiB.');
return;
}
var profile = (settings.dropProfile === 'large' || file.size > neoDropCrypto.SMALL_MAX) ? 1 : 0;
var progressBars = document.getElementById('imgur-upload-progress');
var bar = document.createElement('div');
bar.className = 'imgur-progress-bar';
progressBars.appendChild(bar);
neoDropCrypto.upload(file, {
base: BASE,
profile: profile,
onProgress: function(value) { bar.style.width = Math.round(value * 100) + '%'; }
}).then(function(result) {
if (typeof $rootScope.registerNeoDrop === 'function') {
$rootScope.registerNeoDrop(result.readUrl, result.deleteCapability);
}
if (callback) callback(result.readUrl, result.deleteCapability);
}).catch(function(error) {
showErrorMsg(error.message);
}).finally(function() {
setTimeout(function() { if (bar.parentNode) bar.parentNode.removeChild(bar); }, 500);
});
};
var deleteImage = function(capability, callback) {
var split = String(capability || '').split('.');
if (split.length !== 2) return showErrorMsg('Invalid deletion capability.');
fetch(BASE + '/api/v1/objects/' + split[0], {
method: 'DELETE', headers: {'Authorization': 'Bearer ' + split[1]}
}).then(function(response) {
if (!response.ok) throw new Error('Unable to delete encrypted file.');
if (callback) callback(capability);
}).catch(function() { showErrorMsg('Unable to delete encrypted file.'); });
};
return {process: process, deleteImage: deleteImage};
}]);
})();