Skip to content

Commit

Permalink
Clearer types in code rather than void pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
teusbenschop committed Jan 6, 2024
1 parent 3f7c274 commit e64807d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
8 changes: 4 additions & 4 deletions changes/changes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ string changes_changes (Webserver_Request& webserver_request)
// Handle AJAX call to remove a change notification.
if (webserver_request.post.count ("remove")) {
const int remove = filter::strings::convert_to_int (webserver_request.post["remove"]);
trash_change_notification (std::addressof(webserver_request), remove);
trash_change_notification (webserver_request, remove);
database_modifications.deleteNotification (remove);
#ifdef HAVE_CLIENT
webserver_request.database_config_user ()->addRemovedChange (remove);
Expand Down Expand Up @@ -171,7 +171,7 @@ string changes_changes (Webserver_Request& webserver_request)
if (webserver_request.query.count ("personal")) {
vector <int> ids = database_modifications.getNotificationTeamIdentifiers (username, changes_personal_category (), selectedbible);
for (const auto id : ids) {
trash_change_notification (std::addressof(webserver_request), id);
trash_change_notification (webserver_request, id);
database_modifications.deleteNotification (id);
#ifdef HAVE_CLIENT
webserver_request.database_config_user ()->addRemovedChange (id);
Expand All @@ -185,7 +185,7 @@ string changes_changes (Webserver_Request& webserver_request)
if (webserver_request.query.count ("bible")) {
vector <int> ids = database_modifications.getNotificationTeamIdentifiers (username, changes_bible_category (), selectedbible);
for (const auto id : ids) {
trash_change_notification (std::addressof(webserver_request), id);
trash_change_notification (webserver_request, id);
database_modifications.deleteNotification (id);
#ifdef HAVE_CLIENT
webserver_request.database_config_user ()->addRemovedChange (id);
Expand All @@ -200,7 +200,7 @@ string changes_changes (Webserver_Request& webserver_request)
string user = webserver_request.query ["dismiss"];
vector <int> ids = database_modifications.getNotificationTeamIdentifiers (username, user, selectedbible);
for (auto id : ids) {
trash_change_notification (std::addressof(webserver_request), id);
trash_change_notification (webserver_request, id);
database_modifications.deleteNotification (id);
#ifdef HAVE_CLIENT
webserver_request.database_config_user ()->addRemovedChange (id);
Expand Down
4 changes: 2 additions & 2 deletions database/notes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void Database_Notes::trim_server ()
// Deal with new notes storage in JSON.
identifiers = get_due_for_deletion ();
for (auto & identifier : identifiers) {
trash_consultation_note (std::addressof(m_webserver_request), identifier);
trash_consultation_note (m_webserver_request, identifier);
erase (identifier);
}
}
Expand Down Expand Up @@ -292,7 +292,7 @@ void Database_Notes::sync ()
// Any note identifiers in the main index, and not in the filesystem, remove them.
for (auto id : database_identifiers) {
if (find (identifiers.begin(), identifiers.end(), id) == identifiers.end()) {
trash_consultation_note (std::addressof(m_webserver_request), id);
trash_consultation_note (m_webserver_request, id);
erase (id);
}
}
Expand Down
1 change: 0 additions & 1 deletion navigation/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,3 @@ string navigation_update (Webserver_Request& webserver_request)
// Build the navigation html fragment.
return Navigation_Passage::get_mouse_navigator (webserver_request, bible);
}

4 changes: 2 additions & 2 deletions notes/logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void Notes_Logic::markForDeletion (int identifier)
{
Database_Notes database_notes (m_webserver_request);
database_notes.mark_for_deletion (identifier);
trash_consultation_note (std::addressof(m_webserver_request), identifier);
trash_consultation_note (m_webserver_request, identifier);
if (client_logic_client_enabled ()) {
// Client: record the action in the database.
string user = m_webserver_request.session_logic ()->currentUser ();
Expand Down Expand Up @@ -299,7 +299,7 @@ void Notes_Logic::erase (int identifier)
// Server: notification.
handlerDeleteNote (identifier);
}
trash_consultation_note (std::addressof(m_webserver_request), identifier);
trash_consultation_note (m_webserver_request, identifier);
database_notes.erase (identifier);
}

Expand Down
12 changes: 5 additions & 7 deletions trash/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,26 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
using namespace std;


void trash_change_notification (void * webserver_request, int id)
void trash_change_notification (Webserver_Request& webserver_request, int id)
{
Database_Modifications database_modifications;
Passage passage = database_modifications.getNotificationPassage (id);
string passageText = filter_passage_display_inline ({passage});
string modification = database_modifications.getNotificationModification (id);
Webserver_Request * request = static_cast<Webserver_Request *>(webserver_request);
string username = request->session_logic()->currentUser ();
string username = webserver_request.session_logic()->currentUser ();
Database_Logs::log (username + " removed change notification " + passageText + " : " + modification);
}


void trash_consultation_note (void * webserver_request, int id)
void trash_consultation_note (Webserver_Request& webserver_request, int id)
{
Webserver_Request * request = static_cast<Webserver_Request *>(webserver_request);
Database_Notes database_notes (*request);
Database_Notes database_notes (webserver_request);
vector <Passage> passages = database_notes.get_passages (id);
string passageText = filter_passage_display_inline (passages);
string summary = database_notes.get_summary (id);
string contents = database_notes.get_contents (id);
contents = filter::strings::html2text (contents);
string username = request->session_logic()->currentUser ();
string username = webserver_request.session_logic()->currentUser ();
if (username.empty ()) username = "This app";
Database_Logs::log (username + " deleted or marked for deletion consultation note " + passageText + " | " + summary + " | " + contents);
}
6 changes: 4 additions & 2 deletions trash/handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#include <config/libraries.h>

void trash_change_notification (void * webserver_request, int id);
void trash_consultation_note (void * webserver_request, int id);
class Webserver_Request;

void trash_change_notification (Webserver_Request& webserver_request, int id);
void trash_consultation_note (Webserver_Request& webserver_request, int id);

0 comments on commit e64807d

Please sign in to comment.