Browse Source

I2P specific changes

master
R4SAS 6 years ago
parent
commit
9432fd62b8
  1. 5
      README.md
  2. 15
      app/js/controllers.js
  3. 12
      app/js/lib/config.js
  4. 2
      app/js/lib/mtproto.js
  5. 6
      app/js/lib/mtproto_wrapper.js
  6. 2
      app/js/lib/ng_utils.js
  7. 2
      app/js/messages_manager.js
  8. 40
      app/js/services.js

5
README.md

@ -1,3 +1,8 @@
### Warning!
That fork of Webogram contain changes to work with I2P network.
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![Stories in Ready](https://badge.waffle.io/zhukov/webogram.png?label=ready&title=Ready)](https://waffle.io/zhukov/webogram) [![Stories in Ready](https://badge.waffle.io/zhukov/webogram.png?label=ready&title=Ready)](https://waffle.io/zhukov/webogram)

15
app/js/controllers.js

@ -18,12 +18,6 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$location.url('/im') $location.url('/im')
return return
} }
if (location.protocol == 'http:' &&
!Config.Modes.http &&
Config.App.domains.indexOf(location.hostname) != -1) {
location.href = location.href.replace(/^http:/, 'https:')
return
}
$location.url('/login') $location.url('/login')
}) })
@ -40,12 +34,6 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$location.url('/im') $location.url('/im')
return return
} }
if (location.protocol == 'http:' &&
!Config.Modes.http &&
Config.App.domains.indexOf(location.hostname) != -1) {
location.href = location.href.replace(/^http:/, 'https:')
return
}
TelegramMeWebService.setAuthorized(false) TelegramMeWebService.setAuthorized(false)
WebPushApiManager.forceUnsubscribe() WebPushApiManager.forceUnsubscribe()
}) })
@ -454,7 +442,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
LayoutSwitchService.start() LayoutSwitchService.start()
}) })
.controller('AppIMController', function ($q, qSync, $scope, $location, $routeParams, $modal, $rootScope, $modalStack, MtpApiManager, AppUsersManager, AppChatsManager, AppMessagesManager, AppPeersManager, ContactsSelectService, ChangelogNotifyService, ErrorService, AppRuntimeManager, HttpsMigrateService, LayoutSwitchService, LocationParamsService, AppStickersManager) { .controller('AppIMController', function ($q, qSync, $scope, $location, $routeParams, $modal, $rootScope, $modalStack, MtpApiManager, AppUsersManager, AppChatsManager, AppMessagesManager, AppPeersManager, ContactsSelectService, ChangelogNotifyService, ErrorService, AppRuntimeManager, LayoutSwitchService, LocationParamsService, AppStickersManager) {
$scope.$on('$routeUpdate', updateCurDialog) $scope.$on('$routeUpdate', updateCurDialog)
var pendingParams = false var pendingParams = false
@ -686,7 +674,6 @@ angular.module('myApp.controllers', ['myApp.i18n'])
} }
ChangelogNotifyService.checkUpdate() ChangelogNotifyService.checkUpdate()
HttpsMigrateService.start()
LayoutSwitchService.start() LayoutSwitchService.start()
LocationParamsService.start() LocationParamsService.start()
AppStickersManager.start() AppStickersManager.start()

12
app/js/lib/config.js

File diff suppressed because one or more lines are too long

2
app/js/lib/mtproto.js

@ -34,7 +34,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
if (Config.Modes.ssl || !Config.Modes.http) { if (Config.Modes.ssl || !Config.Modes.http) {
var subdomain = sslSubdomains[dcID - 1] + (upload ? '-1' : '') var subdomain = sslSubdomains[dcID - 1] + (upload ? '-1' : '')
var path = Config.Modes.test ? 'apiw_test1' : 'apiw1' var path = Config.Modes.test ? 'apiw_test1' : 'apiw1'
chosenServer = 'https://' + subdomain + '.web.telegram.org/' + path chosenServer = 'http://' + location.hostname + '/web/' + subdomain + '/' + path
return chosenServer return chosenServer
} }

6
app/js/lib/mtproto_wrapper.js

@ -172,14 +172,8 @@ angular.module('izhukov.mtproto.wrapper', ['izhukov.utils', 'izhukov.mtproto'])
if (!error.handled) { if (!error.handled) {
if (error.code == 401) { if (error.code == 401) {
mtpLogOut()['finally'](function () { mtpLogOut()['finally'](function () {
if (location.protocol == 'http:' &&
!Config.Modes.http &&
Config.App.domains.indexOf(location.hostname) != -1) {
location.href = location.href.replace(/^http:/, 'https:')
} else {
location.hash = '/login' location.hash = '/login'
AppRuntimeManager.reload() AppRuntimeManager.reload()
}
}) })
} else { } else {
ErrorService.show({error: error}) ErrorService.show({error: error})

2
app/js/lib/ng_utils.js

@ -2152,7 +2152,7 @@ angular.module('izhukov.utils', [])
if (navigator.serviceWorker.controller) { if (navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.postMessage(eventData) navigator.serviceWorker.controller.postMessage(eventData)
} }
isAliveTO = setTimeout(isAliveNotify, 10000) isAliveTO = setTimeout(isAliveNotify, 15000)
} }
function setSettings(newSettings) { function setSettings(newSettings) {

2
app/js/messages_manager.js

@ -2759,7 +2759,7 @@ angular.module('myApp.services')
incrementedMessageViews[curMessage.mid] = true incrementedMessageViews[curMessage.mid] = true
needIncrementMessageViews.push(curMessage.mid) needIncrementMessageViews.push(curMessage.mid)
if (incrementMessageViewsTimeout === false) { if (incrementMessageViewsTimeout === false) {
incrementMessageViewsTimeout = setTimeout(incrementMessageViews, 10000) incrementMessageViewsTimeout = setTimeout(incrementMessageViews, 15000)
} }
} }

40
app/js/services.js

@ -4564,46 +4564,6 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
} }
}) })
.service('HttpsMigrateService', function (ErrorService, Storage) {
var started = false
function check () {
Storage.get('https_dismiss').then(function (ts) {
if (!ts || tsNow() > ts + 43200000) {
ErrorService.confirm({
type: 'MIGRATE_TO_HTTPS'
}).then(function () {
var popup
try {
popup = window.open('https://web.telegram.org', '_blank')
} catch (e) {}
if (!popup) {
location.href = 'https://web.telegram.org'
}
}, function () {
Storage.set({https_dismiss: tsNow()})
})
}
})
}
function start () {
if (started ||
location.protocol != 'http:' ||
Config.Modes.http ||
Config.App.domains.indexOf(location.hostname) == -1) {
return
}
started = true
setTimeout(check, 120000)
}
return {
start: start,
check: check
}
})
.service('LayoutSwitchService', function (ErrorService, Storage, AppRuntimeManager, $window) { .service('LayoutSwitchService', function (ErrorService, Storage, AppRuntimeManager, $window) {
var started = false var started = false
var confirmShown = false var confirmShown = false

Loading…
Cancel
Save