Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Commit a5c9852

Browse files
committed
Sensitive content settings
1 parent 523e4bb commit a5c9852

File tree

10 files changed

+326
-612
lines changed

10 files changed

+326
-612
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
2-
[![Stories in Ready](https://badge.waffle.io/zhukov/webogram.png?label=ready&title=Ready)](https://waffle.io/zhukov/webogram)
32

43
## [Webogram](https://web.telegram.org) — Telegram Web App
54

app/js/controllers.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4276,6 +4276,24 @@ angular.module('myApp.controllers', ['myApp.i18n'])
42764276
}
42774277
})
42784278

4279+
$scope.contentSettings = {notReady: true}
4280+
var contentSettingsPromise = MtpApiManager.invokeApi('account.getContentSettings', {}).then(function (contentsResult) {
4281+
$scope.contentSettings = contentsResult
4282+
})
4283+
4284+
$scope.toggleContentSettings = function () {
4285+
if ($scope.contentSettings.pFlags &&
4286+
$scope.contentSettings.pFlags.sensitive_enabled) {
4287+
delete $scope.contentSettings.pFlags.sensitive_enabled
4288+
MtpApiManager.invokeApi('account.setContentSettings', {flags: 0})
4289+
} else {
4290+
return ErrorService.confirm({type: 'CONTENT_SETTINGS_SENSITIVE'}).then(function () {
4291+
$scope.contentSettings.pFlags.sensitive_enabled = true
4292+
MtpApiManager.invokeApi('account.setContentSettings', {flags: 1})
4293+
})
4294+
}
4295+
}
4296+
42794297
$scope.notify = {volume: 0.5}
42804298
$scope.send = {}
42814299

app/js/lib/config.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/js/locales/en-us.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"settings_modal_password_email_pending": "Click the link in {email} to complete Two-Step Verification setup.",
8787
"settings_modal_password_email_pending_cancel": "Abort",
8888
"settings_modal_password_email_pending_cancel_mobile": "Abort password",
89+
"settings_modal_show_sensitive_content": "Show Sensitive Content",
8990

9091
"password_delete_title": "Turn password off",
9192
"password_change_title": "Two-Step Verification",
@@ -277,7 +278,9 @@
277278
"confirm_modal_migrate_supergroup_md": "Please note that group members will need to update their Telegram apps to the latest version to see your supergroup.\n\nAre you sure you want to upgrade this group?",
278279
"confirm_modal_bot_access_phone": "The bot will know your phone number. This can be useful for integration with other services.",
279280
"confirm_modal_bot_access_geo": "This will send your current location to the bot.",
280-
"confirm_modal_bot_access_geo_inline": "This bot would like to know your location each time you send it a request. This can be used to provide location-specific results.",
281+
"confirm_modal_bot_access_geo_inline": "This bot would like to know your location each time you send it a request. This can be used to provide location-specific results.",
282+
"confirm_modal_content_settings_sensitive_md": "**Disable filtering**\nIf you disable filtering, Telegram will display sensitive media in public channels on all your connected devices.",
283+
"confirm_modal_content_settings_sensitive_submit": "Disable",
281284

282285
"confirm_modal_are_u_sure": "Are you sure?",
283286

app/partials/desktop/confirm_modal.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
<div ng-switch-when="BOT_ACCESS_PHONE" my-i18n="confirm_modal_bot_access_phone"></div>
8787
<div ng-switch-when="BOT_ACCESS_GEO" my-i18n="confirm_modal_bot_access_geo"></div>
8888
<div ng-switch-when="BOT_ACCESS_GEO_INLINE" my-i18n="confirm_modal_bot_access_geo_inline"></div>
89+
<div ng-switch-when="CONTENT_SETTINGS_SENSITIVE" my-i18n="confirm_modal_content_settings_sensitive_md"></div>
90+
8991

9092

9193

