List of commits:
Subject Hash Author Date (UTC)
Mostly debug signaling by cache 2cd13a1f01403ebe733ef64ff2446b93e2cd46af Catalin(ux) M. BOIE 2015-11-18 16:36:40
Only texts changes. 37b6e035a5027c99a8b21672cef5431673320892 Catalin(ux) M. BOIE 2015-11-17 17:58:52
webhooks fixes 422d74f1cd4133e73ceb3edbb7a7da6d48c102f2 Catalin(ux) M. BOIE 2015-11-17 15:53:10
Checkpoint: ip/user fixes for remote connections, some pull request fixes and unit test start c8ac332f2ffda6149048dd17eaef8ff2f2920650 Catalin(ux) M. BOIE 2015-11-07 05:30:04
Added webhooks c2b73a8e494c4c61ce2d3f0d4101f0836a5a0df6 Catalin(ux) M. BOIE 2015-10-29 03:55:44
Mostly totp fixes; all tests pass; css fixes b4e220bf8823cad220183930949e80a6ec7f2fb3 Catalin(ux) M. BOIE 2015-10-17 12:02:14
Correct some gramatical problems 9078444271ce3e4fa25cff60afdb4efa8741fa01 Catalin(ux) M. BOIE 2015-09-13 08:43:38
Added weeks for ssh IP validity 6a8679ab22c25fd60504d2b21d57e9f1e2aaa254 Catalin(ux) M. BOIE 2015-09-13 08:03:51
Do not on any event if the protocol match. Assume is stable now. 69912910f5c0bbddc73ced992d8b3a652a8ff526 Catalin(ux) M. BOIE 2015-09-11 05:06:16
Bump version to 0.40 89d2ee4c3cae790d05a8b853de8427298dcbb9e1 Catalin(ux) M. BOIE 2015-09-11 04:59:49
Fix repo stats when there is no commit inside. 621b0a317b65d9a751d221908b8e1664d96011fa Catalin(ux) M. BOIE 2015-09-11 04:58:31
Added back the repo stats d8d06816223b52ff1d65df502fc6175f26c15518 Catalin(ux) M. BOIE 2015-09-10 04:44:10
TOTP fixes: mostly correct error messages 0f13d65e13211a91ce077b4a09307e54e9113f38 Catalin(ux) M. BOIE 2015-09-08 04:59:02
Lots of bug fixes, especially for cache a34c707720da68378086f73f16dd25c5a1ca8072 Catalin(ux) M. BOIE 2015-09-07 06:06:46
Mostly TOTP stuff for ssh 90eed0aa343f735f717238e3937439737290ecfd Catalin(ux) M. BOIE 2015-08-28 04:51:12
Added TOTP feature and some other minor stuff e9197291380929dd53f02f7373e8a339d6bd65a2 Catalin(ux) M. BOIE 2015-08-23 12:07:44
TODO clean-up. 1ae7c17d523aec8e6a303264e2c35934c459fc9d Catalin(ux) M. BOIE 2015-07-14 20:27:45
duilder updates (error out if head is not a tag 09ff5d7b52d059a7fab09427d8e6d12319a53804 Catalin(ux) M. BOIE 2015-07-14 20:27:35
Bump version to 0.39 c28468b1cf0488f8f98b04aeb6ba26429ee91807 Catalin(ux) M. BOIE 2015-07-14 04:34:34
duilder updates cc12a3a5a95586b4533346ccf7fd4cfa652e7d6f Catalin(ux) M. BOIE 2015-07-14 04:34:09
Commit 2cd13a1f01403ebe733ef64ff2446b93e2cd46af - Mostly debug signaling by cache
Author: Catalin(ux) M. BOIE
Author date (UTC): 2015-11-18 16:36
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2015-11-18 16:36
Parent(s): 37b6e035a5027c99a8b21672cef5431673320892
Signing key:
Tree: 94a817cf01bfa7fa41c265631c24088d78aa9409
File Lines added Lines deleted
inc/bug.inc.php 1 12
inc/keys.inc.php 1 6
inc/mail.inc.php 76 0
inc/repo.inc.php 1 6
inc/user.inc.php 2 5
inc/util.inc.php 0 44
inc/webhooks.inc.php 4 4
root/themes/default/mail/user/welcome.body.txt 1 1
tests/email.php 64 5
tests/event.php 1 1
tests/wh.php 2 2
File inc/bug.inc.php changed (mode: 100644) (index 5451e46..87fb889)
... ... require_once($INC . "/sql.inc.php");
5 5 require_once($INC . "/user.inc.php"); require_once($INC . "/user.inc.php");
6 6 require_once($INC . "/repo.inc.php"); require_once($INC . "/repo.inc.php");
7 7 require_once($INC . "/prof.inc.php"); require_once($INC . "/prof.inc.php");
8 require_once($INC . "/mail.inc.php");
8 9 require_once($INC . "/events.inc.php"); require_once($INC . "/events.inc.php");
9 10 require_once($INC . "/watch.inc.php"); require_once($INC . "/watch.inc.php");
10 11
 
... ... function rg_bug_event_add_one($db, $event)
50 51
51 52 $ret = FALSE; $ret = FALSE;
52 53 while (1) { while (1) {
53 if ($event['debug'] == 1) {
54 rg_cache_set('DEBUG::bug_event_add_one', $event, 0);
55 $ret = array();
56 break;
57 }
58
59 54 // lookup user email // lookup user email
60 55 $ui = rg_user_info($db, $event['ui']['uid'], '', ''); $ui = rg_user_info($db, $event['ui']['uid'], '', '');
61 56 if ($ui['exists'] != 1) { if ($ui['exists'] != 1) {
 
... ... function rg_bug_event_note_add_one($db, $event)
133 128
134 129 $ret = FALSE; $ret = FALSE;
135 130 while (1) { while (1) {
136 if ($event['debug'] == 1) {
137 rg_cache_set('DEBUG::bug_event_note_add_one', $event, 0);
138 $ret = array();
139 break;
140 }
141
142 131 // lookup user email // lookup user email
143 132 $ui = rg_user_info($db, $event['ui']['uid'], '', ''); $ui = rg_user_info($db, $event['ui']['uid'], '', '');
144 133 if ($ui['exists'] != 1) { if ($ui['exists'] != 1) {
File inc/keys.inc.php changed (mode: 100644) (index a7a062c..c2e75a2)
2 2 require_once($INC . "/sql.inc.php"); require_once($INC . "/sql.inc.php");
3 3 require_once($INC . "/state.inc.php"); require_once($INC . "/state.inc.php");
4 4 require_once($INC . "/prof.inc.php"); require_once($INC . "/prof.inc.php");
5 require_once($INC . "/mail.inc.php");
5 6 require_once($INC . "/events.inc.php"); require_once($INC . "/events.inc.php");
6 7
7 8 $rg_keys_error = ""; $rg_keys_error = "";
 
... ... function rg_keys_event_notify_user($db, $event)
103 104
104 105 $ret = FALSE; $ret = FALSE;
105 106 while (1) { while (1) {
106 if ($event['debug'] == 1) {
107 rg_cache_set('DEBUG::keys_event_notify_user', $event, 0);
108 $ret = array();
109 break;
110 }
111
112 107 $r = rg_mail_template("mail/user/key/" . $event['op'], $event); $r = rg_mail_template("mail/user/key/" . $event['op'], $event);
113 108 if ($r === FALSE) if ($r === FALSE)
114 109 break; break;
File inc/mail.inc.php added (mode: 100644) (index 0000000..24dc5b0)
1 <?php
2 require_once($INC . "/prof.inc.php");
3 require_once($INC . "/log.inc.php");
4 require_once($INC . "/util.inc.php");
5
6
7 $rg_mail_error = "";
8
9 function rg_mail_set_error($str)
10 {
11 global $rg_mail_error;
12 $rg_mail_error = $str;
13 }
14
15 function rg_mail_error()
16 {
17 global $rg_mail_error;
18 return $rg_mail_error;
19 }
20
21 /*
22 * Function to send e-mails
23 * TODO: Replace mail() with rg_mail everywhere.
24 */
25 function rg_mail_template($template, $more)
26 {
27 global $rg_admin_name, $rg_admin_email;
28
29 rg_prof_start("mail_template");
30 rg_log("mail_template: $template, more=" . rg_array2string($more));
31
32 // Account was not confirmed, so do not send mail
33 if (empty($more['ui']['email']))
34 return TRUE;
35
36 $more['HTML:rg_admin_email'] = $rg_admin_email;
37 $more['HTML:utf8_rg_admin_name'] = "=?UTF-8?B?"
38 . base64_encode($rg_admin_name) . "?=";
39
40 $subject = rg_template($template . ".subj.txt", $more, FALSE /*xss*/);
41 $subject = trim($subject);
42 $subject = str_replace("\r", '', $subject);
43 $subject = str_replace("\n", '', $subject);
44 // TODO: do not encode it as UTF-8 if not needed
45 $subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
46
47 $header = rg_template("mail/common.head.txt", $more, FALSE /*xss*/);
48 $header .= rg_template($template . ".head.txt", $more, FALSE /*xss*/);
49 $header = trim($header);
50
51 $body = rg_template($template . ".body.txt", $more, FALSE /*xss*/);
52
53 rg_log("CHECK: mail_template(" . $more['ui']['email'] . ",
54 $subject, $body, $header, -f $rg_admin_email");
55 if ($more['debug'] == 1) {
56 rg_cache_set('DEBUG::' . $more['ui']['uid'] . '::mail',
57 array(
58 'header' => $header,
59 'subject' => $subject,
60 'to' => $more['ui']['email'],
61 'body' => $body
62 ), RG_SOCKET_NO_WAIT);
63 $ret = TRUE;
64 } else {
65 $ret = mail($more['ui']['email'], $subject, $body, $header,
66 "-f $rg_admin_email");
67 }
68 if ($ret === FALSE)
69 rg_log("Sending mail failed to=" . $more['ui']['email']
70 . " subject=$subject!");
71
72 rg_prof_end("mail_template");
73 return $ret;
74 }
75
76 ?>
File inc/repo.inc.php changed (mode: 100644) (index 0b62a2d..b1ecc06)
... ... require_once($INC . "/user.inc.php");
6 6 require_once($INC . "/git.inc.php"); require_once($INC . "/git.inc.php");
7 7 require_once($INC . "/rights.inc.php"); require_once($INC . "/rights.inc.php");
8 8 require_once($INC . "/prof.inc.php"); require_once($INC . "/prof.inc.php");
9 require_once($INC . "/mail.inc.php");
9 10 require_once($INC . "/events.inc.php"); require_once($INC . "/events.inc.php");
10 11 require_once($INC . "/webhooks.inc.php"); require_once($INC . "/webhooks.inc.php");
11 12
 
... ... function rg_repo_event_notify_user($db, $event)
476 477
477 478 $ret = FALSE; $ret = FALSE;
478 479 while (1) { while (1) {
479 if ($event['debug'] == 1) {
480 rg_cache_set('DEBUG::repo_event_notify_user', $event, 0);
481 $ret = array();
482 break;
483 }
484
485 480 $r = rg_mail_template("mail/user/repo/" . $event['op'], $event); $r = rg_mail_template("mail/user/repo/" . $event['op'], $event);
486 481 if ($r === FALSE) if ($r === FALSE)
487 482 break; break;
File inc/user.inc.php changed (mode: 100644) (index bcc3b10..aeb083f)
... ... require_once($INC . "/sess.inc.php");
7 7 require_once($INC . "/rights.inc.php"); require_once($INC . "/rights.inc.php");
8 8 require_once($INC . "/events.inc.php"); require_once($INC . "/events.inc.php");
9 9 require_once($INC . "/cache.inc.php"); require_once($INC . "/cache.inc.php");
10 require_once($INC . "/mail.inc.php");
10 11 require_once($INC . "/plan.inc.php"); require_once($INC . "/plan.inc.php");
11 12 require_once($INC . "/totp.inc.php"); require_once($INC . "/totp.inc.php");
12 13
 
... ... function rg_user_event_notify_user($db, $event)
92 93 { {
93 94 rg_log("user_event_notify_user: event=" . rg_array2string($event)); rg_log("user_event_notify_user: event=" . rg_array2string($event));
94 95
95 if ($event['debug'] == 1) {
96 rg_cache_set('DEBUG::user_event_notify_user', $event, 0);
97 return array();
98 }
99
100 96 if (strcmp($event['op'], "rename") == 0) { if (strcmp($event['op'], "rename") == 0) {
101 97 $r = rg_mail_template("mail/user/rename", $event); $r = rg_mail_template("mail/user/rename", $event);
102 98 } else { } else {
 
... ... function rg_user_edit($db, $d)
524 520 $event = array('category' => 2000, 'prio' => 50, $event = array('category' => 2000, 'prio' => 50,
525 521 'ui' => array( 'ui' => array(
526 522 'uid' => $row['uid'], 'uid' => $row['uid'],
523 'realname' => $d['realname'],
527 524 'username' => $d['username'], 'username' => $d['username'],
528 525 'email' => $d['confirmed'] > 0 ? $d['email'] : "", 'email' => $d['confirmed'] > 0 ? $d['email'] : "",
529 526 'confirm_token' => $d['confirm_token'] 'confirm_token' => $d['confirm_token']
File inc/util.inc.php changed (mode: 100644) (index 9f4ebdf..fc68b0f)
... ... function rg_date2ts_last_second($s)
1345 1345 return gmmktime(0, 0, 0, $f[1], $f[2] + 1, $f[0]) - 1; return gmmktime(0, 0, 0, $f[1], $f[2] + 1, $f[0]) - 1;
1346 1346 } }
1347 1347
1348 /*
1349 * Function to send e-mails
1350 * TODO: Replace mail() with rg_mail everywhere.
1351 */
1352 function rg_mail_template($template, $more)
1353 {
1354 global $rg_admin_name, $rg_admin_email;
1355
1356 rg_prof_start("mail_template");
1357 rg_log("mail_template: $template, more=" . rg_array2string($more));
1358
1359 // Account was not confirmed, so do not send mail
1360 if (empty($more['ui']['email']))
1361 return TRUE;
1362
1363 $more['HTML:rg_admin_email'] = $rg_admin_email;
1364 $more['HTML:utf8_rg_admin_name'] = "=?UTF-8?B?"
1365 . base64_encode($rg_admin_name) . "?=";
1366
1367 $subject = rg_template($template . ".subj.txt", $more, FALSE /*xss*/);
1368 $subject = trim($subject);
1369 $subject = str_replace("\r", '', $subject);
1370 $subject = str_replace("\n", '', $subject);
1371 // TODO: do not encode it as UTF-8 if not needed
1372 $subject = "=?UTF-8?B?" . base64_encode($subject) . "?=";
1373
1374 $header = rg_template("mail/common.head.txt", $more, FALSE /*xss*/);
1375 $header .= rg_template($template . ".head.txt", $more, FALSE /*xss*/);
1376 $header = trim($header);
1377
1378 $body = rg_template($template . ".body.txt", $more, FALSE /*xss*/);
1379
1380 rg_log("CHECK: mail_template(" . $more['ui']['email'] . ",
1381 $subject, $body, $header, -f $rg_admin_email");
1382 $ret = mail($more['ui']['email'], $subject, $body, $header,
1383 "-f $rg_admin_email");
1384 if ($ret === FALSE)
1385 rg_log("Sending mail failed to=" . $more['ui']['email']
1386 . " subject=$subject!");
1387
1388 rg_prof_end("mail_template");
1389 return $ret;
1390 }
1391
1392 1348 /* /*
1393 1349 * Special implode, with prefix/postfix * Special implode, with prefix/postfix
1394 1350 */ */
File inc/webhooks.inc.php changed (mode: 100644) (index 16d1ff3..4306a6f)
... ... function rg_wh_send_one($db, $event)
119 119 rg_log_ml('Debug: ' . print_r($_info, TRUE)); rg_log_ml('Debug: ' . print_r($_info, TRUE));
120 120
121 121 if ($event['debug'] == 1) if ($event['debug'] == 1)
122 rg_cache_set('DEBUG::webhooks::' . $event['ui']['uid']
123 . '::' . $info['opaque']
122 rg_cache_set('DEBUG::' . $event['ui']['uid']
123 . '::webhooks::' . $info['opaque']
124 124 . '::' . $wh['id'], . '::' . $wh['id'],
125 125 'BAD', RG_SOCKET_NO_WAIT); 'BAD', RG_SOCKET_NO_WAIT);
126 126 break; break;
 
... ... function rg_wh_send_one($db, $event)
129 129 rg_log_ml('Answer: ' . print_r($r, TRUE)); rg_log_ml('Answer: ' . print_r($r, TRUE));
130 130
131 131 if ($event['debug'] == 1) if ($event['debug'] == 1)
132 rg_cache_set('DEBUG::webhooks::' . $event['ui']['uid']
133 . '::' . $info['opaque']
132 rg_cache_set('DEBUG::' . $event['ui']['uid']
133 . '::webhooks::' . $info['opaque']
134 134 . '::' . $wh['id'], . '::' . $wh['id'],
135 135 'OK', RG_SOCKET_NO_WAIT); 'OK', RG_SOCKET_NO_WAIT);
136 136
File root/themes/default/mail/user/welcome.body.txt changed (mode: 100644) (index 922225f..7a0fba0)
1 Dear @@if("@@name@@" == ""){{@@name@@}}{{@@username@@}},
1 Dear @@if("@@ui::realname@@" != ""){{@@ui::realname@@}}{{@@ui::username@@}},
2 2
3 3 Thank you for choosing RocketGit as your hosting solution. Thank you for choosing RocketGit as your hosting solution.
4 4 We are happy to host your projects. We are happy to host your projects.
File tests/email.php changed (mode: 100644) (index 6cd2534..baf34aa)
... ... $INC = dirname(__FILE__) . "/../inc";
6 6 require_once(dirname(__FILE__) . "/config.php"); require_once(dirname(__FILE__) . "/config.php");
7 7 require_once($INC . "/init.inc.php"); require_once($INC . "/init.inc.php");
8 8 require_once($INC . "/util.inc.php"); require_once($INC . "/util.inc.php");
9 require_once("helpers.inc.php");
9 10
10 11 rg_log_set_file("email.log"); rg_log_set_file("email.log");
11 12
13 $rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10";
12 14 $rg_no_db = TRUE; $rg_no_db = TRUE;
13 15 require_once("common.php"); require_once("common.php");
14 16
17 $_testns = 'email';
18 $rg_cache_enable = TRUE;
19
15 20 $rg_scripts = "../"; $rg_scripts = "../";
16 21 $rg_theme = "default"; $rg_theme = "default";
22 $rg_event_socket = "/var/lib/rocketgit/sockets/event.sock";
17 23
18 24 rg_log_set_file("email.log"); rg_log_set_file("email.log");
19 25
20 $more = array(
21 "to" => "xxx@embedromix.ro"
22 );
26 // This will trigger an e-mail
27 rg_test_create_user($db, $rg_ui);
28
29
30 rg_log('');
31 rg_log('Trying to get the cache info...');
32 $key = 'DEBUG::' . $rg_ui['uid'];
33 $tries = 10;
34 while ($tries--) {
35 $r = rg_cache_get($key);
36 if ($r === FALSE) {
37 sleep(1);
38 continue;
39 }
40
41 break;
42 }
43 if ($r === FALSE) {
44 rg_log('DEBUG key was not set!');
45 exit(1);
46 }
47 if (!strstr($r['mail']['body'], 'Dear ' . $rg_ui['realname'])) {
48 rg_log_ml('body: ' . print_r($r['mail']['body'], TRUE));
49 rg_log('realname was specified bu not found in e-mail!');
50 exit(1);
51 }
52
53
54 rg_log('');
55 rg_log('Testing without specifying a realname');
56 $rg_ui = array('realname' => '');
57 rg_test_create_user($db, $rg_ui);
58
59
60 rg_log('');
61 rg_log('Trying to get the cache info...');
62 $key = 'DEBUG::' . $rg_ui['uid'];
63 $tries = 10;
64 while ($tries--) {
65 $r = rg_cache_get($key);
66 if ($r === FALSE) {
67 sleep(1);
68 continue;
69 }
70
71 break;
72 }
73 if ($r === FALSE) {
74 rg_log('DEBUG key was not set!');
75 exit(1);
76 }
77 if (!strstr($r['mail']['body'], 'Dear ' . $rg_ui['username'])) {
78 rg_log_ml('body: ' . print_r($r['mail']['body'], TRUE));
79 rg_log('realname was specified bu not found in e-mail!');
80 exit(1);
81 }
82
23 83
24 $r = rg_mail_template("mail/user/key/new", $more);
25 print_r($r);
84 rg_log('OK');
26 85 ?> ?>
File tests/event.php changed (mode: 100644) (index d7fefcf..dfb4240)
... ... if ($r !== TRUE) {
71 71 rg_log("Cannot add event (" . rg_event_error() . ")!"); rg_log("Cannot add event (" . rg_event_error() . ")!");
72 72 exit(1); exit(1);
73 73 } }
74 rg_event_signal_daemon("", 0);
74 rg_event_signal_daemon('', 0);
75 75
76 76 $notify_list = array(); $notify_list = array();
77 77 $r = rg_event_process_queue($db, $notify_list); $r = rg_event_process_queue($db, $notify_list);
File tests/wh.php changed (mode: 100644) (index cc5443e..0bbf288)
... ... rg_log('Started stunnel with pid ' . $pid);
89 89 rg_log(''); rg_log('');
90 90 rg_log("Creating a user..."); rg_log("Creating a user...");
91 91 rg_test_create_user($db, $rg_ui); rg_test_create_user($db, $rg_ui);
92 $key1 = 'DEBUG::webhooks::' . $rg_ui['uid'] . '::' . $port1;
93 $key2 = 'DEBUG::webhooks::' . $rg_ui['uid'] . '::' . $port2;
92 $key1 = 'DEBUG::' . $rg_ui['uid'] . '::webhooks::' . $port1;
93 $key2 = 'DEBUG::' . $rg_ui['uid'] . '::webhooks::' . $port2;
94 94
95 95
96 96 rg_log(''); rg_log('');
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main