Browse Source

Client hot.readOnly setting set by server

pull/126/head
Lal'C Mellk Mal 3 years ago
parent
commit
c9208b53e5
5 changed files with 19 additions and 11 deletions
  1. +4
    -0
      client/models.js
  2. +1
    -1
      client/posting.js
  3. +8
    -8
      db.js
  4. +2
    -2
      server/caps.js
  5. +4
    -0
      server/server.js

+ 4
- 0
client/models.js View File

@@ -1,3 +1,7 @@
window.hot = new Backbone.Model({
readOnly: false,
});

var Post = Backbone.Model.extend({
idAttribute: 'num',
});


+ 1
- 1
client/posting.js View File

@@ -147,7 +147,7 @@ function make_reply_box() {
}

function insert_pbs() {
if (config.READ_ONLY || readOnly.indexOf(BOARD) >= 0)
if (hot.get('readOnly') || readOnly.indexOf(BOARD) >= 0)
return;
if (THREAD ? $('aside').length : $ceiling.next().is('aside'))
return;


+ 8
- 8
db.js View File

@@ -482,7 +482,7 @@ function long_term_timeslot(when) {
}

Y.reserve_post = function (op, ip, callback) {
if (config.READ_ONLY)
if (this.ident.readOnly)
return callback(Muggle("Can't post right now."));
var r = this.connect();
if (ipUtils.isLoopback(ip))
@@ -515,7 +515,7 @@ Y.reserve_post = function (op, ip, callback) {
var optPostFields = 'name trip email auth subject flavor'.split(' ');

Y.insert_post = function (msg, body, extra, callback) {
if (config.READ_ONLY)
if (this.ident.readOnly)
return callback(Muggle("Can't post right now."));
var r = this.connect();
if (!this.tag)
@@ -907,7 +907,7 @@ Y.archive_thread = function (op, callback) {
/* BOILERPLATE CITY */

Y.remove_images = function (nums, callback) {
if (config.READ_ONLY)
if (this.ident.readOnly)
return callback(Muggle("Read-only right now."));
var threads = {};
var rem = this.remove_image.bind(this, threads);
@@ -924,7 +924,7 @@ Y.remove_images = function (nums, callback) {
};

Y.remove_image = function (threads, num, callback) {
if (config.READ_ONLY)
if (this.ident.readOnly)
return callback(Muggle("Read-only right now."));
var r = this.connect();
var op = OPs[num];
@@ -958,7 +958,7 @@ Y.remove_image = function (threads, num, callback) {
};

Y.hide_image = function (key, callback) {
if (config.READ_ONLY)
if (this.ident.readOnly)
return callback(Muggle("Read-only right now."));
var r = this.connect();
var hash;
@@ -980,7 +980,7 @@ Y.hide_image = function (key, callback) {
};

Y.force_image_spoilers = function (nums, callback) {
if (config.READ_ONLY)
if (this.ident.readOnly)
return callback(Muggle("Read-only right now."));
var threads = {};
var rem = this.spoiler_image.bind(this, threads);
@@ -997,7 +997,7 @@ Y.force_image_spoilers = function (nums, callback) {
};

Y.spoiler_image = function (threads, num, callback) {
if (config.READ_ONLY)
if (this.ident.readOnly)
return callback(Muggle("Read-only right now."));
var r = this.connect();
var op = OPs[num];
@@ -1027,7 +1027,7 @@ Y.spoiler_image = function (threads, num, callback) {
};

Y.toggle_thread_lock = function (op, callback) {
if (config.READ_ONLY)
if (this.ident.readOnly)
return callback(Muggle("Read-only right now."));
if (OPs[op] != op)
return callback(Muggle('Thread does not exist.'));


+ 2
- 2
server/caps.js View File

@@ -181,8 +181,8 @@ function parse_suspensions(suspensions) {
return parsed;
}

exports.lookup_ident = function (ip) {
var ident = {ip: ip};
exports.lookup_ident = function (ip, country) {
var ident = {ip: ip, readOnly: config.READ_ONLY};
var num = parse_ip(ip).num;
var ban = range_lookup(RANGES.bans, num);
if (ban) {


+ 4
- 0
server/server.js View File

@@ -136,6 +136,10 @@ function synchronize(msg, client) {
});
}

if (client.ident.readOnly) {
logs.push('0,' + common.MODEL_SET + ',["hot"],{"readOnly":true}');
}

var sync = '0,' + common.SYNCHRONIZE;
if (dead_threads.length)
sync += ',' + JSON.stringify(dead_threads);


Loading…
Cancel
Save