Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invitations via the Sympa website #648

Closed
Salo15 opened this issue Jun 11, 2019 · 5 comments · Fixed by #1849
Closed

Invitations via the Sympa website #648

Salo15 opened this issue Jun 11, 2019 · 5 comments · Fixed by #1849

Comments

@Salo15
Copy link

Salo15 commented Jun 11, 2019

The invitation mechanism should also be able to be initiated from the advertising side.

Expected Behavior

On the Sympa website of a list, it should be possible to invite users to the list (of course only for those users who have permission to invite users to the list).

Current Behavior

The Invite mechanism can only be used by email command.
Or is it already possible to invite users via the website and I just haven't found this function yet (in version 6.2.16)?

Possible Solution

Alternatively, it should be possible to send Sympa commands via the website.

Context

We have received several requests from users how to invite users to a list via the website.

@adam12b1
Copy link

adam12b1 commented May 29, 2024

I'm glad to find this issue already existing - it is very strange to not have the invite function in the WWSympa interface! So we added one, and I will offer our patch here, but I'm sure Soji will want to improve it in various ways (for example, we were not able to get the confirmation step working the way it does when adding or removing subscribers). I hope this is helpful somehow.

Obviously the biggest patch is to wwsympa.fcgi itself, but you also need to add the feature to the review.tt2 and import.tt2 templates. Individual context diffs for each file, starting from the Sympa 6.2.72 code:

*** review.tt2.orig     Wed May 29 10:02:57 2024
--- review.tt2  Wed May 29 10:02:02 2024
***************
*** 101,106 ****
--- 101,108 ----
                  <div>
                      <input class="MainMenuLinks" type="submit"
                             name="action_add" value="[%|loc%]Add[%END%]" />
+                     or <input class="MainMenuLinks" type="submit"
+                            name="action_invite" value="Invite" />
                  </div>
              </fieldset>
          </form>
*** import.tt2.orig     Wed May 29 10:03:07 2024
--- import.tt2  Wed May 29 10:04:15 2024
***************
*** 16,21 ****
--- 16,23 ----
          [% END ~%]
          <input class="MainMenuLinks" type="submit" name="action_import"
                 value="[%|loc%]Add subscribers[%END%]" />
+         or <input class="MainMenuLinks" type="submit" name="action_invite"
+              value="Invite" />
      </div>
  </form>
  <!-- end import.tt2 -->
*** wwsympa.fcgi.orig   Wed May 29 09:51:06 2024
--- wwsympa.fcgi        Wed May 29 09:59:45 2024
***************
*** 291,296 ****
--- 291,299 ----
      'set_lang'            => 'do_set_lang',
      'attach'              => 'do_attach',
      'stats'               => 'do_stats',
+     #---acb: add web-based invite
+     'invite'              => 'do_invite',
+     #---acb end
      'viewlogs'            => 'do_viewlogs',
      'wsdl'                => 'do_wsdl',
      'sync_include'        => 'do_sync_include',
***************
*** 16896,16901 ****
--- 16899,16981 ----
      close $fh;

  }
+ #---acb: need a web invite function
+ # (code mostly stolen from do_add() and do_import())
+ sub do_invite {
+
+     # Access control.
+     unless (defined check_authz('do_invite', 'invite')) {
+         add_stash('user', 'Invite not allowed');
+         return 'review';
+     }
+
+     my @emails;
+
+     # address for single user (from review.tt2) is in $in{email}:
+     if ($in{'email'}) {
+         @emails =
+             grep {$_} map { Sympa::Tools::Text::canonic_email($_) }
+         split /\0/, $in{'email'};
+         $log->syslog('info', 'single invite "%s"', join(' ',@emails));
+         unless (@emails) {
+             add_stash('user', 'no_email');
+             return 'review';
+         }
+     } else { # addresses for multiple users (from import.tt2) are $in{dump}
+         foreach (split /\r\n|\r|\n/, $in{'dump'}) {
+             next unless /\S/;
+             next if /\A\s*#/;    #FIXME: email address can contain '#'
+
+             my ($email) = m{\A\s*(\S+)(?:\s+(.*))?\s*\z};
+             push @emails, $email;
+         }
+         $log->syslog('info', 'multiple invite "%s"', join(' ',@emails));
+         unless (@emails) {
+             add_stash('user', 'no_email');
+             return 'import';
+         }
+     }
+
+     $param->{'email'} = [@emails];
+
+     my $stash     = [];
+     my $processed = 0;
+     foreach my $email (@emails) {
+         $log->syslog('info', 'do_invite working on %s', $emails[0]);
+         my $spindle = Sympa::Spindle::ProcessRequest->new(
+             context          => $list,
+             action           => 'invite',
+             email            => $email,
+             sender           => $param->{'user'}{'email'},
+             md5_check        => 1,
+             scenario_context => {
+                 email       => $email,
+                 sender      => $param->{'user'}{'email'},
+                 remote_host => $param->{'remote_host'},
+                 remote_addr => $param->{'remote_addr'}
+             },
+             stash => $stash,
+         );
+         $spindle and $processed += $spindle->spin;
+     }
+     unless ($processed) {
+         return $in{'previous_action'} || 'review';
+     }
+
+     foreach my $report (@$stash) {
+         if ($report->[1] eq 'notice') {
+             add_stash('notice', @{$report}[2, 3]);
+         } else {
+             add_stash(@{$report}[1 .. 3]);
+         }
+     }
+     unless (@$stash) {
+         add_stash('notice', 'performed');
+     }
+
+     return $in{'previous_action'} || 'review';
+ }
+ #---acb end

  __END__

@ikedas
Copy link
Member

ikedas commented May 31, 2024

Hi @adam12b1 , thank you for improvement! Could you please submit a pull request?

@adam12b1
Copy link

adam12b1 commented Jun 4, 2024

Hi @adam12b1 , thank you for improvement! Could you please submit a pull request?

Oh, thank you for the response, yes I will... I just have to figure out how to do that! I'm not a real developer. :) But I will work on it when I have some time.

adam12b1 pushed a commit to adam12b1/sympa that referenced this issue Jun 4, 2024
adam12b1 pushed a commit to adam12b1/sympa that referenced this issue Jun 4, 2024
adam12b1 pushed a commit to adam12b1/sympa that referenced this issue Jun 4, 2024
@ikedas
Copy link
Member

ikedas commented Jun 5, 2024

@adam12b1 , now you have your own fork and you're a real developer!

You'd be better to create a branch for PR on your fork and to work there. See also documentation on GitHub.

@adam12b1
Copy link

adam12b1 commented Jun 6, 2024

Thank you @ikedas for the guidance, I think maybe I got it right now?

Please let me know if there are any other conventions I should follow for PR, as I have a big stack of other bug fixes and features to submit when I have time.... :)

@ikedas ikedas linked a pull request Aug 25, 2024 that will close this issue
ikedas added a commit that referenced this issue Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants