initial commit, simple hello world module hooked into user_may_join_room()
This commit is contained in:
parent
be73eac95b
commit
6ed2cc4b73
51
README.md
51
README.md
@ -1,3 +1,50 @@
|
||||
# rdblock
|
||||
# redlight
|
||||
|
||||
An advanced abuse management tool. It's a Synapse module that allows server owners to safely host rdlist, or use rdlist to prevent users from accessing tagged rooms.
|
||||
<p align="left">
|
||||
<img src="https://code.glowers.club/PC-Admin/redlight/logo/redlight_logo.jpg" width="480" alt="redlight logo">
|
||||
</p>
|
||||
|
||||
_"The red light means stop!"_
|
||||
|
||||
An advanced abuse management tool. It's a Synapse module that allows server owners to either run a "redlight server", or to act as a "redlight client" to prevent their own users from accessing abusive rooms. It's designed to block child sexual abuse material (CSAM) and other abusive content on the Matrix network.
|
||||
|
||||
This software attempts to resolve the complex problem of how to share pointers to rooms containing abusive content in order to block or report activity. These room lists are sensitive and sharing them can not only aid people in blocking this content but also direct bad actors to said content.
|
||||
|
||||
The goal of this tool is to simply block this content as efficiently as possible across many small-medium sized servers.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
Easy, setup for homeserver owners via Synapse Module
|
||||
Private, hashing is used to prevent redlight clients from sharing room_ids with redlight servers
|
||||
Decentralised, many people can run redlight servers with their own blocking policies, redlight clients are free to pick a provider
|
||||
Safe, access restrictions and ratelimiting are used to guard the content of rdlist
|
||||
|
||||
|
||||
## How it Works
|
||||
|
||||
...
|
||||
|
||||
For a more detailed description of how it will work please consult the [Technical Specification](./technical_spec.md).
|
||||
|
||||
**Coming soon...**
|
||||
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License.
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
We warmly welcome contributors who are interested in improving Matrix Lantern. Whether you're fixing bugs, improving documentation, or proposing new features, your efforts are greatly appreciated. Please ensure that new contributions follow our [Style Guide](./style_guide.md).
|
||||
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
Redlight is a community-driven project aimed at protecting the Matrix network's users from harmful content. Our thanks go out to the Matrix network, Glowers Club, and all our contributors who make this project possible.
|
||||
|
||||
|
||||
## Roadmap
|
||||
|
||||
1) Get a basic prototype working.
|
||||
|
37
hello_world_module.py
Normal file
37
hello_world_module.py
Normal file
@ -0,0 +1,37 @@
|
||||
import logging
|
||||
from typing import Union
|
||||
from synapse.module_api import ModuleApi
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class HelloWorldModule:
|
||||
def __init__(self, config: dict, api: ModuleApi):
|
||||
self._api = api
|
||||
|
||||
# Log a message to indicate the module's initialization
|
||||
logger.info("HelloWorldModule initialized.")
|
||||
|
||||
# Register the spam checker callback
|
||||
api.register_spam_checker_callbacks(
|
||||
user_may_join_room=self.user_may_join_room
|
||||
)
|
||||
|
||||
async def user_may_join_room(
|
||||
self, user: str, room: str, is_invited: bool
|
||||
) -> Union["synapse.module_api.NOT_SPAM", "synapse.module_api.errors.Codes"]:
|
||||
|
||||
# Log the event of a user trying to join a room
|
||||
logger.info(f"User {user} is attempting to join room {room}. Invitation status: {is_invited}.")
|
||||
|
||||
# Log the desired message
|
||||
logger.info("Hello World!")
|
||||
|
||||
# Return NOT_SPAM to allow the operation (joining the room)
|
||||
#return self._api.NOT_SPAM
|
||||
return self._api.errors.Codes.FORBIDDEN
|
||||
|
||||
def parse_config(config: dict) -> dict:
|
||||
return config
|
||||
|
||||
def create_module(api: ModuleApi, config: dict) -> HelloWorldModule:
|
||||
return HelloWorldModule(config, api)
|
BIN
logo/redlight_logo.jpg
Normal file
BIN
logo/redlight_logo.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
88
style_guide.md
Normal file
88
style_guide.md
Normal file
@ -0,0 +1,88 @@
|
||||
# Matrix Lantern Style Guide
|
||||
|
||||
This guide will help you in understanding the coding style being used in this project. Please adhere to these rules when contributing to the project for better readability and understanding of the code.
|
||||
|
||||
|
||||
## Indentation
|
||||
|
||||
Use tabs for indentation. The code uses one tab per indentation level.
|
||||
|
||||
|
||||
## Functions
|
||||
|
||||
Use lower case words separated by underscores. Function names should be descriptive of their function.
|
||||
|
||||
```
|
||||
def my_function():
|
||||
pass
|
||||
```
|
||||
|
||||
|
||||
## Variables
|
||||
|
||||
Similar to function names, variable names should also be lowercase with words separated by underscores. They should be descriptive.
|
||||
|
||||
```
|
||||
# good
|
||||
my_variable = 10
|
||||
|
||||
# bad
|
||||
mv = 10
|
||||
```
|
||||
|
||||
|
||||
## Commenting
|
||||
|
||||
Inline comments should be used sparingly. The use of comments is to clarify complex sections of code. If your code is straightforward, there's no need for comments.
|
||||
|
||||
```
|
||||
# Good
|
||||
def complex_algorithm():
|
||||
# This line does this...
|
||||
complex_line_of_code_here
|
||||
|
||||
# Bad
|
||||
def simple_algorithm():
|
||||
# This line increments by 1
|
||||
counter += 1
|
||||
```
|
||||
|
||||
|
||||
## Function Calls
|
||||
|
||||
Function calls and definitions should have no space between the function name and the parentheses.
|
||||
|
||||
```
|
||||
# Good
|
||||
print("Hello, World!")
|
||||
|
||||
# Bad
|
||||
print ("Hello, World!")
|
||||
```
|
||||
|
||||
|
||||
## Constants
|
||||
|
||||
Use uppercase with underscores to declare constants.
|
||||
|
||||
```
|
||||
# Good
|
||||
CONSTANT_NAME = 'Hello, World!'
|
||||
|
||||
# Bad
|
||||
Constant_name = 'Hello, World!'
|
||||
constantName = 'Hello, World!'
|
||||
```
|
||||
|
||||
|
||||
## Default Function Arguments
|
||||
|
||||
When using default arguments, there should be no spaces around the equals sign.
|
||||
|
||||
```
|
||||
# Good
|
||||
def my_func(default_arg='default'):
|
||||
|
||||
# Bad
|
||||
def my_func(default_arg = 'default'):
|
||||
```
|
2
technical_spec.md
Normal file
2
technical_spec.md
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
## add later
|
Loading…
Reference in New Issue
Block a user