about summary refs log tree commit diff stats
path: root/src/database.c
Commit message (Collapse)AuthorAgeFilesLines
* add `files_file_in_account_data_path()`Steffen Jaeckel2022-03-131-21/+1
| | | | | | | | | | | | As all parts of the code invoking the `files_get_account_data_path()` function did the same afterwards, a function has been added with the same behavior. 1. create path 2. `mkdir` of that path 3. return final path Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
* auto-formatSteffen Jaeckel2022-02-011-1/+1
| | | | Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
* database.c: fix inserting messages to chat logs if archive_id is emptyJuraj Mlich2021-12-311-1/+1
| | | | | | | | | | | The original intention of the code was that in case archive_id is not set, NULL should be inserted. What is inserted however is an empty string. This causes the condition to not insert messages with non-unique archive_id insert only one message in total and ignore all further ones (if NULL was there, the condition would work properly). And this in turn causes chat history not work properly. This commit makes the SQL condition work properly and therefore fixes chat history. Fixes #1589.
* Format code correctlyMichael Vetter2021-10-051-12/+12
|
* Escape all parameters in SQL statementsCIacademic2021-06-111-8/+5
| | | | | Some more parameters might contain quotes, so escape all of them with %q by using sqlite3_mprintf.
* Get rid of asprintf and _GNU_SOURCE defineMichael Vetter2021-03-301-21/+20
| | | | | | | _GNU_SOURCE was even in some files where it was not needed at all (http*). Let's replace asprintf() with g_strdup_printf().
* Add config.h in files were it was missingMichael Vetter2021-03-261-0/+2
| | | | Related to https://github.com/profanity-im/profanity/issues/1512
* database: make log_database_get_previous_chat saferMichael Vetter2021-03-251-0/+2
|
* database: simplify _log_database_add_outgoingMichael Vetter2021-03-251-2/+1
|
* database: simplify log_database_add_incomingMichael Vetter2021-03-251-2/+1
|
* Calm OpenBSD syslogkaffeekanne2021-02-151-5/+5
| | | | | | | | | | | | | On every write to `chatlog.db` syslog throws ``` profanity: vfprintf %s NULL in "INSERT INTO `ChatLogs` (`from_jid`, `from_resource`, `to_jid`, `to_resource`, `message`, `timestamp`, `stanza_id`, `archive_id`, `replace_id`, `type`, `encryption`) SELECT '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' WHERE NOT EXISTS (SELECT 1 FROM `ChatLogs` WHERE `archive_id` = '%s')" ``` in `/var/log/messages`. Checking for `NULL` except in the fields the DB is expected to throw errors for, satisfies OpenBSDs security measures
* Since the string from strerror should never be modified, use const.Philipp Klaus Krause2020-10-141-1/+1
|
* Use g_date_time_format_iso8601()Michael Vetter2020-09-301-8/+2
| | | | | | | | | This partly reverts d3a387a0ec6e5265f625de87318be2de610efb01. For proanity 0.9.x we still wanted to support older glib versions so that we can be packaged for various linux distros. Now with 0.10 we want to move on.
* database: Only insert if there is no entry with same archive_idMichael Vetter2020-07-231-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | archive_is is <stanza-id> or <result id=""> and should identify one message stable and uniquely. See XEP-0359: Unique and Stable Stanza IDs. We need this for example for this situation: * we go online with Profanity * we fetch all messages since yesterday * we add them to the db * we go offline * we go online with Profanity * we fetch all messages since yesterday * we only want to add the new ones So far we don't ask MAM "give me all since last 'id'" but since a certain date. In case no archive_id will be set, it will be `(null)` and thus should be inserted anyways because it won't find a value with (null) in that row. Because when adding we use `message->stanzaid ? message->stanzaid : "",` so it will be empty in such a case. Regards MAM: https://github.com/profanity-im/profanity/issues/660 Regards Stable IDs: https://github.com/profanity-im/profanity/issues/1207
* Apply coding styleMichael Vetter2020-07-071-65/+72
|
* Revert "Apply coding style"Michael Vetter2020-07-071-76/+69
| | | | | | This reverts commit 9b55f2dec0ea27a9ce4856e303425e12f866cea2. Sorting the includes creates some problems.
* Apply coding styleMichael Vetter2020-07-071-69/+76
| | | | Regards https://github.com/profanity-im/profanity/issues/1396
* Use files_get_account_data_path instead of duplicate codeMichael Vetter2020-07-011-16/+10
| | | | | We often had a use case where we want the account specific data dir. Let's create a function for this instead of doing it by hand each time.
* Feature request - XEP-0373: OpenPGP for XMPP (OX)DebXWoody2020-06-291-1/+3
| | | | | | | | | Basic implementation of XEP-0373: OpenPGP for XMPP. https://xmpp.org/extensions/xep-0373.html Command /ox Issue: #1331
* Fix carbon loggingMichael Vetter2020-05-271-4/+8
| | | | Regards https://github.com/profanity-im/profanity/issues/1342
* Escape message before adding to SQL backendMichael Vetter2020-04-181-1/+5
|
* Add to_jid field to ProfMessage structMichael Vetter2020-04-111-4/+5
| | | | | Is usefult in many cases if we want cleaner code. Hope this edit didn't break anything though ;-)
* Fix error in getting previous chatlogMichael Vetter2020-04-101-1/+5
| | | | | | | | | Our search was too broad, and thus incorrect. One of the various mistakes it can cause was https://github.com/profanity-im/profanity/issues/1308 Fix https://github.com/profanity-im/profanity/issues/1308
* Retrieve message type from databaseMichael Vetter2020-04-081-1/+16
| | | | So we don't have to check for MUC another way.
* Downgrade dependenciesMichael Vetter2020-04-071-2/+8
| | | | | | | | | | | Use g_date_time_format() instead of g_date_time_format_iso8601() to only rely on glib 2.56.0 which is the latest version in Debian Buster (current stable). We also only use basic sqlite functions so 3.27.0 should be fine there (also the one in Debian buster). Thanks to @DebXWoody.
* Add missing includesMichael Vetter2020-04-061-0/+3
|
* db: actually display the last 10 entries in correct orderMichael Vetter2020-04-061-1/+1
|
* db: get last messages sorted by timestampMichael Vetter2020-04-061-1/+1
|
* db: Use type from message struct instead of having individual functionsMichael Vetter2020-04-061-75/+79
|
* db: Fix memleaksMichael Vetter2020-04-061-0/+1
|
* Add sql to error logMichael Vetter2020-04-061-2/+2
| | | | so we can more easily grep for it.
* Remove chat_log_get_previous()Michael Vetter2020-04-061-2/+2
| | | | | | | | | | | | We now dont get the log files from the text files via chat_log_get_previous() anymore. We use the sql backend via log_database_get_previous_chat(). So far it just has the same behaviour like chat_log_get_previous(), except that in _chatwin_history() we don't pass the sender to win_print_history() which should be fixed in a commit soon. And log_database_get_previous_chat() can later easily be expanded to fix https://github.com/profanity-im/profanity/issues/205.
* Get regular chat history out of sql backendMichael Vetter2020-04-061-2/+44
|
* db: log encryption typeMichael Vetter2020-04-061-2/+19
|
* db: log "to" resourceMichael Vetter2020-04-061-8/+8
|
* db: log "from" resourceMichael Vetter2020-04-061-6/+7
|
* db: log all incoming and outgoing messagesMichael Vetter2020-04-061-18/+33
|
* db: log outgoing message in one caseMichael Vetter2020-04-061-11/+43
| | | | Not all cases covered yet.
* db: add dedicated chat, muc, muc pm logging functionsMichael Vetter2020-04-061-1/+20
|
* db: insert message typeMichael Vetter2020-04-061-4/+14
|
* db: add more needed fieldsMichael Vetter2020-04-061-7/+20
| | | | DB fields should be complete now.
* db: make id autoincrementMichael Vetter2020-04-061-1/+1
|
* db: fix inserting null in databaseMichael Vetter2020-04-061-1/+1
|
* db: log replace idMichael Vetter2020-04-061-3/+3
|
* db: use goto in error caseMichael Vetter2020-04-061-24/+13
|
* db: add db versionMichael Vetter2020-04-061-1/+25
| | | | so we can later migrate.
* db: move includesMichael Vetter2020-04-061-4/+1
|
* db: guard against no DBMichael Vetter2020-04-061-2/+10
| | | | | | | | Maybe if we only use `/connect` we dont have ProfAccount. In that case we won't log anything. Only if a account is used we log. If this is the case or the init of the db didn't work we still want profanity to run but wont log anything to the db.
* db: Have one database per accountMichael Vetter2020-04-061-4/+41
|
* database: log stanza_id and whether it is a muc messageMichael Vetter2020-04-061-4/+4
|