Skip to content

Commit

Permalink
Merge pull request #1167 from justingit/bugfixes-11_20_3
Browse files Browse the repository at this point in the history
Bugfixes 11 20 3
  • Loading branch information
justingit authored Aug 8, 2023
2 parents 68f475a + 1359077 commit b47eb48
Show file tree
Hide file tree
Showing 36 changed files with 1,490 additions and 727 deletions.
589 changes: 358 additions & 231 deletions app/dada/DADA/App.pm

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions app/dada/DADA/App/Digests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ sub should_send_digest {
my $self = shift;

if($self->mock_run() == 1){
my $keys = $self->{a_obj}->get_archive_entries('normal');
my $keys = $self->{a_obj}->get_archive_entries('ASC');
if ( scalar( @{$keys} ) == 0 ) {
return 0;
}
Expand All @@ -140,7 +140,7 @@ sub should_send_digest {
sub archive_ids_for_digest {

my $self = shift;
my $keys = $self->{a_obj}->get_archive_entries('normal');
my $keys = $self->{a_obj}->get_archive_entries('ASC');
my $ids = [];
my $digest_last_archive_id_sent = $self->{ls_obj}->param('digest_last_archive_id_sent') || undef;

Expand Down
8 changes: 1 addition & 7 deletions app/dada/DADA/App/Subscriptions/ConfirmationTokens.pm
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,6 @@ DESTROY {
$self->_remove_expired_tokens;
}

1;

sub token {

my $self = shift;
Expand Down Expand Up @@ -588,8 +586,4 @@ DESTROY {
$self->_remove_expired_tokens;
}

1;



1;
1;
6 changes: 4 additions & 2 deletions app/dada/DADA/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1809,8 +1809,8 @@ $ATTACHMENT_TEMPFILE //= 0;
$MAIL_VERP_SEPARATOR //= '-';


$VERSION = 11.20.2;
$VER = 'v11.20.2 stable 2023-07-06';
$VERSION = 11.21.0;
$VER = 'v11.21.0 stable 2023-08-07';

#
#
Expand Down Expand Up @@ -2052,6 +2052,8 @@ sub _config_import {
consents_table => 'dada_consents',
consent_activity_table => 'dada_consent_activity',

simple_auth_str_table => 'dada_simple_auth_str',

dbtype => 'SQLite',
database => 'dadamail',

Expand Down
2 changes: 1 addition & 1 deletion app/dada/DADA/Logging/Clickthrough.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5002,7 +5002,7 @@ sub send_analytics_email_notification {

}

sub DESTROUY {}
sub DESTROY {}

1;

Expand Down
6 changes: 3 additions & 3 deletions app/dada/DADA/Mail/MailOut.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2372,12 +2372,12 @@ sub log {
$file = make_safer($file);

open( MO_LOG, '>>:encoding(' . $DADA::Config::HTML_CHARSET . ')', $file )
or carp $!;
or carp "cannot open log file at, '$file': " . $!;
flock( MO_LOG, LOCK_SH );
print MO_LOG "[$time]\t$log\n"
or carp $!;
or carp 'cannot write to log file: ' . $!;
close(MO_LOG)
or carp $!;
or carp 'cannot close log file: ' . $!;

}

Expand Down
152 changes: 133 additions & 19 deletions app/dada/DADA/MailingList/Archives.pm
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,19 @@ sub get_archive_entries {
my $self = shift;
my $order = shift || 'normal';
my @keys;
my $in_reverse = $self->{ls}->param('sort_archives_in_reverse') || 0; #yeah, like what?

my $order = shift || undef;

if(! $order){
if($self->{ls}->param('sort_archives_in_reverse') == 1){
$order = 'DESC';
}
else {
$order = 'ASC'
}
}

my $query = 'SELECT archive_id FROM '. $self->{sql_params}->{archives_table} .
' WHERE list = ? ORDER BY archive_id ASC';
' WHERE list = ? ORDER BY archive_id ' . $order;

my $sth = $self->{dbh}->prepare($query);
$sth->execute($self->{name});
Expand All @@ -314,14 +323,12 @@ sub get_archive_entries {

$sth->finish;

if($order eq 'reverse' || $in_reverse == 1){
@keys = reverse @keys;
}
return \@keys;
}




sub get_archive_info {

my $self = shift;
Expand Down Expand Up @@ -462,24 +469,37 @@ sub set_archive_info {
=head2 search_entries
my $search_results = $archive->search_entries($keyword);
my $search_results = $archive->search_entries($query);
Given a $keyword, will return a array ref of archive key/ids that contain the
Given a $query, will return a array ref of archive key/ids that contain the
keyword.
=cut

sub search_entries {

my $self = shift;
my $keyword = shift;
my $qy = shift;
my $order = shift || undef;

# $order should be 'normal' or, 'reverse'. Brilliant.

if(! $order){
if($self->{ls}->param('sort_archives_in_reverse') == 1){
$order = 'DESC';
}
else {
$order = 'ASC'
}
}

my @results;

my $query = 'SELECT archive_id FROM '. $self->{sql_params}->{archives_table} .
' WHERE list = ? AND (raw_msg LIKE ? OR message LIKE ? OR subject LIKE ?) ORDER BY archive_id DESC';

' WHERE list = ? AND (raw_msg LIKE ? OR message LIKE ? OR subject LIKE ?) ORDER BY archive_id ' . $order;
my $sth = $self->{dbh}->prepare($query);
$sth->execute($self->{name}, '%'.$keyword.'%', '%'.$keyword.'%', '%'.$keyword.'%')
$sth->execute($self->{name}, '%'.$qy.'%', '%'.$qy.'%', '%'.$qy.'%')
or croak "cannot do statement! $DBI::errstr";
while((my $archives_id) = $sth->fetchrow_array){
push(@results, $archives_id);
Expand Down Expand Up @@ -980,16 +1000,44 @@ sub create_index {
my $entries = $self->get_archive_entries() || undef;

if($entries){

my ($start, $stop);

$start = $here;
$stop = ($start + $amount)-1;
return ($start, $stop);
}
}


sub archive_page_entries {

my $self = shift;
my $page = shift || 1;
my $entries = shift || undef;
if ( !defined($entries) ) {
$entries = $self->get_archive_entries();
}

# UI uses 1 as the index, internally, we shift this to 0
$page -= 1;

my $amount = $self->{ls}->param('archive_index_count') || 10;
my $r_entries = [];

for ( my $i = 0 ; $i < $amount ; $i++ ) {
my $i_i = $i + ( $page * $amount );
if ( defined( $entries->[$i_i] ) ) {
push( @$r_entries, $entries->[$i_i] );
}
else {
# most likely a good idea:
# last;
}
}
return $r_entries;
}





=pod
Expand Down Expand Up @@ -1044,6 +1092,71 @@ sub oldest_entry {



sub pagination_info {

require Data::Pageset;
require POSIX;

my $self = shift;
my ($args) = @_;

if(! exists($args->{-page})){
$args->{-page} = 1;
}
if($args->{-page} <= 0){
$args->{-page} = 1;
}
if(! exists($args->{-entries})){
$args->{-entries} = [];
}
if(! exists($args->{-entries_per_page})){
$args->{-entries_per_page} = $self->{ls}->param('archive_index_count');
}
if($#{$args->{-entries}} > 0){
if(
$args->{-page} > POSIX::ceil((($#{$args->{-entries}} + 1) / $args->{-entries_per_page}))
){
$args->{-page} = 1;
}
}

my $start_i = ($args->{-page} - 1) * $args->{-entries_per_page};
my $end_i = ($start_i + $args->{-entries_per_page}) - 1;


my $dps = Data::Pageset->new(
{
total_entries => $#{$args->{-entries}},
entries_per_page => $args->{-entries_per_page},
current_page => $args->{-page},
mode => 'slide',
pages_per_set => 10,
}
);

my $pages_in_set = [];
foreach my $page_num ( @{ $dps->pages_in_set() } ) {
if ( $page_num == $dps->current_page() ) {
push( @$pages_in_set, { page => $page_num, on_current_page => 1 } );
}
else {
push( @$pages_in_set, { page => $page_num, on_current_page => undef } );
}
}


return {
start_index => $start_i,
end_index => $end_i,
pages_in_set => $pages_in_set,
dps_obj => $dps,
page => $args->{-page},
}
}






=pod
Expand Down Expand Up @@ -2229,23 +2342,24 @@ sub massage {
=head2 make_search_summary
my $summaries = $archive->make_search_summary($keyword, $search_results);
my $summaries = $archive->make_search_summary($query, $search_results);
Given a $keyword (string) and $search_results (array ref of archive keys/ids)
Given a $query (string) and $search_results (array ref of archive keys/ids)
will return a hashref of each line the keyword appears in.
=cut

sub make_search_summary {

my $self = shift;
my $keyword = shift;
my $query = shift;
my $matches = shift;

my $message_summary;
my %search_summary;

my $key;

for $key(@$matches){

my ($subject, $message, $format, $raw_msg) = $self->get_archive_info($key);
Expand Down Expand Up @@ -2275,10 +2389,10 @@ sub make_search_summary {
my $line;

for $line(@message_lines){
if($line =~ m/$keyword/io){
if($line =~ m/$query/io){

# $line = convert_to_ascii($line);
$line =~ s{$keyword}{<em class="dm_highlighted">$keyword</em>}gi;
$line =~ s{$query}{<em class="dm_highlighted">$query</em>}gi;
$line = $self->massage($line);
$search_summary{$key} .= "... $line ... <br />";
}
Expand Down
5 changes: 4 additions & 1 deletion app/dada/DADA/MailingList/Schedules.pm
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,10 @@ sub run_schedules {
{
-settings => {
schedule_last_checked_time => time
}
},
-screen_cache => {
-clean_out => 0,
}
}
);

Expand Down
26 changes: 22 additions & 4 deletions app/dada/DADA/MailingList/Settings.pm
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,27 @@ sub save {

$self->{cached_settings} = undef;

require DADA::App::ScreenCache;
my $c = DADA::App::ScreenCache->new;
$c->flush;

if(!exists($args->{-screen_cache})){
$args->{-screen_cache} = {};
$args->{-screen_cache}->{-clean_out} = 1
}
if(!exists($args->{-screen_cache}->{-clean_out})){
$args->{-screen_cache}->{-clean_out} = 1
}

if($args->{-screen_cache}->{-clean_out} == 1){
warn 'removing screen cache'
if $t;
require DADA::App::ScreenCache;
my $c = DADA::App::ScreenCache->new;
$c->flush;
undef $c;
}
else {
warn 'preserving screen cache'
if $t;
}

$self->{RAW_DB_HASH} = undef;

for my $other_list(@$also_save_for){
Expand All @@ -246,6 +263,7 @@ sub save {
$other_ls->save({
-also_save_for => [],
-settings => $orig_settings,
-screen_cache => $args->{-screen_cache},
});
} catch {
warn 'problem saving settings for, ' . $other_list . ' because:' . $_;
Expand Down
Loading

0 comments on commit b47eb48

Please sign in to comment.