Skip to content

Commit 23f8d4a

Browse files
authored
Merge branch 'master' into msg-actions-buttons
2 parents 0dfaedf + 5282a4a commit 23f8d4a

33 files changed

+410
-204
lines changed

CONTRIBUTING.md

Lines changed: 127 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,130 @@
1-
We appreciate all feedback and support of the project.
2-
Please use the issue tracker at GitHub to submit bug reports or feature requests:
1+
# How to contribute
32

4-
https://github.com/cypht-org/cypht/issues
3+
Thank you for choosing Cypht webmail and for your willingness to contribute to its development! Your support helps make it better for everyone. There are many ways to get involved, regardless of your technical skill level: you can **report a bug** you've encountered, **propose an exciting new feature**, submit a **code fix** for an existing issue, or **improve our documentation** to make it clearer for other users. Every contribution, big or small, is valued and makes a real difference to the project and our community.
4+
5+
## Reporting Bugs
6+
7+
Bugs are tracked as [GitHub issues](https://github.com/cypht-org/cypht/issues). Before creating a new issue:
8+
- **Search existing issues** to see if the problem has already been reported.
9+
- If it's a new bug, **create a new issue**.
10+
11+
Please provide the following information in your bug report:
12+
- A clear, descriptive title.
13+
- A detailed description of the behavior and what you expected to happen instead.
14+
- Steps to reproduce the problem.
15+
- Your environment: OS (name and version), Browser, and any other relevant details.
16+
17+
## Suggesting new features
18+
19+
We welcome ideas for new features and improvements. For any new proposed feature, you need to create also a **new issue**. This allows maintainers and the community to discuss the approach before you write any code. Before submitting the issue:
20+
- **search existing ideas** to avoid duplicates,
21+
- **Provide a clear description** of the proposed feature and the problem it solves.
22+
23+
## Submit a bug fix
24+
25+
Always link your code changes to a GitHub issue. If one doesn't exist for your change, please create it first. Next you will need to follow the Git workflow.
26+
27+
## Git contribution workflow
28+
29+
1. Fork the Official Repository
30+
31+
Navigate to the official Cypht repository on GitHub (https://github.com/cypht-org/cypht) and click the "Fork" button in the top-right corner.
32+
33+
2. Clone Your Fork Locally
34+
35+
```
36+
git clone https://github.com/YOUR_USERNAME/cypht.git
37+
cd cypht
38+
```
39+
40+
3. Configure Remote Repositories (origin & upstream)
41+
42+
```
43+
# Check the existing remote name (it should be 'origin' pointing to your fork)
44+
git remote -v
45+
46+
# Add the official Cypht repository as the 'upstream' remote
47+
git remote add upstream https://github.com/cypht-org/cypht.git
48+
49+
# Verify both remotes are set correctly
50+
git remote -v
51+
```
52+
53+
4. Create a new Branch (for the new Feature or a bug fix)
54+
55+
```
56+
git checkout -b feature-amazing-new-feature
57+
# or
58+
git checkout -b fix-issue-123-description
59+
```
60+
61+
5. Write Code and run tests
62+
63+
**Code **
64+
65+
This is the core development phase where you implement your change. Before writing a line of code, take a moment to explore Cypht's architecture and code style.
66+
67+
Make changes that are minimal and specific to the issue you are solving. Avoid unnecessary refactoring or style changes in unrelated code.
68+
69+
Match the existing code style (indentation, bracket placement, naming conventions for variables and functions). This makes your code feel like a natural part of the project.
70+
71+
Add clear comments for complex logic, but strive to write code that is self-documenting through good variable and function names.
72+
73+
**Manual test**
74+
75+
Manual testing is your first line of defense to catch obvious issues and logic errors. **Do not skip this**.
76+
77+
Example:
78+
79+
**For a Backend/Bug Fix** (e.g., fixing IMAP connection errors):
80+
81+
- **Reproduce the Bug**: First, confirm you can reproduce the original issue described on GitHub.
82+
83+
- **Test the Fix**: Apply your change and verify the specific error no longer occurs.
84+
85+
- **Check for Regressions**: This is vital. Does your fix break any other existing functionality?
86+
87+
- Can you still read emails?
88+
- Can you still send emails?
89+
- Do all the other modules still load correctly?
90+
91+
- **Test with Different Configurations**: If possible, test with different mail servers to ensure robustness.
92+
93+
**Write Automated tests (for the new feature... if possible)**
94+
95+
6. Run automated tests (if possible)
96+
97+
- Unit Tests and integration tests with PHPUnit
98+
- End to end tests with Selenium
99+
100+
You can learn about how to run these tests [here](https://www.cypht.org/developers-documentation/) in the **Run Tests** section.
101+
102+
7. Commit Changes
103+
104+
Stage and commit your changes with clear, descriptive messages.
105+
106+
```
107+
# Stage changes
108+
git add .
109+
110+
# Commit changes (be specific!)
111+
git commit -m "feat(backend): allow search flagged in all folders if enabled in settings"
112+
```
113+
114+
8. Push to Your Fork and Create a Pull Request (PR)
115+
116+
```
117+
git push -u origin feature-allow-flagged-emails-search
118+
```
119+
120+
Go to your fork on GitHub. You will see a prompt to "Compare & pull request" for the newly pushed branch. Click it.
121+
122+
Fill out the PR template:
123+
124+
- Title: Clear summary
125+
- Description: Detail what you did, why you did it, and how it can be tested (if possible).
126+
127+
128+
**We appreciate all feedback and support of the project.**
5129

6130
If you have questions, please join our chat at: https://gitter.im/cypht-org/community

config/app.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@
795795
// |
796796
// | Github repository tracking.
797797
// */
798-
// // 'github',
798+
'github',
799799

800800
// /*
801801
// | ---------
@@ -813,7 +813,7 @@
813813
// |
814814
// | WordPress.com notifications.
815815
// */
816-
// // 'wordpress',
816+
'wordpress',
817817

818818
// /*
819819
// | -------

config/database.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@
7272
| defined above, and the db user must have read-write access to it:
7373
|
7474
| Postgresql:
75-
| CREATE TABLE hm_user_session (hm_id varchar(250) primary key not null, data text, hm_version INTEGEF DEFAULT 1, date timestamp);
75+
| CREATE TABLE hm_user_session (hm_id varchar(250) primary key not null, data text, hm_version INTEGER DEFAULT 1, date timestamp);
7676
|
7777
| MySQL or SQLite:
78-
| CREATE TABLE hm_user_session (hm_id varchar(180), data longblob, hm_version INTEGEF DEFAULT 1, lock INTEGER DEFAULT 0, date timestamp, primary key (hm_id));
78+
| CREATE TABLE hm_user_session (hm_id varchar(180), data longblob, hm_version INTEGER DEFAULT 1, lock INTEGER DEFAULT 0, date timestamp, primary key (hm_id));
7979
|
8080
|
8181
| DB Authentication

docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ COPY index.php index.php
8282
# Entrypoint
8383
COPY docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
8484
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
85+
COPY .env.example .env
8586

8687
# Healthcheck
8788
HEALTHCHECK CMD curl --fail http://localhost || exit 1

docker/docker-compose.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
version: '3.8'
1+
# this is a demo of using the production cypht image
2+
23
services:
34
db:
45
image: mariadb:10
@@ -12,7 +13,7 @@ services:
1213
- MYSQL_USER=cypht
1314
- MYSQL_PASSWORD=cypht_password
1415
healthcheck:
15-
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
16+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-ucypht", "-pcypht_password"]
1617
interval: 10s
1718
timeout: 5s
1819
retries: 5

lib/framework.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
/* load the framework */
1212
require APP_PATH.'lib/repository.php';
13+
require APP_PATH.'lib/searchable.php';
1314
require APP_PATH.'lib/module.php';
1415
require APP_PATH.'lib/modules.php';
1516
require APP_PATH.'lib/modules_exec.php';

lib/searchable.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
trait Searchable {
4+
/**
5+
* Return items matching $match in column $column.
6+
*
7+
* @param mixed $match
8+
* @param string $column
9+
* @param bool $returnFirst
10+
* @return array|null
11+
*/
12+
public static function getBy($match, $column = 'id', $returnFirst = false) {
13+
$results = [];
14+
foreach (static::getDataset() as $item) {
15+
if (isset($item[$column]) && $item[$column] === $match) {
16+
if ($returnFirst) {
17+
return $item;
18+
}
19+
$results[] = $item;
20+
}
21+
}
22+
return $returnFirst ? null : $results;
23+
}
24+
25+
// Each class must implement this
26+
abstract protected static function getDataset();
27+
}

lib/servers.php

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ public static function toggle_hidden($id, $hide) {
174174
trait Hm_Server_List {
175175

176176
use Hm_Server_Modify;
177+
use Searchable;
177178
use Hm_Repository {
178179
Hm_Repository::add as repo_add;
179180
Hm_Repository::get as repo_get;
@@ -216,24 +217,11 @@ public static function dump($id = false, $full = false) {
216217
}
217218

218219
/**
219-
* Return server details matching $match in column $column.
220-
*
221-
* @param mixed $match Value to match.
222-
* @param string $column Column name to match against.
223-
* @param bool $returnFirst If true, return only the first matching server.
224-
* @return array|null Array of matches, or a single server array, or null if no match.
220+
* Get the dataset for the server list
221+
* @return array
225222
*/
226-
public static function getBy($match, $column = 'id', $returnFirst = false) {
227-
$results = [];
228-
foreach (self::$server_list as $server) {
229-
if (isset($server[$column]) && $server[$column] === $match) {
230-
if ($returnFirst) {
231-
return $server;
232-
}
233-
$results[] = $server;
234-
}
235-
}
236-
return $returnFirst ? null : $results;
223+
protected static function getDataset() {
224+
return self::$server_list;
237225
}
238226

239227
/**

modules/core/hm-mailbox.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ public function get_folders($only_subscribed = false) {
240240
}
241241
}
242242

243-
public function get_subfolders($folder, $only_subscribed = false, $with_input = false) {
243+
public function get_subfolders($folder, $only_subscribed = false, $with_input = false, $count_children = false) {
244244
if (! $this->authed()) {
245245
return;
246246
}
247247
if ($this->is_imap()) {
248-
return $this->connection->get_folder_list_by_level($folder, $only_subscribed, $with_input);
248+
return $this->connection->get_folder_list_by_level($folder, $only_subscribed, $with_input, $count_children);
249249
} else {
250250
return $this->connection->get_folders($folder, $only_subscribed, $this->user_config->get('unsubscribed_folders')[$this->server_id] ?? [], $with_input);
251251
}

0 commit comments

Comments
 (0)