somestuff-paperlessstuff 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- somestuff_paperlessstuff-0.1.0/.gitignore +180 -0
- somestuff_paperlessstuff-0.1.0/LICENSE.md +163 -0
- somestuff_paperlessstuff-0.1.0/PKG-INFO +302 -0
- somestuff_paperlessstuff-0.1.0/README.md +272 -0
- somestuff_paperlessstuff-0.1.0/pyproject.toml +62 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/README.md +272 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/__init__.py +127 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/__main__.py +5 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/api.py +466 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/config.py +512 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/filetypes.py +58 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/folder/__init__.py +11 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/folder/intake.py +161 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/folder/scan.py +154 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/hook.py +968 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/hook_api.py +439 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/README.md +70 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/__init__.py +12 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/__main__.py +5 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/cli.py +103 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/clients.py +461 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/company_review.py +221 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/config.py +339 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/importer.py +148 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/jira2paperless.example.toml +73 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/models.py +221 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/reconcile.py +104 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/jira2paperless/rules.py +293 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/mail/__init__.py +12 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/mail/intake.py +349 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/mail/parse.py +335 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/plugins.py +206 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/py.typed +0 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/rules.toml +131 -0
- somestuff_paperlessstuff-0.1.0/somestuff/paperlessstuff/upload.py +161 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**/.gtfs_cache
|
|
2
|
+
/*.local
|
|
3
|
+
.claude
|
|
4
|
+
|
|
5
|
+
/*gguf*
|
|
6
|
+
|
|
7
|
+
/docker-config
|
|
8
|
+
/docker_build_local.log
|
|
9
|
+
|
|
10
|
+
/ms?hit
|
|
11
|
+
*mstest*py
|
|
12
|
+
*_test.py
|
|
13
|
+
/umqtt
|
|
14
|
+
.idea/
|
|
15
|
+
/upydev_.config
|
|
16
|
+
*.local.*
|
|
17
|
+
/scripts/logdir/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Byte-compiled / optimized / DLL files
|
|
21
|
+
__pycache__/
|
|
22
|
+
*.py[cod]
|
|
23
|
+
*$py.class
|
|
24
|
+
|
|
25
|
+
# C extensions
|
|
26
|
+
*.so
|
|
27
|
+
|
|
28
|
+
# Distribution / packaging
|
|
29
|
+
.Python
|
|
30
|
+
build/
|
|
31
|
+
develop-eggs/
|
|
32
|
+
dist/
|
|
33
|
+
downloads/
|
|
34
|
+
eggs/
|
|
35
|
+
.eggs/
|
|
36
|
+
lib/
|
|
37
|
+
lib64/
|
|
38
|
+
parts/
|
|
39
|
+
sdist/
|
|
40
|
+
var/
|
|
41
|
+
wheels/
|
|
42
|
+
share/python-wheels/
|
|
43
|
+
*.egg-info/
|
|
44
|
+
.installed.cfg
|
|
45
|
+
*.egg
|
|
46
|
+
MANIFEST
|
|
47
|
+
|
|
48
|
+
# PyInstaller
|
|
49
|
+
# Usually these files are written by a python script from a template
|
|
50
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
51
|
+
*.manifest
|
|
52
|
+
*.spec
|
|
53
|
+
|
|
54
|
+
# Installer logs
|
|
55
|
+
pip-log.txt
|
|
56
|
+
pip-delete-this-directory.txt
|
|
57
|
+
|
|
58
|
+
# Unit test / coverage reports
|
|
59
|
+
htmlcov/
|
|
60
|
+
.tox/
|
|
61
|
+
.nox/
|
|
62
|
+
.coverage
|
|
63
|
+
.coverage.*
|
|
64
|
+
.cache
|
|
65
|
+
nosetests.xml
|
|
66
|
+
coverage.xml
|
|
67
|
+
*.cover
|
|
68
|
+
*.py,cover
|
|
69
|
+
.hypothesis/
|
|
70
|
+
.pytest_cache/
|
|
71
|
+
cover/
|
|
72
|
+
|
|
73
|
+
# Translations
|
|
74
|
+
*.mo
|
|
75
|
+
*.pot
|
|
76
|
+
|
|
77
|
+
# Django stuff:
|
|
78
|
+
*.log
|
|
79
|
+
local_settings.py
|
|
80
|
+
db.sqlite3
|
|
81
|
+
db.sqlite3-journal
|
|
82
|
+
|
|
83
|
+
# Flask stuff:
|
|
84
|
+
instance/
|
|
85
|
+
.webassets-cache
|
|
86
|
+
|
|
87
|
+
# Scrapy stuff:
|
|
88
|
+
.scrapy
|
|
89
|
+
|
|
90
|
+
# Sphinx documentation
|
|
91
|
+
docs/_build/
|
|
92
|
+
|
|
93
|
+
# PyBuilder
|
|
94
|
+
.pybuilder/
|
|
95
|
+
target/
|
|
96
|
+
|
|
97
|
+
# Jupyter Notebook
|
|
98
|
+
.ipynb_checkpoints
|
|
99
|
+
|
|
100
|
+
# IPython
|
|
101
|
+
profile_default/
|
|
102
|
+
ipython_config.py
|
|
103
|
+
|
|
104
|
+
# pyenv
|
|
105
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
106
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
107
|
+
# .python-version
|
|
108
|
+
|
|
109
|
+
# pipenv
|
|
110
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
111
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
112
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
113
|
+
# install all needed dependencies.
|
|
114
|
+
#Pipfile.lock
|
|
115
|
+
|
|
116
|
+
# poetry
|
|
117
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
118
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
119
|
+
# commonly ignored for libraries.
|
|
120
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
121
|
+
#poetry.lock
|
|
122
|
+
|
|
123
|
+
# pdm
|
|
124
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
125
|
+
#pdm.lock
|
|
126
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
127
|
+
# in version control.
|
|
128
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
129
|
+
.pdm.toml
|
|
130
|
+
|
|
131
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
132
|
+
__pypackages__/
|
|
133
|
+
|
|
134
|
+
# Celery stuff
|
|
135
|
+
celerybeat-schedule
|
|
136
|
+
celerybeat.pid
|
|
137
|
+
|
|
138
|
+
# SageMath parsed files
|
|
139
|
+
*.sage.py
|
|
140
|
+
|
|
141
|
+
# Environments
|
|
142
|
+
.env
|
|
143
|
+
.venv
|
|
144
|
+
env/
|
|
145
|
+
venv/
|
|
146
|
+
ENV/
|
|
147
|
+
env.bak/
|
|
148
|
+
venv.bak/
|
|
149
|
+
|
|
150
|
+
# Spyder project settings
|
|
151
|
+
.spyderproject
|
|
152
|
+
.spyproject
|
|
153
|
+
|
|
154
|
+
# Rope project settings
|
|
155
|
+
.ropeproject
|
|
156
|
+
|
|
157
|
+
# mkdocs documentation
|
|
158
|
+
/site
|
|
159
|
+
|
|
160
|
+
# mypy
|
|
161
|
+
.mypy_cache/
|
|
162
|
+
.dmypy.json
|
|
163
|
+
dmypy.json
|
|
164
|
+
|
|
165
|
+
# Pyre type checker
|
|
166
|
+
.pyre/
|
|
167
|
+
|
|
168
|
+
# pytype static type analyzer
|
|
169
|
+
.pytype/
|
|
170
|
+
|
|
171
|
+
# Cython debug symbols
|
|
172
|
+
cython_debug/
|
|
173
|
+
|
|
174
|
+
# PyCharm
|
|
175
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
176
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
177
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
178
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
179
|
+
#.idea/
|
|
180
|
+
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
GNU Lesser General Public License
|
|
2
|
+
=================================
|
|
3
|
+
|
|
4
|
+
_Version 3, 29 June 2007_
|
|
5
|
+
_Copyright © 2007 Free Software Foundation, Inc. <<http://fsf.org/>>_
|
|
6
|
+
|
|
7
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
8
|
+
of this license document, but changing it is not allowed.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
This version of the GNU Lesser General Public License incorporates
|
|
12
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
13
|
+
License, supplemented by the additional permissions listed below.
|
|
14
|
+
|
|
15
|
+
### 0. Additional Definitions
|
|
16
|
+
|
|
17
|
+
As used herein, “this License” refers to version 3 of the GNU Lesser
|
|
18
|
+
General Public License, and the “GNU GPL” refers to version 3 of the GNU
|
|
19
|
+
General Public License.
|
|
20
|
+
|
|
21
|
+
“The Library” refers to a covered work governed by this License,
|
|
22
|
+
other than an Application or a Combined Work as defined below.
|
|
23
|
+
|
|
24
|
+
An “Application” is any work that makes use of an interface provided
|
|
25
|
+
by the Library, but which is not otherwise based on the Library.
|
|
26
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
27
|
+
of using an interface provided by the Library.
|
|
28
|
+
|
|
29
|
+
A “Combined Work” is a work produced by combining or linking an
|
|
30
|
+
Application with the Library. The particular version of the Library
|
|
31
|
+
with which the Combined Work was made is also called the “Linked
|
|
32
|
+
Version”.
|
|
33
|
+
|
|
34
|
+
The “Minimal Corresponding Source” for a Combined Work means the
|
|
35
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
36
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
37
|
+
based on the Application, and not on the Linked Version.
|
|
38
|
+
|
|
39
|
+
The “Corresponding Application Code” for a Combined Work means the
|
|
40
|
+
object code and/or source code for the Application, including any data
|
|
41
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
42
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
43
|
+
|
|
44
|
+
### 1. Exception to Section 3 of the GNU GPL
|
|
45
|
+
|
|
46
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
47
|
+
without being bound by section 3 of the GNU GPL.
|
|
48
|
+
|
|
49
|
+
### 2. Conveying Modified Versions
|
|
50
|
+
|
|
51
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
52
|
+
facility refers to a function or data to be supplied by an Application
|
|
53
|
+
that uses the facility (other than as an argument passed when the
|
|
54
|
+
facility is invoked), then you may convey a copy of the modified
|
|
55
|
+
version:
|
|
56
|
+
|
|
57
|
+
* **a)** under this License, provided that you make a good faith effort to
|
|
58
|
+
ensure that, in the event an Application does not supply the
|
|
59
|
+
function or data, the facility still operates, and performs
|
|
60
|
+
whatever part of its purpose remains meaningful, or
|
|
61
|
+
|
|
62
|
+
* **b)** under the GNU GPL, with none of the additional permissions of
|
|
63
|
+
this License applicable to that copy.
|
|
64
|
+
|
|
65
|
+
### 3. Object Code Incorporating Material from Library Header Files
|
|
66
|
+
|
|
67
|
+
The object code form of an Application may incorporate material from
|
|
68
|
+
a header file that is part of the Library. You may convey such object
|
|
69
|
+
code under terms of your choice, provided that, if the incorporated
|
|
70
|
+
material is not limited to numerical parameters, data structure
|
|
71
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
72
|
+
(ten or fewer lines in length), you do both of the following:
|
|
73
|
+
|
|
74
|
+
* **a)** Give prominent notice with each copy of the object code that the
|
|
75
|
+
Library is used in it and that the Library and its use are
|
|
76
|
+
covered by this License.
|
|
77
|
+
* **b)** Accompany the object code with a copy of the GNU GPL and this license
|
|
78
|
+
document.
|
|
79
|
+
|
|
80
|
+
### 4. Combined Works
|
|
81
|
+
|
|
82
|
+
You may convey a Combined Work under terms of your choice that,
|
|
83
|
+
taken together, effectively do not restrict modification of the
|
|
84
|
+
portions of the Library contained in the Combined Work and reverse
|
|
85
|
+
engineering for debugging such modifications, if you also do each of
|
|
86
|
+
the following:
|
|
87
|
+
|
|
88
|
+
* **a)** Give prominent notice with each copy of the Combined Work that
|
|
89
|
+
the Library is used in it and that the Library and its use are
|
|
90
|
+
covered by this License.
|
|
91
|
+
|
|
92
|
+
* **b)** Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
93
|
+
document.
|
|
94
|
+
|
|
95
|
+
* **c)** For a Combined Work that displays copyright notices during
|
|
96
|
+
execution, include the copyright notice for the Library among
|
|
97
|
+
these notices, as well as a reference directing the user to the
|
|
98
|
+
copies of the GNU GPL and this license document.
|
|
99
|
+
|
|
100
|
+
* **d)** Do one of the following:
|
|
101
|
+
- **0)** Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
- **1)** Use a suitable shared library mechanism for linking with the
|
|
109
|
+
Library. A suitable mechanism is one that **(a)** uses at run time
|
|
110
|
+
a copy of the Library already present on the user's computer
|
|
111
|
+
system, and **(b)** will operate properly with a modified version
|
|
112
|
+
of the Library that is interface-compatible with the Linked
|
|
113
|
+
Version.
|
|
114
|
+
|
|
115
|
+
* **e)** Provide Installation Information, but only if you would otherwise
|
|
116
|
+
be required to provide such information under section 6 of the
|
|
117
|
+
GNU GPL, and only to the extent that such information is
|
|
118
|
+
necessary to install and execute a modified version of the
|
|
119
|
+
Combined Work produced by recombining or relinking the
|
|
120
|
+
Application with a modified version of the Linked Version. (If
|
|
121
|
+
you use option **4d0**, the Installation Information must accompany
|
|
122
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
123
|
+
Code. If you use option **4d1**, you must provide the Installation
|
|
124
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
125
|
+
for conveying Corresponding Source.)
|
|
126
|
+
|
|
127
|
+
### 5. Combined Libraries
|
|
128
|
+
|
|
129
|
+
You may place library facilities that are a work based on the
|
|
130
|
+
Library side by side in a single library together with other library
|
|
131
|
+
facilities that are not Applications and are not covered by this
|
|
132
|
+
License, and convey such a combined library under terms of your
|
|
133
|
+
choice, if you do both of the following:
|
|
134
|
+
|
|
135
|
+
* **a)** Accompany the combined library with a copy of the same work based
|
|
136
|
+
on the Library, uncombined with any other library facilities,
|
|
137
|
+
conveyed under the terms of this License.
|
|
138
|
+
* **b)** Give prominent notice with the combined library that part of it
|
|
139
|
+
is a work based on the Library, and explaining where to find the
|
|
140
|
+
accompanying uncombined form of the same work.
|
|
141
|
+
|
|
142
|
+
### 6. Revised Versions of the GNU Lesser General Public License
|
|
143
|
+
|
|
144
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
145
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
146
|
+
versions will be similar in spirit to the present version, but may
|
|
147
|
+
differ in detail to address new problems or concerns.
|
|
148
|
+
|
|
149
|
+
Each version is given a distinguishing version number. If the
|
|
150
|
+
Library as you received it specifies that a certain numbered version
|
|
151
|
+
of the GNU Lesser General Public License “or any later version”
|
|
152
|
+
applies to it, you have the option of following the terms and
|
|
153
|
+
conditions either of that published version or of any later version
|
|
154
|
+
published by the Free Software Foundation. If the Library as you
|
|
155
|
+
received it does not specify a version number of the GNU Lesser
|
|
156
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
157
|
+
General Public License ever published by the Free Software Foundation.
|
|
158
|
+
|
|
159
|
+
If the Library as you received it specifies that a proxy can decide
|
|
160
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
161
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
162
|
+
permanent authorization for you to choose that version for the
|
|
163
|
+
Library.
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: somestuff-paperlessstuff
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Paperless-ngx webhook service: company custom field -> company tags and view groups, origin rules, IMAP and folder intake, plugins, periodic sweep
|
|
5
|
+
Project-URL: Homepage, https://github.com/vroomfondel/somestuff
|
|
6
|
+
Project-URL: Repository, https://github.com/vroomfondel/somestuff
|
|
7
|
+
Project-URL: Issues, https://github.com/vroomfondel/somestuff/issues
|
|
8
|
+
Author-email: Henning Thieß <ht@xomox.cc>
|
|
9
|
+
License-File: LICENSE.md
|
|
10
|
+
Keywords: document-management,fastapi,paperless,paperless-ngx,permissions,webhook
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: System Administrators
|
|
13
|
+
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Topic :: Office/Business
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.14
|
|
20
|
+
Requires-Dist: loguru>=0.7.3
|
|
21
|
+
Requires-Dist: pydantic>=2.14
|
|
22
|
+
Requires-Dist: tabulate>=0.10
|
|
23
|
+
Requires-Dist: typer>=0.27
|
|
24
|
+
Provides-Extra: api
|
|
25
|
+
Requires-Dist: fastapi>=0.143; extra == 'api'
|
|
26
|
+
Requires-Dist: uvicorn>=0.54; extra == 'api'
|
|
27
|
+
Provides-Extra: jira
|
|
28
|
+
Requires-Dist: requests>=2.32; extra == 'jira'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# paperlessstuff
|
|
32
|
+
|
|
33
|
+
Webhook service for [Paperless-ngx](https://docs.paperless-ngx.com/) that keeps company tags and
|
|
34
|
+
document visibility in step with two select custom fields ("Company", "Company 2" by default), plus its own mail
|
|
35
|
+
and folder intake. Replaces a set of Paperless workflows that cannot remove tags or groups
|
|
36
|
+
selectively, and the Paperless mail fetcher.
|
|
37
|
+
|
|
38
|
+
Per document:
|
|
39
|
+
|
|
40
|
+
- **Mail routes** (`[[mail.route]]`), **origin rules** (`[[origin]]`), the **plus rule** and the
|
|
41
|
+
**folder segment rule** fill the company fields when empty and optionally set the owner and extra
|
|
42
|
+
tags. Applied on `/added`, right after a mail/folder upload and, in the sweep, to documents added
|
|
43
|
+
within the last 24 h. Routes and origin rules are checked top-down, the first match wins; plus and
|
|
44
|
+
segment rule are fallbacks while the first company field is still empty.
|
|
45
|
+
- **Company tags**: exactly the tags of the selected companies; other company tags are removed, the
|
|
46
|
+
private tag ("Private") is removed once a company is set. Non-company tags stay untouched.
|
|
47
|
+
- **Visibility**: `view.groups` = current groups minus all company groups plus the groups of the
|
|
48
|
+
selected companies. `change.*` and `view.users` are kept.
|
|
49
|
+
|
|
50
|
+
Writes happen only on a difference, so the `updated` webhook triggered by the service's own change
|
|
51
|
+
ends as a no-op.
|
|
52
|
+
|
|
53
|
+
## Modules
|
|
54
|
+
|
|
55
|
+
| Module | Content |
|
|
56
|
+
|--------------------|--------------------------------------------------------------------------------------------|
|
|
57
|
+
| `hook.py` | pure `decide()` (no I/O), `Hook` (resolves names to IDs, applies decisions, sweep) |
|
|
58
|
+
| `api.py` | typed Paperless REST client (stdlib `urllib`, API version 9, pydantic models) |
|
|
59
|
+
| `config.py` | pydantic models of `rules.toml` + `companies.toml`; unknown keys and broken regexes fail |
|
|
60
|
+
| `upload.py` | shared upload path of both intakes (checksum check, `post_document`, consume task) |
|
|
61
|
+
| `filetypes.py` | file type from magic bytes, extension, content type |
|
|
62
|
+
| `mail/parse.py` | MIME parsing: attachment selection like Paperless, decoded file names, sender, recipients |
|
|
63
|
+
| `mail/intake.py` | IMAP loop (IDLE or polling), move by outcome |
|
|
64
|
+
| `folder/scan.py` | folder scan, readiness across two scans, ignore patterns, target paths, retention |
|
|
65
|
+
| `folder/intake.py` | folder polling loop, move by outcome |
|
|
66
|
+
| `plugins.py` | plugin directory: `on_added` / `on_updated` per `*.py` file |
|
|
67
|
+
| `hook_api.py` | FastAPI service and Typer CLI `paperless-hook` (extra `api`) |
|
|
68
|
+
| `rules.toml` | sample configuration; the default `--config-dir` is the package directory |
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pip install "somestuff-paperlessstuff[api]"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Requires Python 3.14 (IMAP IDLE via `imaplib.IMAP4.idle`).
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
export PAPERLESS_API_TOKEN=... HOOK_TOKEN=...
|
|
82
|
+
paperless-hook --config-dir ./paperless-hook # service + sweep thread
|
|
83
|
+
paperless-hook --config-dir ./paperless-hook --sweep-once --dry-run # one full dry run, JSON stats on stdout
|
|
84
|
+
python3 -m somestuff.paperlessstuff --help
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
| Option | Env var | Default |
|
|
88
|
+
|--------------------------------|----------------------------|------------------------------------------------------|
|
|
89
|
+
| `--config-dir` | `HOOK_CONFIG_DIR` | package directory |
|
|
90
|
+
| `--base-url` | `PAPERLESS_BASE_URL` | `http://paperless.paperless.svc.cluster.local.:8000` |
|
|
91
|
+
| `--api-token` | `PAPERLESS_API_TOKEN` | — |
|
|
92
|
+
| `--hook-token` | `HOOK_TOKEN` | — (required for the service) |
|
|
93
|
+
| `--listen-host` | `HOOK_LISTEN_HOST` | `0.0.0.0` |
|
|
94
|
+
| `--listen-port` | `HOOK_LISTEN_PORT`, `PORT` | `8080` |
|
|
95
|
+
| `--dry-run` | `HOOK_DRY_RUN` | off |
|
|
96
|
+
| `--sweep-once` | — | off |
|
|
97
|
+
| `--plugin-dir` | `HOOK_PLUGIN_DIR` | — (no plugins) |
|
|
98
|
+
| `--mail-intake` | `HOOK_MAIL_INTAKE` | off |
|
|
99
|
+
| `--imap-host` | `IMAP_HOST` | — (required with mail intake) |
|
|
100
|
+
| `--imap-user` | `IMAP_USER` | — (required with mail intake) |
|
|
101
|
+
| `--imap-password` | `IMAP_PASSWORD` | — (required with mail intake) |
|
|
102
|
+
| `--imap-port` | `IMAP_PORT` | `[mail] port`, else 993 (`tls`) / 143 |
|
|
103
|
+
| `--imap-security` | `IMAP_SECURITY` | `[mail] security` (`tls`, `starttls`, `none`) |
|
|
104
|
+
| `--imap-idle/--no-imap-idle` | `IMAP_IDLE` | `[mail] idle` (on) |
|
|
105
|
+
| `--imap-delimiter` | `IMAP_DELIMITER` | `[mail] delimiter`, else detected via `LIST` |
|
|
106
|
+
| `--folder-intake` | `HOOK_FOLDER_INTAKE` | off |
|
|
107
|
+
| `--intake-dir` | `HOOK_INTAKE_DIR` | — (required with folder intake) |
|
|
108
|
+
| `--log-level` | `HOOK_LOG_LEVEL` | `info` |
|
|
109
|
+
|
|
110
|
+
## Routes
|
|
111
|
+
|
|
112
|
+
| Route | Purpose |
|
|
113
|
+
|-----------------|-----------------------------------------------------------------------------|
|
|
114
|
+
| `GET /healthz` | liveness, dry-run flag, sweep/mail/folder threads alive, loaded plugins |
|
|
115
|
+
| `POST /added` | `{"doc_id": <id>}` + header `X-Hook-Token`, origin rules applied, plugins |
|
|
116
|
+
| `POST /updated` | same, without origin rules |
|
|
117
|
+
|
|
118
|
+
Wrong or missing token → 401, missing/invalid `doc_id` → 422, a Paperless error → 500 so Paperless
|
|
119
|
+
retries the webhook. In Paperless, create one workflow per trigger (Document Added, Document Updated)
|
|
120
|
+
with a webhook action, JSON body `{"doc_id": "{{ doc_id }}"}` and the `X-Hook-Token` header.
|
|
121
|
+
|
|
122
|
+
The "Document Added" webhook is queued inside the consume transaction and can arrive before the
|
|
123
|
+
document is committed. Both intakes therefore apply the origin rules themselves once the consume task
|
|
124
|
+
reports the new document id; the sweep (documents added within 24 h, `modified` > last run) catches
|
|
125
|
+
up on anything missed.
|
|
126
|
+
|
|
127
|
+
## Mail intake
|
|
128
|
+
|
|
129
|
+
Replaces the Paperless mail fetcher. Active with `HOOK_MAIL_INTAKE=1` and `IMAP_HOST`, `IMAP_USER`,
|
|
130
|
+
`IMAP_PASSWORD`. One connection stays open: a full pass over the inbox, then IMAP IDLE until the
|
|
131
|
+
server reports new mail (`EXISTS`), at the latest after `idle_seconds` another full pass. Without
|
|
132
|
+
IDLE (`idle = false`, `IMAP_IDLE=0` or no server support) it polls every `interval_seconds`.
|
|
133
|
+
|
|
134
|
+
Per mail in the inbox (`SINCE max_age_days`):
|
|
135
|
+
|
|
136
|
+
1. Sender outside `allowed_senders` (empty = everybody) → **Rejected**.
|
|
137
|
+
2. Attachments are selected like Paperless 3.5.1 (rule "attachments only", imap_tools 1.15):
|
|
138
|
+
all non-multipart parts with a file name, a `Content-ID` or type `message/rfc822`; only
|
|
139
|
+
`Content-Disposition: attachment` counts, inline parts are skipped. **Forwarded mails** attached as
|
|
140
|
+
`message/rfc822` are consumed as `.eml` (named after their subject) *and* walked into, so their
|
|
141
|
+
own attachments become separate documents. File names are decoded per RFC 2231 and RFC 2047, raw
|
|
142
|
+
UTF-8 as fallback. The type (magic bytes, extension, content type) must be in `extensions`.
|
|
143
|
+
No attachment left → **No Attachment**.
|
|
144
|
+
3. Upload via `post_document`: title = subject, tags from `tags` ("Source: Mail",
|
|
145
|
+
"paperless-gpt-auto", "paperless-gpt-ocr": Paperless sets them only for source Mail, an API
|
|
146
|
+
upload has source API), text fields "Mail Subject", "Mail Sender" (`Name <address>`) and
|
|
147
|
+
"Mail Recipients" (Delivered-To, X-Original-To, To, Cc; lower case, no duplicates, whole addresses up
|
|
148
|
+
to 128 characters). Custom fields go in as `{"<id>": value}` with the upload, never via PATCH.
|
|
149
|
+
4. Wait for the consume task, then move: success or duplicate → **Processed**, task failure →
|
|
150
|
+
**Error**. A Paperless or IMAP error leaves the mail in the inbox for the next pass.
|
|
151
|
+
|
|
152
|
+
Files whose SHA-256 checksum Paperless already has are not uploaded again (restart/retry safe;
|
|
153
|
+
documents in the trash are not visible to this check). One log line per mail, with Message-ID.
|
|
154
|
+
`HOOK_DRY_RUN` opens the inbox read-only and only logs.
|
|
155
|
+
|
|
156
|
+
Target folders are created when missing. Folder names use `/` as hierarchy separator and are
|
|
157
|
+
translated to the server delimiter (`delimiter`, `IMAP_DELIMITER`, otherwise detected via `LIST`).
|
|
158
|
+
Names must be ASCII.
|
|
159
|
+
|
|
160
|
+
### Plus addresses and the Dovecot pitfall
|
|
161
|
+
|
|
162
|
+
Postfix uses `recipient_delimiter = +`, Dovecot `lmtp_save_to_detail_mailbox = yes`: a mail to
|
|
163
|
+
`paperless+<detail>@` is delivered into the folder `<detail>` **if that folder exists**, otherwise
|
|
164
|
+
into INBOX. Consequences:
|
|
165
|
+
|
|
166
|
+
- A folder whose name equals a detail swallows those mails: they never reach INBOX and are never
|
|
167
|
+
processed. The intake refuses to start when a target folder (`Processed`, `No Attachment`,
|
|
168
|
+
`Error`, `Rejected`) normalizes to a company key or `private`/`privat`. Do not create folders named like
|
|
169
|
+
companies.
|
|
170
|
+
- `paperless+Processed@` or `paperless+Error@` land directly in those folders (mailbox names are
|
|
171
|
+
case-sensitive except INBOX) and are not processed either.
|
|
172
|
+
- `.` is the server's hierarchy delimiter: `paperless+acme.globex@` looks for the subfolder `globex`
|
|
173
|
+
below `acme`, which does not exist, so the mail goes to INBOX as intended. Creating `acme` with a
|
|
174
|
+
child `globex` would break it.
|
|
175
|
+
|
|
176
|
+
### Plus rule, routes, wildcard
|
|
177
|
+
|
|
178
|
+
`[mail.plus]` (switchable, target `address`) resolves the detail of `<local>+<detail>@<domain>`
|
|
179
|
+
against the companies: split at `.` or `-`, compared case-insensitively with label and tag without
|
|
180
|
+
spaces, dots and dashes (`acme`, `globex`, `initech` for "Initech Ltd"). The first company goes to the first company field,
|
|
181
|
+
the second to the second: `paperless+acme.globex@` → ACME + Globex. `paperless+private@` (or `+privat`)
|
|
182
|
+
sets no company and logs it. Only empty fields are filled; the rule runs while the first field is empty.
|
|
183
|
+
|
|
184
|
+
`[[mail.route]]` entries map recipient + address extension to effects, checked top-down before
|
|
185
|
+
`[[origin]]`, first match wins:
|
|
186
|
+
|
|
187
|
+
```toml
|
|
188
|
+
[[mail.route]]
|
|
189
|
+
recipient = 'paperless@example\.com' # regex on the base address (without +detail), "*" = any
|
|
190
|
+
detail = '(acme[.-])?globex' # regex on the extension; "*" or omitted = any, "" = none
|
|
191
|
+
set_company = "ACME"
|
|
192
|
+
set_company2 = "Globex"
|
|
193
|
+
add_tags = ["Invoice"]
|
|
194
|
+
|
|
195
|
+
[[mail.route]]
|
|
196
|
+
recipient = "*" # wildcard fallback
|
|
197
|
+
detail = "*"
|
|
198
|
+
resolve_plus = true # companies from the extension, like the plus rule
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Folder intake
|
|
202
|
+
|
|
203
|
+
Active with `HOOK_FOLDER_INTAKE=1`; root from `HOOK_INTAKE_DIR` (an NFS mount in the pod). NFS has
|
|
204
|
+
no inotify, so the root is polled every `interval_seconds`. A file is ready when size and mtime are
|
|
205
|
+
unchanged across two scans. Ignored: directories starting with `.`, file names matching `ignore`
|
|
206
|
+
(`.*`, `*.tmp`, `*.part`, `~*`).
|
|
207
|
+
|
|
208
|
+
Upload via `post_document` (title from the file name, by Paperless) with tags "Source: Folder",
|
|
209
|
+
"paperless-gpt-auto", "paperless-gpt-ocr" and the text field "Intake Folder" = relative subfolder
|
|
210
|
+
(`acme`, `acme/invoices`; empty in the root). Then the file moves, keeping the subfolder:
|
|
211
|
+
|
|
212
|
+
| Outcome | Target |
|
|
213
|
+
|----------------------------|--------------------------------------------|
|
|
214
|
+
| uploaded or duplicate | `.processed/<YYYY-MM-DD>/<subfolder>/` |
|
|
215
|
+
| consume task failed | `.error/<subfolder>/` |
|
|
216
|
+
| unsupported file type | `.rejected/<subfolder>/` |
|
|
217
|
+
| Paperless error | stays, retried in the next scan |
|
|
218
|
+
|
|
219
|
+
Date folders in `.processed` older than `retention_days` (default 30) are deleted. The segment rule
|
|
220
|
+
(`segment_rule`) resolves the first subfolder segment exactly like a plus detail: `acme/` → ACME,
|
|
221
|
+
`acme.globex/` → ACME + Globex, `private/` → no company. Paperless must not consume the same
|
|
222
|
+
directory; give the hook its own intake directory.
|
|
223
|
+
|
|
224
|
+
## Plugins
|
|
225
|
+
|
|
226
|
+
`--plugin-dir` / `HOOK_PLUGIN_DIR`: every `*.py` file (not starting with `_`) is loaded in name
|
|
227
|
+
order and reloaded when it changes. A plugin defines `on_added(event)` and/or `on_updated(event)`:
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
from somestuff.paperlessstuff.plugins import DocumentEvent
|
|
231
|
+
|
|
232
|
+
def on_added(event: DocumentEvent) -> None:
|
|
233
|
+
if not event.dry_run and event.document.title and "Mahnung" in event.document.title:
|
|
234
|
+
... # event.api is the Paperless client, event.decision what the hook just applied
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Handlers run after the hook's own changes, only for the `/added` and `/updated` webhooks — every
|
|
238
|
+
document passes `/added` once, whether it came by mail, folder, scan or upload. Sweep and intakes do
|
|
239
|
+
not run plugins (that would run them twice). A failing plugin is logged and reported in the webhook
|
|
240
|
+
answer; it does not fail the webhook, so Paperless does not retry and other plugins do not run again.
|
|
241
|
+
|
|
242
|
+
## Configuration
|
|
243
|
+
|
|
244
|
+
`companies.toml` and `rules.toml` from `--config-dir` are merged and validated (unknown keys and
|
|
245
|
+
broken regexes stop the start). See the sample `rules.toml` for every key.
|
|
246
|
+
|
|
247
|
+
```toml
|
|
248
|
+
[fields]
|
|
249
|
+
company = "Company" # old key "firma" is still accepted
|
|
250
|
+
company2 = "Company 2" # old key "firma2"
|
|
251
|
+
|
|
252
|
+
[tags]
|
|
253
|
+
private = "Private"
|
|
254
|
+
|
|
255
|
+
[behavior]
|
|
256
|
+
strip_groups_without_company = true # also drop company groups from documents without a company
|
|
257
|
+
|
|
258
|
+
[sweep]
|
|
259
|
+
interval_seconds = 600 # incremental sweep (modified > last run)
|
|
260
|
+
buffer_seconds = 120
|
|
261
|
+
|
|
262
|
+
[[companies]]
|
|
263
|
+
label = "ACME" # option label in the company fields
|
|
264
|
+
group = "ACME" # Paperless group that gets view permission
|
|
265
|
+
tag = "ACME" # company tag
|
|
266
|
+
|
|
267
|
+
[[origin]]
|
|
268
|
+
name = "Mail from jane"
|
|
269
|
+
match_mail_from = 'jane@example\.com'
|
|
270
|
+
set_company = "ACME"
|
|
271
|
+
set_owner = "jane" # owner_only_if_unowned = false forces it
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
| Condition | Matches |
|
|
275
|
+
|------------------------|-------------------------------------------------------------------------------|
|
|
276
|
+
| `match_tags_any` | at least one of the tag names |
|
|
277
|
+
| `match_tags_all` | all tag names |
|
|
278
|
+
| `match_owner` | owner username |
|
|
279
|
+
| `match_filename_regex` | regex on the original file name |
|
|
280
|
+
| `match_correspondent` | correspondent name |
|
|
281
|
+
| `match_field` | `{"<field name>" = "<regex>"}`, every entry on the field's value |
|
|
282
|
+
| `match_mail_from` | regex on "Mail Sender" |
|
|
283
|
+
| `match_mail_to` | regex on every address in "Mail Recipients" |
|
|
284
|
+
| `match_mail_detail` | regex on every plus detail of the plus address |
|
|
285
|
+
| `match_recipient` | `{address = "<regex>", detail = "<regex>"}` on the same address, `*` wildcard |
|
|
286
|
+
| `match_folder` | regex on "Intake Folder" |
|
|
287
|
+
|
|
288
|
+
Effects: `set_company`, `set_company2` (old keys `set_firma`, `set_firma2` accepted), `set_owner`, `owner_only_if_unowned`, `add_tags`, `resolve_plus`.
|
|
289
|
+
Regexes are searched case-insensitively (`match_recipient` and routes match the whole value). IDs of
|
|
290
|
+
fields, options, tags, groups and users are resolved by name at runtime and cached for five minutes.
|
|
291
|
+
A company whose group or tag does not exist is logged and ignored.
|
|
292
|
+
|
|
293
|
+
## jira2paperless
|
|
294
|
+
|
|
295
|
+
Copies Jira Server attachments (PDFs and images) into Paperless-ngx: import, `--reconcile` after paperless-gpt and
|
|
296
|
+
`--company-review` for company suggestions. Everything site-specific (hosts, token files, companies, regex rules)
|
|
297
|
+
lives in a TOML file outside the repository, see [`jira2paperless/README.md`](jira2paperless/README.md).
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
pip install "somestuff-paperlessstuff[jira]"
|
|
301
|
+
python3 -m somestuff.paperlessstuff.jira2paperless --config ~/.config/paperlessstuff/jira2paperless.toml --help
|
|
302
|
+
```
|