force sane permissions for user-initiated subscriptions
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -22,6 +22,9 @@ export const READ_DELAY = 1000;
|
|||||||
// The shortest allowed tag length. Matches the value on the server.
|
// The shortest allowed tag length. Matches the value on the server.
|
||||||
export const MIN_TAG_LENGTH = 4;
|
export const MIN_TAG_LENGTH = 4;
|
||||||
|
|
||||||
|
// Access mode for subscriptions initiated by the current user.
|
||||||
|
export const DEFAULT_ACCESS_MODE = 'JRWPS';
|
||||||
|
|
||||||
// Mediaquery breakpoint between desktop and mobile, in px. Should match the value
|
// Mediaquery breakpoint between desktop and mobile, in px. Should match the value
|
||||||
// in @media (max-size: 640px) in base.css
|
// in @media (max-size: 640px) in base.css
|
||||||
export const MEDIA_BREAKPOINT = 640;
|
export const MEDIA_BREAKPOINT = 640;
|
||||||
|
|||||||
@@ -122,8 +122,8 @@ class MessagesView extends React.Component {
|
|||||||
// And show "loading" spinner.
|
// And show "loading" spinner.
|
||||||
this.setState({ fetchingMessages: true });
|
this.setState({ fetchingMessages: true });
|
||||||
}
|
}
|
||||||
const setQuery = Tinode.isNewGroupTopicName(this.props.topic) ?
|
const setQuery = (this.props.newTopicParams && this.props.newTopicParams._topicName == this.props.topic) ?
|
||||||
this.props.newGroupTopicParams : undefined;
|
this.props.newTopicParams : undefined;
|
||||||
topic.subscribe(getQuery.build(), setQuery)
|
topic.subscribe(getQuery.build(), setQuery)
|
||||||
.then((ctrl) => {
|
.then((ctrl) => {
|
||||||
if (this.state.topic != ctrl.topic) {
|
if (this.state.topic != ctrl.topic) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import InfoView from './info-view.jsx';
|
|||||||
import MessagesView from './messages-view.jsx';
|
import MessagesView from './messages-view.jsx';
|
||||||
import SidepanelView from './sidepanel-view.jsx';
|
import SidepanelView from './sidepanel-view.jsx';
|
||||||
|
|
||||||
import { API_KEY, APP_NAME, MEDIA_BREAKPOINT, READ_DELAY, RECEIVED_DELAY } from '../config.js';
|
import { API_KEY, APP_NAME, DEFAULT_ACCESS_MODE, MEDIA_BREAKPOINT, READ_DELAY, RECEIVED_DELAY } from '../config.js';
|
||||||
import { makeImageUrl } from '../lib/blob-helpers.js';
|
import { makeImageUrl } from '../lib/blob-helpers.js';
|
||||||
import { detectServerAddress, isLocalHost, isSecureConnection } from '../lib/host-name.js';
|
import { detectServerAddress, isLocalHost, isSecureConnection } from '../lib/host-name.js';
|
||||||
import LocalStorageUtil from '../lib/local-storage.js';
|
import LocalStorageUtil from '../lib/local-storage.js';
|
||||||
@@ -141,7 +141,7 @@ class TinodeWeb extends React.Component {
|
|||||||
topicSelected: '',
|
topicSelected: '',
|
||||||
topicSelectedOnline: false,
|
topicSelectedOnline: false,
|
||||||
topicSelectedAcs: null,
|
topicSelectedAcs: null,
|
||||||
newGroupTopicParams: null,
|
newTopicParams: null,
|
||||||
loginDisabled: false,
|
loginDisabled: false,
|
||||||
displayMobile: (window.innerWidth <= MEDIA_BREAKPOINT),
|
displayMobile: (window.innerWidth <= MEDIA_BREAKPOINT),
|
||||||
showInfoPanel: false,
|
showInfoPanel: false,
|
||||||
@@ -657,6 +657,13 @@ class TinodeWeb extends React.Component {
|
|||||||
|
|
||||||
// User clicked on a contact in the side panel or deleted a contact.
|
// User clicked on a contact in the side panel or deleted a contact.
|
||||||
handleTopicSelected(topicName, unused_index, online, acs) {
|
handleTopicSelected(topicName, unused_index, online, acs) {
|
||||||
|
// Clear newTopicParams after use.
|
||||||
|
if (this.state.newTopicParams && this.state.newTopicParams._topicName != topicName) {
|
||||||
|
this.setState({
|
||||||
|
newTopicParams: null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (topicName) {
|
if (topicName) {
|
||||||
this.setState({
|
this.setState({
|
||||||
errorText: '',
|
errorText: '',
|
||||||
@@ -939,14 +946,15 @@ class TinodeWeb extends React.Component {
|
|||||||
// Request to start a new topic. New P2P topic requires peer's name.
|
// Request to start a new topic. New P2P topic requires peer's name.
|
||||||
handleNewTopicRequest(peerName, pub, priv, tags) {
|
handleNewTopicRequest(peerName, pub, priv, tags) {
|
||||||
const topicName = peerName || this.tinode.newGroupTopicName();
|
const topicName = peerName || this.tinode.newGroupTopicName();
|
||||||
|
const params = {
|
||||||
|
_topicName: topicName,
|
||||||
|
sub: {mode: DEFAULT_ACCESS_MODE}
|
||||||
|
};
|
||||||
if (!peerName) {
|
if (!peerName) {
|
||||||
this.setState(
|
params.desc = {public: pub, private: {comment: priv}};
|
||||||
{newGroupTopicParams: {desc: {public: pub, private: {comment: priv}}, tags: tags}},
|
params.tags = tags;
|
||||||
() => {this.handleTopicSelected(topicName)}
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
this.handleTopicSelected(topicName);
|
|
||||||
}
|
}
|
||||||
|
this.setState({newTopicParams: params}, () => {this.handleTopicSelected(topicName)});
|
||||||
}
|
}
|
||||||
|
|
||||||
// New topic was creted, here is the new topic name.
|
// New topic was creted, here is the new topic name.
|
||||||
@@ -1271,7 +1279,7 @@ class TinodeWeb extends React.Component {
|
|||||||
errorAction={this.state.errorAction}
|
errorAction={this.state.errorAction}
|
||||||
errorActionText={this.state.errorActionText}
|
errorActionText={this.state.errorActionText}
|
||||||
|
|
||||||
newGroupTopicParams={this.state.newGroupTopicParams}
|
newTopicParams={this.state.newTopicParams}
|
||||||
|
|
||||||
onHideMessagesView={this.handleHideMessagesView}
|
onHideMessagesView={this.handleHideMessagesView}
|
||||||
onData={this.tnData}
|
onData={this.tnData}
|
||||||
|
|||||||
+11
-7
@@ -2597,8 +2597,12 @@ var messages = Object(react_intl__WEBPACK_IMPORTED_MODULE_1__["defineMessages"])
|
|||||||
});
|
});
|
||||||
|
|
||||||
function isUnconfirmed(acs) {
|
function isUnconfirmed(acs) {
|
||||||
var ex = acs ? acs.getExcessive() || '' : '';
|
if (acs) {
|
||||||
return ex.includes('R') || ex.includes('W');
|
var ex = acs.getExcessive() || '';
|
||||||
|
return acs.isJoiner('given') && (ex.includes('R') || ex.includes('W'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var MessagesView = function (_React$Component) {
|
var MessagesView = function (_React$Component) {
|
||||||
@@ -4756,7 +4760,7 @@ var TinodeWeb = function (_React$Component) {
|
|||||||
|
|
||||||
case 'block':
|
case 'block':
|
||||||
console.log("Blocking...");
|
console.log("Blocking...");
|
||||||
var am = topic.getAccessMode().updateWant('-J').getWant();
|
var am = topic.getAccessMode().updateWant('-JP').getWant();
|
||||||
response = topic.setMeta({
|
response = topic.setMeta({
|
||||||
sub: {
|
sub: {
|
||||||
mode: am
|
mode: am
|
||||||
@@ -7279,13 +7283,13 @@ var ContextMenu = function (_React$Component) {
|
|||||||
'topic_unblock': {
|
'topic_unblock': {
|
||||||
id: 'topic_unblock',
|
id: 'topic_unblock',
|
||||||
title: formatMessage(messages.unblock),
|
title: formatMessage(messages.unblock),
|
||||||
handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+J')
|
handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+JP')
|
||||||
},
|
},
|
||||||
'topic_block': {
|
'topic_block': {
|
||||||
id: 'topic_block',
|
id: 'topic_block',
|
||||||
title: formatMessage(messages.block),
|
title: formatMessage(messages.block),
|
||||||
handler: function handler(params, errorHandler) {
|
handler: function handler(params, errorHandler) {
|
||||||
return _this.topicPermissionSetter('-J', params, errorHandler).then(function (ctrl) {
|
return _this.topicPermissionSetter('-JP', params, errorHandler).then(function (ctrl) {
|
||||||
_this.props.onTopicRemoved(params.topicName);
|
_this.props.onTopicRemoved(params.topicName);
|
||||||
|
|
||||||
return ctrl;
|
return ctrl;
|
||||||
@@ -9522,8 +9526,8 @@ var ReceivedMarker = function (_React$PureComponent) {
|
|||||||
}, "access_time");
|
}, "access_time");
|
||||||
} else if (this.props.received == tinode_sdk__WEBPACK_IMPORTED_MODULE_2___default.a.MESSAGE_STATUS_FAILED) {
|
} else if (this.props.received == tinode_sdk__WEBPACK_IMPORTED_MODULE_2___default.a.MESSAGE_STATUS_FAILED) {
|
||||||
marker = react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("i", {
|
marker = react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("i", {
|
||||||
className: "material-icons small red"
|
className: "material-icons small amber"
|
||||||
}, "error_outline");
|
}, "warning");
|
||||||
} else if (this.props.received == tinode_sdk__WEBPACK_IMPORTED_MODULE_2___default.a.MESSAGE_STATUS_SENT) {
|
} else if (this.props.received == tinode_sdk__WEBPACK_IMPORTED_MODULE_2___default.a.MESSAGE_STATUS_SENT) {
|
||||||
marker = react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("i", {
|
marker = react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("i", {
|
||||||
className: "material-icons small"
|
className: "material-icons small"
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user