allow extra.json

closes #60
This commit is contained in:
Jan-Piet Mens
2015-10-26 19:00:21 +01:00
parent 13c51f3d72
commit a2989e8c70
2 changed files with 7 additions and 1 deletions
+1 -1
View File
@@ -359,7 +359,7 @@ As mentioned earlier, data is stored in files, and these files are relative to `
* `cards/`, optional, contains user cards which are published when either you or one of your trackers on Hosted adds a new device. This card is then stored here and used with, e.g., `ocat --last` to show a user's name and optional avatar.
* `config/`, optional, contains the JSON of a [device configuration](http://owntracks.org/booklet/features/remoteconfig/) (`.otrc`) which was requested remotely via a [dump command](http://owntracks.org/booklet/tech/json/#_typecmd). Note that this will contain sensitive data. You can use this `.otrc` file to restore the OwnTracks configuration on your device by copying to the device and opening it in OwnTracks.
* `ghash/`, unless disabled, reverse Geo data is collected into an LMDB database located in this directory. This LMDB database also contains named databases which are used by your optional Lua hooks, as well as a `topic2tid` database which can be used for TID re-mapping.
* `last/` contains the last location published by devices. E.g. Jane's last publish from her iPhone would be in `last/jjolie/iphone/jjolie-iphone.json`. The JSON payload contained therein is enhanced with the fields `user`, `device`, `topic`, and `ghash`.
* `last/` contains the last location published by devices. E.g. Jane's last publish from her iPhone would be in `last/jjolie/iphone/jjolie-iphone.json`. The JSON payload contained therein is enhanced with the fields `user`, `device`, `topic`, and `ghash`. If a device's `last/` directory contains a file called `extra.json` (i.e. matching the example, this would be `last/jjolie/iphone/extra.json`), the content of this file is merged into the existing JSON for this user and returned by the API. Note, that you cannot overwrite existing values. So, an `extra.json` containing `{ "tst" : 11 }` will do nothing because the `tst` element we obtain from location data overrules, but adding `{ "beverage" : "water" }` will do what you want.
* `monitor` a file which contains a timestamp and the last received topic (see Monitoring below).
* `msg/` contains messages received by the Messaging system.
* `photos/` optional; contains the binary photos from a _card_.
+6
View File
@@ -82,6 +82,7 @@ void storage_gcache_load(char *lmdbname)
}
#endif /* !LMDB */
void get_geo(JsonNode *o, char *ghash)
{
#ifdef WITH_LMDB
@@ -176,6 +177,11 @@ void append_device_details(JsonNode *userlist, char *user, char *device)
get_geo(last, node->string_);
}
}
/* Extra data */
snprintf(path, BUFSIZ, "%s/last/%s/%s/extra.json",
STORAGEDIR, user, device);
json_copy_from_file(last, path);
}
/*