Fixed send queries by id

This commit is contained in:
Vysheng 2014-10-01 14:34:55 +04:00
parent 33e973ee9d
commit 283b8672a2
2 changed files with 40 additions and 32 deletions

View File

@ -1773,7 +1773,7 @@ void bl_do_encr_chat_init (int id, int user_id, unsigned char random[], unsigned
void bl_do_set_pts (int pts) {
if (tgl_state.locks & TGL_LOCK_DIFF) { return; }
if (pts == tgl_state.pts) { return; }
if (pts <= tgl_state.pts) { return; }
int *ev = alloc_log_event (8);
ev[0] = CODE_binlog_set_pts;
ev[1] = pts;
@ -1782,7 +1782,7 @@ void bl_do_set_pts (int pts) {
void bl_do_set_qts (int qts) {
if (tgl_state.locks & TGL_LOCK_DIFF) { return; }
if (qts == tgl_state.qts) { return; }
if (qts <= tgl_state.qts) { return; }
int *ev = alloc_log_event (8);
ev[0] = CODE_binlog_set_qts;
ev[1] = qts;
@ -1791,7 +1791,7 @@ void bl_do_set_qts (int qts) {
void bl_do_set_date (int date) {
if (tgl_state.locks & TGL_LOCK_DIFF) { return; }
if (date == tgl_state.date) { return; }
if (date <= tgl_state.date) { return; }
int *ev = alloc_log_event (8);
ev[0] = CODE_binlog_set_date;
ev[1] = date;

View File

@ -300,17 +300,17 @@ tgl_peer_id_t cur_token_user (void) {
char c = cur_token[cur_token_len];
cur_token[cur_token_len] = 0;
if (l >= 6 && !memcmp (s, "user#", 5)) {
s += 5;
l -= 5;
if (l >= 8 && !memcmp (s, "user#id", 7)) {
s += 7;
l -= 7;
int r = atoi (s);
cur_token[cur_token_len] = c;
if (r >= 0) { return tgl_set_peer_id (TGL_PEER_USER, r); }
else { return TGL_PEER_NOT_FOUND; }
}
if (l >= 8 && !memcmp (s, "user#id", 7)) {
s += 7;
l -= 7;
if (l >= 6 && !memcmp (s, "user#", 5)) {
s += 5;
l -= 5;
int r = atoi (s);
cur_token[cur_token_len] = c;
if (r >= 0) { return tgl_set_peer_id (TGL_PEER_USER, r); }
@ -335,18 +335,17 @@ tgl_peer_id_t cur_token_chat (void) {
char c = cur_token[cur_token_len];
cur_token[cur_token_len] = 0;
if (l >= 6 && !memcmp (s, "chat#", 5)) {
s += 5;
l -= 5;
if (l >= 8 && !memcmp (s, "chat#id", 7)) {
s += 7;
l -= 7;
int r = atoi (s);
cur_token[cur_token_len] = c;
if (r >= 0) { return tgl_set_peer_id (TGL_PEER_CHAT, r); }
else { return TGL_PEER_NOT_FOUND; }
}
if (l >= 8 && !memcmp (s, "chat#id", 7)) {
s += 7;
l -= 7;
if (l >= 6 && !memcmp (s, "chat#", 5)) {
s += 5;
l -= 5;
int r = atoi (s);
cur_token[cur_token_len] = c;
if (r >= 0) { return tgl_set_peer_id (TGL_PEER_CHAT, r); }
@ -386,22 +385,6 @@ tgl_peer_id_t cur_token_peer (void) {
char c = cur_token[cur_token_len];
cur_token[cur_token_len] = 0;
if (l >= 6 && !memcmp (s, "user#", 5)) {
s += 5;
l -= 5;
int r = atoi (s);
cur_token[cur_token_len] = c;
if (r >= 0) { return tgl_set_peer_id (TGL_PEER_USER, r); }
else { return TGL_PEER_NOT_FOUND; }
}
if (l >= 6 && !memcmp (s, "chat#", 5)) {
s += 5;
l -= 5;
int r = atoi (s);
cur_token[cur_token_len] = c;
if (r >= 0) { return tgl_set_peer_id (TGL_PEER_CHAT, r); }
else { return TGL_PEER_NOT_FOUND; }
}
if (l >= 8 && !memcmp (s, "user#id", 7)) {
s += 7;
l -= 7;
@ -418,6 +401,22 @@ tgl_peer_id_t cur_token_peer (void) {
if (r >= 0) { return tgl_set_peer_id (TGL_PEER_CHAT, r); }
else { return TGL_PEER_NOT_FOUND; }
}
if (l >= 6 && !memcmp (s, "user#", 5)) {
s += 5;
l -= 5;
int r = atoi (s);
cur_token[cur_token_len] = c;
if (r >= 0) { return tgl_set_peer_id (TGL_PEER_USER, r); }
else { return TGL_PEER_NOT_FOUND; }
}
if (l >= 6 && !memcmp (s, "chat#", 5)) {
s += 5;
l -= 5;
int r = atoi (s);
cur_token[cur_token_len] = c;
if (r >= 0) { return tgl_set_peer_id (TGL_PEER_CHAT, r); }
else { return TGL_PEER_NOT_FOUND; }
}
tgl_peer_t *P = tgl_peer_get_by_name (s);
cur_token[cur_token_len] = c;
@ -432,6 +431,15 @@ tgl_peer_id_t cur_token_peer (void) {
static tgl_peer_t *mk_peer (tgl_peer_id_t id) {
if (tgl_get_peer_type (id) == NOT_FOUND) { return 0; }
tgl_peer_t *P = tgl_peer_get (id);
if (!P) {
if (tgl_get_peer_type (id) == TGL_PEER_USER) {
tgl_insert_empty_user (tgl_get_peer_id (id));
}
if (tgl_get_peer_type (id) == TGL_PEER_CHAT) {
tgl_insert_empty_chat (tgl_get_peer_id (id));
}
P = tgl_peer_get (id);
}
return P;
}