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.
|
||||
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
|
||||
// in @media (max-size: 640px) in base.css
|
||||
export const MEDIA_BREAKPOINT = 640;
|
||||
|
||||
@@ -122,8 +122,8 @@ class MessagesView extends React.Component {
|
||||
// And show "loading" spinner.
|
||||
this.setState({ fetchingMessages: true });
|
||||
}
|
||||
const setQuery = Tinode.isNewGroupTopicName(this.props.topic) ?
|
||||
this.props.newGroupTopicParams : undefined;
|
||||
const setQuery = (this.props.newTopicParams && this.props.newTopicParams._topicName == this.props.topic) ?
|
||||
this.props.newTopicParams : undefined;
|
||||
topic.subscribe(getQuery.build(), setQuery)
|
||||
.then((ctrl) => {
|
||||
if (this.state.topic != ctrl.topic) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import InfoView from './info-view.jsx';
|
||||
import MessagesView from './messages-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 { detectServerAddress, isLocalHost, isSecureConnection } from '../lib/host-name.js';
|
||||
import LocalStorageUtil from '../lib/local-storage.js';
|
||||
@@ -141,7 +141,7 @@ class TinodeWeb extends React.Component {
|
||||
topicSelected: '',
|
||||
topicSelectedOnline: false,
|
||||
topicSelectedAcs: null,
|
||||
newGroupTopicParams: null,
|
||||
newTopicParams: null,
|
||||
loginDisabled: false,
|
||||
displayMobile: (window.innerWidth <= MEDIA_BREAKPOINT),
|
||||
showInfoPanel: false,
|
||||
@@ -657,6 +657,13 @@ class TinodeWeb extends React.Component {
|
||||
|
||||
// User clicked on a contact in the side panel or deleted a contact.
|
||||
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) {
|
||||
this.setState({
|
||||
errorText: '',
|
||||
@@ -939,14 +946,15 @@ class TinodeWeb extends React.Component {
|
||||
// Request to start a new topic. New P2P topic requires peer's name.
|
||||
handleNewTopicRequest(peerName, pub, priv, tags) {
|
||||
const topicName = peerName || this.tinode.newGroupTopicName();
|
||||
const params = {
|
||||
_topicName: topicName,
|
||||
sub: {mode: DEFAULT_ACCESS_MODE}
|
||||
};
|
||||
if (!peerName) {
|
||||
this.setState(
|
||||
{newGroupTopicParams: {desc: {public: pub, private: {comment: priv}}, tags: tags}},
|
||||
() => {this.handleTopicSelected(topicName)}
|
||||
);
|
||||
} else {
|
||||
this.handleTopicSelected(topicName);
|
||||
params.desc = {public: pub, private: {comment: priv}};
|
||||
params.tags = tags;
|
||||
}
|
||||
this.setState({newTopicParams: params}, () => {this.handleTopicSelected(topicName)});
|
||||
}
|
||||
|
||||
// New topic was creted, here is the new topic name.
|
||||
@@ -1271,7 +1279,7 @@ class TinodeWeb extends React.Component {
|
||||
errorAction={this.state.errorAction}
|
||||
errorActionText={this.state.errorActionText}
|
||||
|
||||
newGroupTopicParams={this.state.newGroupTopicParams}
|
||||
newTopicParams={this.state.newTopicParams}
|
||||
|
||||
onHideMessagesView={this.handleHideMessagesView}
|
||||
onData={this.tnData}
|
||||
|
||||
+11
-7
@@ -2597,8 +2597,12 @@ var messages = Object(react_intl__WEBPACK_IMPORTED_MODULE_1__["defineMessages"])
|
||||
});
|
||||
|
||||
function isUnconfirmed(acs) {
|
||||
var ex = acs ? acs.getExcessive() || '' : '';
|
||||
return ex.includes('R') || ex.includes('W');
|
||||
if (acs) {
|
||||
var ex = acs.getExcessive() || '';
|
||||
return acs.isJoiner('given') && (ex.includes('R') || ex.includes('W'));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var MessagesView = function (_React$Component) {
|
||||
@@ -4756,7 +4760,7 @@ var TinodeWeb = function (_React$Component) {
|
||||
|
||||
case 'block':
|
||||
console.log("Blocking...");
|
||||
var am = topic.getAccessMode().updateWant('-J').getWant();
|
||||
var am = topic.getAccessMode().updateWant('-JP').getWant();
|
||||
response = topic.setMeta({
|
||||
sub: {
|
||||
mode: am
|
||||
@@ -7279,13 +7283,13 @@ var ContextMenu = function (_React$Component) {
|
||||
'topic_unblock': {
|
||||
id: 'topic_unblock',
|
||||
title: formatMessage(messages.unblock),
|
||||
handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+J')
|
||||
handler: _this.topicPermissionSetter.bind(_assertThisInitialized(_assertThisInitialized(_this)), '+JP')
|
||||
},
|
||||
'topic_block': {
|
||||
id: 'topic_block',
|
||||
title: formatMessage(messages.block),
|
||||
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);
|
||||
|
||||
return ctrl;
|
||||
@@ -9522,8 +9526,8 @@ var ReceivedMarker = function (_React$PureComponent) {
|
||||
}, "access_time");
|
||||
} 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", {
|
||||
className: "material-icons small red"
|
||||
}, "error_outline");
|
||||
className: "material-icons small amber"
|
||||
}, "warning");
|
||||
} 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", {
|
||||
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