http publishes are marked with _http:true in JSON

This commit is contained in:
Jan-Piet Mens 2016-03-02 19:49:00 +01:00
parent be3af09040
commit 9ca53b264f
4 changed files with 14 additions and 5 deletions

View File

@ -168,6 +168,11 @@
title: config.column_titles.user,
visible: true,
data: null,
createdCell: function(td, cellData, rowData, row, col) {
if (rowData._http) {
$(td).css('color', 'gray');
}
},
render: function(data, type, row) {
var t = "{{username}}/{{device}}";
return Mustache.render(t, data);

2
http.c
View File

@ -589,7 +589,7 @@ static int dopublish(struct mg_connection *conn, const char *uri)
debug(ud, "HTTPPUB clen=%zu, topic=%s", conn->content_len, UB(topic));
handle_message(ud, UB(topic), payload, conn->content_len, 0);
handle_message(ud, UB(topic), payload, conn->content_len, 0, TRUE);
jarray = populate_friends(conn, u, d);

View File

@ -523,7 +523,7 @@ unsigned char *decrypt(struct udata *ud, char *topic, char *p64, char *username,
}
#endif /* ENCRYPT */
void handle_message(void *userdata, char *topic, char *payload, size_t payloadlen, int retain)
void handle_message(void *userdata, char *topic, char *payload, size_t payloadlen, int retain, int httpmode)
{
JsonNode *json, *j, *geo = NULL;
char *tid = NULL, *t = NULL, *p;
@ -729,7 +729,7 @@ void handle_message(void *userdata, char *topic, char *payload, size_t payloadle
cleartext = (char *)decrypt(ud, topic, j->string_, UB(username), UB(device));
if (cleartext != NULL) {
handle_message(ud, topic, cleartext, strlen(cleartext), retain);
handle_message(ud, topic, cleartext, strlen(cleartext), retain, httpmode);
free(cleartext);
}
if (_typestr) free(_typestr);
@ -875,6 +875,10 @@ void handle_message(void *userdata, char *topic, char *payload, size_t payloadle
utstring_printf(addr, "n.a.");
}
if (httpmode) {
json_append_member(json, "_http", json_mkbool(1));
}
/*
* We have normalized data in the JSON, so we can now write it
@ -1018,7 +1022,7 @@ void on_message(struct mosquitto *mosq, void *userdata, const struct mosquitto_m
{
struct udata *ud = (struct udata *)userdata;
handle_message(ud, m->topic, m->payload, m->payloadlen, m->retain);
handle_message(ud, m->topic, m->payload, m->payloadlen, m->retain, FALSE);
}

View File

@ -1,6 +1,6 @@
#ifndef _RECORDER_H_INCL_
# define _RECORDER_H_INCL_
void handle_message(void *userdata, char *topic, char *payload, size_t payloadlen, int retain);
void handle_message(void *userdata, char *topic, char *payload, size_t payloadlen, int retain, int httpmode);
#endif /* _RECORDER_H_INCL_ */