@@ -117,6 +119,7 @@
117119
<span ng-switch-when="SHARE_CONTACT_PEER" my-i18n="confirm_modal_share_contact_submit"></span>
118120
<span ng-switch-when="EXT_SHARE_PEER" my-i18n="confirm_modal_share_file_submit"></span>
119121
<span ng-switch-when="RESET_ACCOUNT" my-i18n="confirm_modal_reset_account_submit"></span>
122+
<span ng-switch-when="CONTENT_SETTINGS_SENSITIVE" my-i18n="confirm_modal_content_settings_sensitive_submit"></span>
120123
<span ng-switch-default my-i18n="modal_ok"></span>
121124
</button>
122125
</div>

app/partials/desktop/settings_modal.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@
131131
<a ng-if="password._ == 'account.password'" class="md_modal_section_link" ng-click="changePassword({action: 'change'})" my-i18n="settings_modal_change_password"></a>
132132
</div>
133133

134+
<a class="md_modal_section_toggle_wrap settings_modal_content_settings_wrap tg_checkbox" ng-click="toggleContentSettings()" ng-class="contentSettings.pFlags.sensitive_enabled ? 'tg_checkbox_on' : ''" ng-show="contentSettings.pFlags.sensitive_can_change">
135+
<span class="icon icon-checkbox-outer"><i class="icon-checkbox-inner"></i></span>
136+
<span class="tg_checkbox_label" my-i18n="settings_modal_show_sensitive_content"></span>
137+
</a>
138+
139+
140+
134141
<div class="md_modal_section_link_wrap">
135142
<a class="md_modal_section_link" ng-click="showSessions()" my-i18n="settings_modal_active_sessions"></a>
136143
</div>

app/partials/mobile/settings_modal.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ <h4 class="mobile_user_modal_header" my-peer-link="profile.id"></h4>
122122
</div>
123123

124124

125-
<div class="mobile_modal_action_wrap" ng-controller="AppLangSelectController">
125+
<div class="mobile_modal_action_wrap clearfix" ng-controller="AppLangSelectController">
126126
<div class="mobile_modal_select_wrap pull-right">
127127
<select class="form-control" ng-change="localeSelect()" ng-model="form.locale">
128128
<option ng-repeat="locale in ::supportedLocales" value="{{locale}}" ng-bind="langNames[locale]" ng-selected="locale == curLocale"></option>
@@ -131,6 +131,13 @@ <h4 class="mobile_user_modal_header" my-peer-link="profile.id"></h4>
131131
<span class="mobile_modal_action" my-i18n="settings_modal_language"></span>
132132
</div>
133133

134+
<div class="mobile_modal_action_wrap">
135+
<a class="mobile_modal_action tg_checkbox clearfix" ng-click="toggleContentSettings()" ng-class="contentSettings.pFlags.sensitive_enabled ? 'tg_checkbox_on' : ''">
136+
<span class="icon icon-checkbox-outer"><i class="icon-checkbox-inner"></i></span>
137+
<span class="tg_checkbox_label" my-i18n="settings_modal_show_sensitive_content"></span>
138+
</a>
139+
</div>
140+
134141
<div class="mobile_modal_section" ng-if="profile.phone">
135142
<h4 class="mobile_modal_section_header" my-i18n="user_modal_phone"></h4>
136143
<div class="mobile_modal_section_value" ng-bind="profile.phone | phoneNumber"></div>

gulpfile.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ function writeServiceWorkerFile (rootDir, handleFetch, callback) {
225225
var config = {
226226
cacheId: packageJson.name,
227227
handleFetch: handleFetch,
228-
logger: $.util.log,
229228
staticFileGlobs: fileGlobs,
230229
stripPrefix: './' + rootDir + '/',
231230
importScripts: ['js/lib/push_worker.js'],
@@ -242,7 +241,7 @@ gulp.task('generate-service-worker', gulp.series('build', function (callback) {
242241

243242
gulp.task('add-appcache-manifest', gulp.series('build', function () {
244243
return gulp.src(fileGlobs)
245-
.pipe($.manifest({
244+
.pipe($.manifest3({
246245
timestamp: false,
247246
hash: true,
248247
network: ['http://*', 'https://*', '*'],

0 commit comments

Comments
 (0)