mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Clean up newline quote marks around the codebase (#6362)
This commit is contained in:
parent
9cc168e42e
commit
3916e1b97a
1
changelog.d/6362.misc
Normal file
1
changelog.d/6362.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Clean up some unnecessary quotation marks around the codebase.
|
@ -69,7 +69,7 @@ class FederationSenderSlaveStore(
|
|||||||
self.federation_out_pos_startup = self._get_federation_out_pos(db_conn)
|
self.federation_out_pos_startup = self._get_federation_out_pos(db_conn)
|
||||||
|
|
||||||
def _get_federation_out_pos(self, db_conn):
|
def _get_federation_out_pos(self, db_conn):
|
||||||
sql = "SELECT stream_id FROM federation_stream_position" " WHERE type = ?"
|
sql = "SELECT stream_id FROM federation_stream_position WHERE type = ?"
|
||||||
sql = self.database_engine.convert_param_style(sql)
|
sql = self.database_engine.convert_param_style(sql)
|
||||||
|
|
||||||
txn = db_conn.cursor()
|
txn = db_conn.cursor()
|
||||||
|
@ -185,7 +185,7 @@ class ApplicationServiceApi(SimpleHttpClient):
|
|||||||
|
|
||||||
if not _is_valid_3pe_metadata(info):
|
if not _is_valid_3pe_metadata(info):
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"query_3pe_protocol to %s did not return a" " valid result", uri
|
"query_3pe_protocol to %s did not return a valid result", uri
|
||||||
)
|
)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ def _load_appservice(hostname, as_info, config_filename):
|
|||||||
for regex_obj in as_info["namespaces"][ns]:
|
for regex_obj in as_info["namespaces"][ns]:
|
||||||
if not isinstance(regex_obj, dict):
|
if not isinstance(regex_obj, dict):
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Expected namespace entry in %s to be an object," " but got %s",
|
"Expected namespace entry in %s to be an object, but got %s",
|
||||||
ns,
|
ns,
|
||||||
regex_obj,
|
regex_obj,
|
||||||
)
|
)
|
||||||
|
@ -170,7 +170,7 @@ class _RoomDirectoryRule(object):
|
|||||||
self.action = action
|
self.action = action
|
||||||
else:
|
else:
|
||||||
raise ConfigError(
|
raise ConfigError(
|
||||||
"%s rules can only have action of 'allow'" " or 'deny'" % (option_name,)
|
"%s rules can only have action of 'allow' or 'deny'" % (option_name,)
|
||||||
)
|
)
|
||||||
|
|
||||||
self._alias_matches_all = alias == "*"
|
self._alias_matches_all = alias == "*"
|
||||||
|
@ -223,7 +223,7 @@ class ServerConfig(Config):
|
|||||||
self.federation_ip_range_blacklist.update(["0.0.0.0", "::"])
|
self.federation_ip_range_blacklist.update(["0.0.0.0", "::"])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ConfigError(
|
raise ConfigError(
|
||||||
"Invalid range(s) provided in " "federation_ip_range_blacklist: %s" % e
|
"Invalid range(s) provided in federation_ip_range_blacklist: %s" % e
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.public_baseurl is not None:
|
if self.public_baseurl is not None:
|
||||||
@ -787,14 +787,14 @@ class ServerConfig(Config):
|
|||||||
"--print-pidfile",
|
"--print-pidfile",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
default=None,
|
default=None,
|
||||||
help="Print the path to the pidfile just" " before daemonizing",
|
help="Print the path to the pidfile just before daemonizing",
|
||||||
)
|
)
|
||||||
server_group.add_argument(
|
server_group.add_argument(
|
||||||
"--manhole",
|
"--manhole",
|
||||||
metavar="PORT",
|
metavar="PORT",
|
||||||
dest="manhole",
|
dest="manhole",
|
||||||
type=int,
|
type=int,
|
||||||
help="Turn on the twisted telnet manhole" " service on the given port.",
|
help="Turn on the twisted telnet manhole service on the given port.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class TransactionActions(object):
|
|||||||
response code and response body.
|
response code and response body.
|
||||||
"""
|
"""
|
||||||
if not transaction.transaction_id:
|
if not transaction.transaction_id:
|
||||||
raise RuntimeError("Cannot persist a transaction with no " "transaction_id")
|
raise RuntimeError("Cannot persist a transaction with no transaction_id")
|
||||||
|
|
||||||
return self.store.get_received_txn_response(transaction.transaction_id, origin)
|
return self.store.get_received_txn_response(transaction.transaction_id, origin)
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class TransactionActions(object):
|
|||||||
Deferred
|
Deferred
|
||||||
"""
|
"""
|
||||||
if not transaction.transaction_id:
|
if not transaction.transaction_id:
|
||||||
raise RuntimeError("Cannot persist a transaction with no " "transaction_id")
|
raise RuntimeError("Cannot persist a transaction with no transaction_id")
|
||||||
|
|
||||||
return self.store.set_received_txn_response(
|
return self.store.set_received_txn_response(
|
||||||
transaction.transaction_id, origin, code, response
|
transaction.transaction_id, origin, code, response
|
||||||
|
@ -49,7 +49,7 @@ sent_pdus_destination_dist_count = Counter(
|
|||||||
|
|
||||||
sent_pdus_destination_dist_total = Counter(
|
sent_pdus_destination_dist_total = Counter(
|
||||||
"synapse_federation_client_sent_pdu_destinations:total",
|
"synapse_federation_client_sent_pdu_destinations:total",
|
||||||
"" "Total number of PDUs queued for sending across all destinations",
|
"Total number of PDUs queued for sending across all destinations",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ class TransactionManager(object):
|
|||||||
txn_id = str(self._next_txn_id)
|
txn_id = str(self._next_txn_id)
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"TX [%s] {%s} Attempting new transaction" " (pdus: %d, edus: %d)",
|
"TX [%s] {%s} Attempting new transaction (pdus: %d, edus: %d)",
|
||||||
destination,
|
destination,
|
||||||
txn_id,
|
txn_id,
|
||||||
len(pdus),
|
len(pdus),
|
||||||
@ -103,7 +103,7 @@ class TransactionManager(object):
|
|||||||
self._next_txn_id += 1
|
self._next_txn_id += 1
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
"TX [%s] {%s} Sending transaction [%s]," " (PDUs: %d, EDUs: %d)",
|
"TX [%s] {%s} Sending transaction [%s], (PDUs: %d, EDUs: %d)",
|
||||||
destination,
|
destination,
|
||||||
txn_id,
|
txn_id,
|
||||||
transaction.transaction_id,
|
transaction.transaction_id,
|
||||||
|
@ -119,7 +119,7 @@ class DirectoryHandler(BaseHandler):
|
|||||||
if not service.is_interested_in_alias(room_alias.to_string()):
|
if not service.is_interested_in_alias(room_alias.to_string()):
|
||||||
raise SynapseError(
|
raise SynapseError(
|
||||||
400,
|
400,
|
||||||
"This application service has not reserved" " this kind of alias.",
|
"This application service has not reserved this kind of alias.",
|
||||||
errcode=Codes.EXCLUSIVE,
|
errcode=Codes.EXCLUSIVE,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
@ -96,7 +96,7 @@ def parse_boolean_from_args(args, name, default=None, required=False):
|
|||||||
return {b"true": True, b"false": False}[args[name][0]]
|
return {b"true": True, b"false": False}[args[name][0]]
|
||||||
except Exception:
|
except Exception:
|
||||||
message = (
|
message = (
|
||||||
"Boolean query parameter %r must be one of" " ['true', 'false']"
|
"Boolean query parameter %r must be one of ['true', 'false']"
|
||||||
) % (name,)
|
) % (name,)
|
||||||
raise SynapseError(400, message)
|
raise SynapseError(400, message)
|
||||||
else:
|
else:
|
||||||
|
@ -246,7 +246,7 @@ class HttpPusher(object):
|
|||||||
# fixed, we don't suddenly deliver a load
|
# fixed, we don't suddenly deliver a load
|
||||||
# of old notifications.
|
# of old notifications.
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Giving up on a notification to user %s, " "pushkey %s",
|
"Giving up on a notification to user %s, pushkey %s",
|
||||||
self.user_id,
|
self.user_id,
|
||||||
self.pushkey,
|
self.pushkey,
|
||||||
)
|
)
|
||||||
@ -299,8 +299,7 @@ class HttpPusher(object):
|
|||||||
# for sanity, we only remove the pushkey if it
|
# for sanity, we only remove the pushkey if it
|
||||||
# was the one we actually sent...
|
# was the one we actually sent...
|
||||||
logger.warning(
|
logger.warning(
|
||||||
("Ignoring rejected pushkey %s because we" " didn't send it"),
|
("Ignoring rejected pushkey %s because we didn't send it"), pk,
|
||||||
pk,
|
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logger.info("Pushkey %s was rejected: removing", pk)
|
logger.info("Pushkey %s was rejected: removing", pk)
|
||||||
|
@ -43,7 +43,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
MESSAGE_FROM_PERSON_IN_ROOM = (
|
MESSAGE_FROM_PERSON_IN_ROOM = (
|
||||||
"You have a message on %(app)s from %(person)s " "in the %(room)s room..."
|
"You have a message on %(app)s from %(person)s in the %(room)s room..."
|
||||||
)
|
)
|
||||||
MESSAGE_FROM_PERSON = "You have a message on %(app)s from %(person)s..."
|
MESSAGE_FROM_PERSON = "You have a message on %(app)s from %(person)s..."
|
||||||
MESSAGES_FROM_PERSON = "You have messages on %(app)s from %(person)s..."
|
MESSAGES_FROM_PERSON = "You have messages on %(app)s from %(person)s..."
|
||||||
@ -55,7 +55,7 @@ MESSAGES_FROM_PERSON_AND_OTHERS = (
|
|||||||
"You have messages on %(app)s from %(person)s and others..."
|
"You have messages on %(app)s from %(person)s and others..."
|
||||||
)
|
)
|
||||||
INVITE_FROM_PERSON_TO_ROOM = (
|
INVITE_FROM_PERSON_TO_ROOM = (
|
||||||
"%(person)s has invited you to join the " "%(room)s room on %(app)s..."
|
"%(person)s has invited you to join the %(room)s room on %(app)s..."
|
||||||
)
|
)
|
||||||
INVITE_FROM_PERSON = "%(person)s has invited you to chat on %(app)s..."
|
INVITE_FROM_PERSON = "%(person)s has invited you to chat on %(app)s..."
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ class PreviewUrlResource(DirectServeResource):
|
|||||||
pattern = entry[attrib]
|
pattern = entry[attrib]
|
||||||
value = getattr(url_tuple, attrib)
|
value = getattr(url_tuple, attrib)
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Matching attrib '%s' with value '%s' against" " pattern '%s'",
|
"Matching attrib '%s' with value '%s' against pattern '%s'",
|
||||||
attrib,
|
attrib,
|
||||||
value,
|
value,
|
||||||
pattern,
|
pattern,
|
||||||
|
@ -54,7 +54,7 @@ class ConsentServerNotices(object):
|
|||||||
)
|
)
|
||||||
if "body" not in self._server_notice_content:
|
if "body" not in self._server_notice_content:
|
||||||
raise ConfigError(
|
raise ConfigError(
|
||||||
"user_consent server_notice_consent must contain a 'body' " "key."
|
"user_consent server_notice_consent must contain a 'body' key."
|
||||||
)
|
)
|
||||||
|
|
||||||
self._consent_uri_builder = ConsentURIBuilder(hs.config)
|
self._consent_uri_builder = ConsentURIBuilder(hs.config)
|
||||||
|
@ -851,7 +851,7 @@ class SQLBaseStore(object):
|
|||||||
allvalues.update(values)
|
allvalues.update(values)
|
||||||
latter = "UPDATE SET " + ", ".join(k + "=EXCLUDED." + k for k in values)
|
latter = "UPDATE SET " + ", ".join(k + "=EXCLUDED." + k for k in values)
|
||||||
|
|
||||||
sql = ("INSERT INTO %s (%s) VALUES (%s) " "ON CONFLICT (%s) DO %s") % (
|
sql = ("INSERT INTO %s (%s) VALUES (%s) ON CONFLICT (%s) DO %s") % (
|
||||||
table,
|
table,
|
||||||
", ".join(k for k in allvalues),
|
", ".join(k for k in allvalues),
|
||||||
", ".join("?" for _ in allvalues),
|
", ".join("?" for _ in allvalues),
|
||||||
|
@ -380,7 +380,7 @@ class DeviceInboxStore(DeviceInboxWorkerStore, DeviceInboxBackgroundUpdateStore)
|
|||||||
devices = list(messages_by_device.keys())
|
devices = list(messages_by_device.keys())
|
||||||
if len(devices) == 1 and devices[0] == "*":
|
if len(devices) == 1 and devices[0] == "*":
|
||||||
# Handle wildcard device_ids.
|
# Handle wildcard device_ids.
|
||||||
sql = "SELECT device_id FROM devices" " WHERE user_id = ?"
|
sql = "SELECT device_id FROM devices WHERE user_id = ?"
|
||||||
txn.execute(sql, (user_id,))
|
txn.execute(sql, (user_id,))
|
||||||
message_json = json.dumps(messages_by_device["*"])
|
message_json = json.dumps(messages_by_device["*"])
|
||||||
for row in txn:
|
for row in txn:
|
||||||
|
@ -138,9 +138,9 @@ class EndToEndKeyWorkerStore(SQLBaseStore):
|
|||||||
result.setdefault(user_id, {})[device_id] = None
|
result.setdefault(user_id, {})[device_id] = None
|
||||||
|
|
||||||
# get signatures on the device
|
# get signatures on the device
|
||||||
signature_sql = (
|
signature_sql = ("SELECT * FROM e2e_cross_signing_signatures WHERE %s") % (
|
||||||
"SELECT * " " FROM e2e_cross_signing_signatures " " WHERE %s"
|
" OR ".join("(" + q + ")" for q in signature_query_clauses)
|
||||||
) % (" OR ".join("(" + q + ")" for q in signature_query_clauses))
|
)
|
||||||
|
|
||||||
txn.execute(signature_sql, signature_query_params)
|
txn.execute(signature_sql, signature_query_params)
|
||||||
rows = self.cursor_to_dict(txn)
|
rows = self.cursor_to_dict(txn)
|
||||||
|
@ -713,9 +713,7 @@ class EventsStore(
|
|||||||
|
|
||||||
metadata_json = encode_json(event.internal_metadata.get_dict())
|
metadata_json = encode_json(event.internal_metadata.get_dict())
|
||||||
|
|
||||||
sql = (
|
sql = "UPDATE event_json SET internal_metadata = ? WHERE event_id = ?"
|
||||||
"UPDATE event_json SET internal_metadata = ?" " WHERE event_id = ?"
|
|
||||||
)
|
|
||||||
txn.execute(sql, (metadata_json, event.event_id))
|
txn.execute(sql, (metadata_json, event.event_id))
|
||||||
|
|
||||||
# Add an entry to the ex_outlier_stream table to replicate the
|
# Add an entry to the ex_outlier_stream table to replicate the
|
||||||
@ -732,7 +730,7 @@ class EventsStore(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
sql = "UPDATE events SET outlier = ?" " WHERE event_id = ?"
|
sql = "UPDATE events SET outlier = ? WHERE event_id = ?"
|
||||||
txn.execute(sql, (False, event.event_id))
|
txn.execute(sql, (False, event.event_id))
|
||||||
|
|
||||||
# Update the event_backward_extremities table now that this
|
# Update the event_backward_extremities table now that this
|
||||||
@ -1479,7 +1477,7 @@ class EventsStore(
|
|||||||
|
|
||||||
# We do joins against events_to_purge for e.g. calculating state
|
# We do joins against events_to_purge for e.g. calculating state
|
||||||
# groups to purge, etc., so lets make an index.
|
# groups to purge, etc., so lets make an index.
|
||||||
txn.execute("CREATE INDEX events_to_purge_id" " ON events_to_purge(event_id)")
|
txn.execute("CREATE INDEX events_to_purge_id ON events_to_purge(event_id)")
|
||||||
|
|
||||||
txn.execute("SELECT event_id, should_delete FROM events_to_purge")
|
txn.execute("SELECT event_id, should_delete FROM events_to_purge")
|
||||||
event_rows = txn.fetchall()
|
event_rows = txn.fetchall()
|
||||||
|
@ -55,7 +55,7 @@ class FilteringStore(SQLBaseStore):
|
|||||||
if filter_id_response is not None:
|
if filter_id_response is not None:
|
||||||
return filter_id_response[0]
|
return filter_id_response[0]
|
||||||
|
|
||||||
sql = "SELECT MAX(filter_id) FROM user_filters " "WHERE user_id = ?"
|
sql = "SELECT MAX(filter_id) FROM user_filters WHERE user_id = ?"
|
||||||
txn.execute(sql, (user_localpart,))
|
txn.execute(sql, (user_localpart,))
|
||||||
max_id = txn.fetchone()[0]
|
max_id = txn.fetchone()[0]
|
||||||
if max_id is None:
|
if max_id is None:
|
||||||
|
@ -337,7 +337,7 @@ class MediaRepositoryStore(MediaRepositoryBackgroundUpdateStore):
|
|||||||
if len(media_ids) == 0:
|
if len(media_ids) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
sql = "DELETE FROM local_media_repository_url_cache" " WHERE media_id = ?"
|
sql = "DELETE FROM local_media_repository_url_cache WHERE media_id = ?"
|
||||||
|
|
||||||
def _delete_url_cache_txn(txn):
|
def _delete_url_cache_txn(txn):
|
||||||
txn.executemany(sql, [(media_id,) for media_id in media_ids])
|
txn.executemany(sql, [(media_id,) for media_id in media_ids])
|
||||||
@ -365,11 +365,11 @@ class MediaRepositoryStore(MediaRepositoryBackgroundUpdateStore):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def _delete_url_cache_media_txn(txn):
|
def _delete_url_cache_media_txn(txn):
|
||||||
sql = "DELETE FROM local_media_repository" " WHERE media_id = ?"
|
sql = "DELETE FROM local_media_repository WHERE media_id = ?"
|
||||||
|
|
||||||
txn.executemany(sql, [(media_id,) for media_id in media_ids])
|
txn.executemany(sql, [(media_id,) for media_id in media_ids])
|
||||||
|
|
||||||
sql = "DELETE FROM local_media_repository_thumbnails" " WHERE media_id = ?"
|
sql = "DELETE FROM local_media_repository_thumbnails WHERE media_id = ?"
|
||||||
|
|
||||||
txn.executemany(sql, [(media_id,) for media_id in media_ids])
|
txn.executemany(sql, [(media_id,) for media_id in media_ids])
|
||||||
|
|
||||||
|
@ -377,9 +377,7 @@ class RegistrationWorkerStore(SQLBaseStore):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def f(txn):
|
def f(txn):
|
||||||
sql = (
|
sql = "SELECT name, password_hash FROM users WHERE lower(name) = lower(?)"
|
||||||
"SELECT name, password_hash FROM users" " WHERE lower(name) = lower(?)"
|
|
||||||
)
|
|
||||||
txn.execute(sql, (user_id,))
|
txn.execute(sql, (user_id,))
|
||||||
return dict(txn)
|
return dict(txn)
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
|
|||||||
|
|
||||||
def _get_max_topological_txn(self, txn, room_id):
|
def _get_max_topological_txn(self, txn, room_id):
|
||||||
txn.execute(
|
txn.execute(
|
||||||
"SELECT MAX(topological_ordering) FROM events" " WHERE room_id = ?",
|
"SELECT MAX(topological_ordering) FROM events WHERE room_id = ?",
|
||||||
(room_id,),
|
(room_id,),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -83,9 +83,7 @@ class TagsWorkerStore(AccountDataWorkerStore):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def get_tag_content(txn, tag_ids):
|
def get_tag_content(txn, tag_ids):
|
||||||
sql = (
|
sql = "SELECT tag, content FROM room_tags WHERE user_id=? AND room_id=?"
|
||||||
"SELECT tag, content" " FROM room_tags" " WHERE user_id=? AND room_id=?"
|
|
||||||
)
|
|
||||||
results = []
|
results = []
|
||||||
for stream_id, user_id, room_id in tag_ids:
|
for stream_id, user_id, room_id in tag_ids:
|
||||||
txn.execute(sql, (user_id, room_id))
|
txn.execute(sql, (user_id, room_id))
|
||||||
|
@ -447,7 +447,7 @@ def _apply_module_schema_files(cur, database_engine, modname, names_and_streams)
|
|||||||
# Mark as done.
|
# Mark as done.
|
||||||
cur.execute(
|
cur.execute(
|
||||||
database_engine.convert_param_style(
|
database_engine.convert_param_style(
|
||||||
"INSERT INTO applied_module_schemas (module_name, file)" " VALUES (?,?)"
|
"INSERT INTO applied_module_schemas (module_name, file) VALUES (?,?)"
|
||||||
),
|
),
|
||||||
(modname, name),
|
(modname, name),
|
||||||
)
|
)
|
||||||
|
@ -88,9 +88,12 @@ class PaginationConfig(object):
|
|||||||
raise SynapseError(400, "Invalid request.")
|
raise SynapseError(400, "Invalid request.")
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return (
|
return ("PaginationConfig(from_tok=%r, to_tok=%r, direction=%r, limit=%r)") % (
|
||||||
"PaginationConfig(from_tok=%r, to_tok=%r," " direction=%r, limit=%r)"
|
self.from_token,
|
||||||
) % (self.from_token, self.to_token, self.direction, self.limit)
|
self.to_token,
|
||||||
|
self.direction,
|
||||||
|
self.limit,
|
||||||
|
)
|
||||||
|
|
||||||
def get_source_config(self, source_name):
|
def get_source_config(self, source_name):
|
||||||
keyname = "%s_key" % source_name
|
keyname = "%s_key" % source_name
|
||||||
|
Loading…
Reference in New Issue
Block a user