Open seinshah opened 8 years ago
Same here!
There should be a dedicated command to mark messages as viewed.
Yes, I searched for that command but I got nothing
Do anybody know what command marks a message as viewed (not a dialog)??
There isn't any yet I guess.
for that on read history oh channel you must call function bellow getMessagesViews on tl schema 45 with increase flag true how can add this to cli history function ?
@amin1softco: So receiving the count automatically increases it?
yeah if you call this function counter of public msg automatically increased. if before not seen. so easy must queries.c must update...
void tgl_do_messages_mark_read (struct tgl_state *TLS, tgl_peer_id_t id, int max_id, int offset, void (*callback)(struct tgl_state *TLS, void *callback_extra, int), void *callback_extra) {
if (TLS->is_bot) { return; }
if (tgl_get_peer_type (id) == TGL_PEER_ENCR_CHAT) {
tgl_do_mark_read (TLS, id, callback, callback_extra);
return;
}
clear_packet ();
if (tgl_get_peer_type (id) != TGL_PEER_CHANNEL) {
out_int (CODE_messages_read_history);
out_peer_id (TLS, id);
out_int (max_id);
//out_int (offset);
struct mark_read_extra *E = talloc (sizeof (*E));
E->id = id;
E->max_id = max_id;
tglq_send_query (TLS, TLS->DC_working, packet_ptr - packet_buffer, packet_buffer, &mark_read_methods, E, callback, callback_extra);
} else {
out_int (CODE_channels_read_history);
out_int (CODE_input_channel);
out_int (tgl_get_peer_id (id));
out_long (id.access_hash);
out_int (max_id);
struct mark_read_extra *E = talloc (sizeof (*E));
E->id = id;
E->max_id = max_id;
tglq_send_query (TLS, TLS->DC_working, packet_ptr - packet_buffer, packet_buffer, &mark_read_channels_methods, E, callback, callback_extra);
//this after mark read msg must call to getMessagesViews to each post with incress flag true
out_int(CODE_messages_get_messages_views);
out_int (tgl_get_peer_id (id));
out_long (id.access_hash);
out=>>>msgid !!!
out_int (1);
}
}
out_int(CODE_messages_get_messages_views); out_int (tgl_get_peer_id (id)); out_long (id.access_hash); out=>>>msgid !!! out_int (1);
@amin1softco Wow this is really difficult to read. Could you edit your post wrapping your code in code blocks?
```c //your code here ```
The c
is to specify the language for syntaxhighlighting
this peace of tgl code of @vysheng no my code ...
someone knows the solution? gcc -I. -I. -I./tgl -I/usr/local/include -I/usr/local/Cellar/readline/6.3.8/include -I/usr/local/include -I/include -I/usr/local/Cellar/openssl/1.0.2g//include -DHAVE_CONFIG_H -Wall -Wextra -Wno-missing-field-initializers -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/queries.d -MQ objs/queries.o -o objs/queries.o tgl/queries.c tgl/queries.c:1424:7: error: use of undeclared identifier 'out' out=>>>msgid !!! ^ tgl/queries.c:1424:11: error: expected expression out=>>>msgid !!! ^ tgl/queries.c:1424:13: error: expected expression out=>>>msgid !!! ^ tgl/queries.c:1424:14: error: use of undeclared identifier 'msgid' out=>>>msgid !!! ^ 4 errors generated.
//updated tgl/queries.c
/* {{{ view msg */
static int view_msg_on_answer (struct tgl_state *TLS, struct query *q, void *D) {
struct tl_ds_vector *DS_V = D;
int n = DS_LVAL (DS_V->f1);
int *r = talloc (4 * n);
int i;
for (i = 0; i < n; i++) {
r[i] = *(int *)DS_V->f2[i];
}
if (q->callback) {
((void (*)(struct tgl_state *, void *, int, int, int *))q->callback) (TLS, q->callback_extra, 1, n, r);
}
tfree (r, 4 * n);
return 0;
}
static int view_msg_on_error (struct tgl_state *TLS, struct query *q, int error_code, int error_len, const char *error) {
tgl_set_query_error (TLS, EPROTO, "RPC_CALL_FAIL %d: %.*s", error_code, error_len, error);
if (q->callback) {
((void (*)(struct tgl_state *,void *, int))(q->callback))(TLS, q->callback_extra, 0);
}
tfree (q->extra, sizeof (tgl_message_id_t));
return 0;
}
static struct query_methods view_msg_methods = {
.on_answer = view_msg_on_answer,
.on_error = view_msg_on_error,
.type = TYPE_TO_PARAM_1(vector, TYPE_TO_PARAM (bare_int)),
.name = "view message"
};
void tgl_do_view_msg (struct tgl_state *TLS, tgl_message_id_t *_msg_id, void (*callback)(struct tgl_state *TLS, void *callback_extra, int success), void *callback_extra) {
tgl_message_id_t msg_id = *_msg_id;
if (msg_id.peer_type == TGL_PEER_TEMP_ID) {
msg_id = tgl_convert_temp_msg_id (TLS, msg_id);
}
if (msg_id.peer_type == TGL_PEER_TEMP_ID) {
tgl_set_query_error (TLS, EINVAL, "unknown message");
if (callback) {
callback (TLS, callback_extra, 0);
}
return;
}
clear_packet ();
out_int(CODE_messages_get_messages_views);
out_int (CODE_input_peer_channel);
out_int (msg_id.peer_id);
out_long (msg_id.access_hash);
out_int (CODE_vector);
out_int (1);
out_int (msg_id.id);
out_int (CODE_bool_true);
tgl_message_id_t *id = talloc (sizeof (*id));
*id = msg_id;
tglq_send_query (TLS, TLS->DC_working, packet_ptr - packet_buffer, packet_buffer, &view_msg_methods, 0, callback, callback_extra);
}
/* }}} */
Maybe need to update interface.c too? How do call this method correctly?
//updated interface.c
//add on line 1654
{"view_msg", {ca_msg_id, ca_none}, do_view_msg, "view_msg <msg-id>\view message", NULL},
//add some where in interface
void do_view_msg (struct command *command, int arg_num, struct arg args[], struct in_ev *ev) {
if (ev) { ev->refcnt ++; }
tgl_do_view_msg (TLS, &args[0].msg_id, print_success_gw, ev);
}
then you run tg with -N see id for call view_msg 1...
Compile well, but then I call view_msg
view_msg 05000000bca33c3f06000000000000009a9a4f13f424a353 {"result": "SUCCESS"}
return only result code, How print count of message views?
you have two option 1 update updates of tg or update history command to show view count and i not implement this thing write your code or ask @vysheng
@amin1softco Can't you make a Pull request quickly? Pretty please?
I tried each command below: history @channel_username mark_read @channel_username
But unfortunately non of them increase posts view count. I mean after running these command when I use
dialog_list
, unread messages are zero but seen count at the bottom of post in channel doesn't change.Any help will be appreciated