From 3fcaf100334897e314a86a53576639410055989b Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Sun, 20 Jul 2025 17:00:26 +0300 Subject: Moved tools like check-ci into tools/ and updated the glossary --- CONTRIBUTING.md | 4 ++++ GLOSSARY.md | 50 ++++++++++++++++++++++++++++++++++++++++++++ check-ci.sh | 12 ----------- copyright.sh | 61 ------------------------------------------------------ mprocs.yaml | 2 +- reload.sh | 7 ------- terminology.md | 23 -------------------- tools/check-ci.sh | 12 +++++++++++ tools/copyright.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 128 insertions(+), 104 deletions(-) create mode 100644 GLOSSARY.md delete mode 100755 check-ci.sh delete mode 100755 copyright.sh delete mode 100755 reload.sh delete mode 100644 terminology.md create mode 100755 tools/check-ci.sh create mode 100755 tools/copyright.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5d75cb2..f7b1a03 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,6 +39,10 @@ us know in your PR, otherwise we will assume it is a WIP. Please only mark the pull request as "Ready for Review" when it is in fact complete and ready for review. +## Glosarry + +Check out the [Glossary](./glossary.md) to see how certain terms are used and what they mean + > When contributing to this project, you must agree that you have authored 100% > of the content, (or) that you have the necessary rights to the content and > that the content you contribute may be provided under the projects AGPLv3 diff --git a/GLOSSARY.md b/GLOSSARY.md new file mode 100644 index 0000000..22cbc4f --- /dev/null +++ b/GLOSSARY.md @@ -0,0 +1,50 @@ +# Glossary + +The goal is to define the meaning behind specific terminology used in this project. +Currently this document is incomplete, it'll be improved over time, feel free to contribute improvements. + +## ID + +A snowflake ID, a snowflake ID is a unique identifier used across the client +and server, it embeds metadata including the date it was generated which can +be retrieved for display purposes. + +### User ID + +A snowflake ID for a user, used as the primary way to refer to a user in a +unique way (like opening a signal with a user). + +### Receiver ID + +Usually refers to the "other" person's ID in a user-to-user messaging, but +can also refer to the literal `receiver_id` SQL field on the `messages` table +which may be either the "other" person, or the user itself. + +### Frequency ID + +A snowflake ID that refers to a frequency. + +### Chad ID + +A snowflake ID that refers to either a frequency ID or a receiver ID. + +### Signal + +A currently open chat between 2 individual users ("DM"). + +## Session + +A struct that helps with managing a single active connection, it contains +various metadata including the address of the connection and has methods for +reading/writing to the connection, it is also responsible for metrics and +rate limiting for per-connection requests. + +### Unauthenticated Session + +A session that has not yet been authenticated, so it doesn't have a User ID +or public key yet, and has not been added to the server sessions map. + +### Authenticated Session + +A session that is authenticated and attached to a user, it has a UserID and a +public key and it has been mapped into the server's session map. diff --git a/check-ci.sh b/check-ci.sh deleted file mode 100755 index 2baee8a..0000000 --- a/check-ci.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e - -trap 'echo "❌ Check failed"; exit 1' ERR - -test -z "$(go fmt ./...)" -staticcheck ./... -go test --cover ./... -gosec ./... - -echo "✅ All checks passed" diff --git a/copyright.sh b/copyright.sh deleted file mode 100755 index cc3a612..0000000 --- a/copyright.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash - -# AGPLv3 header template -START_YEAR=2025 -HEADER="// Eko: A terminal based social media platform -// Copyright (C) $START_YEAR Kyren223 -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see ." - -# List of paths to exclude (files or directories) -EXCLUDE_PATHS=("internal/data" "tools/test_rate_limit.go") - -# Check if .go files exist recursively -if ! find . -type f -name "*.go" | grep -q .; then - echo "No .go files found in the current directory or subdirectories." - exit 1 -fi - -# Get current year -CURRENT_YEAR=$(date +%Y) - -# Apply header to all .go files recursively, excluding specified paths -find . -type f -name "*.go" | while IFS= read -r file; do - # Check if file or its parent directories are in EXCLUDE_PATHS - skip=false - for exclude in "${EXCLUDE_PATHS[@]}"; do - if [[ "$file" == "./$exclude" || "$file" == ./"$exclude"/* ]]; then - skip=true - break - fi - done - - if [ "$skip" = true ]; then - echo "Skipped $file (in excluded path)" - continue - fi - - # Skip if file already has Copyright in the first 10 lines - if ! head -n 10 "$file" | grep -q "Copyright"; then - # Prepend header with a single newline, preserving original content - { echo "$HEADER"; echo; cat "$file"; } > "$file.tmp" && mv "$file.tmp" "$file" - echo "Added license header to $file" - else - # Update year in the header if needed and current year differs - if [ "$CURRENT_YEAR" != "$START_YEAR" ] && head -n 10 "$file" | grep -q "Copyright (C) $START_YEAR"; then - sed -i "1,10s/Copyright (C) $START_YEAR/Copyright (C) $START_YEAR-$CURRENT_YEAR/" "$file" - echo "Updated year in $file" - fi - fi -done diff --git a/mprocs.yaml b/mprocs.yaml index 2b9319a..4efa0f9 100644 --- a/mprocs.yaml +++ b/mprocs.yaml @@ -10,4 +10,4 @@ procs: messages-log: shell: "tail -f messages.log" check-ci: - shell: "./check-ci.sh" + shell: "./tools/check-ci.sh" diff --git a/reload.sh b/reload.sh deleted file mode 100755 index e520ebc..0000000 --- a/reload.sh +++ /dev/null @@ -1,7 +0,0 @@ -# 2.1 means "1st pane of the 2nd window" -tmux send-keys -t 2.1 C-c -sleep 0.5 -tmux send-keys -t 2.1 clear C-m -sleep 0.2 -tmux send-keys -t 2.1 "go run ./cmd/client" C-m -sleep 0.2 diff --git a/terminology.md b/terminology.md deleted file mode 100644 index d4cbe91..0000000 --- a/terminology.md +++ /dev/null @@ -1,23 +0,0 @@ -# Terminology - -TODO - -## TODO - -ID - A snowflake ID, a snowflake ID is a unique identifier used across the client and server, it embeds metadata including the date it was generated which can be retrieved for display purposes. - -User ID - A snowflake ID for a user, used as the primary way to refer to a user in a unique way (like opening a signal with a user) - -Receiver ID - usually refers to the "other" person's ID in a 1:1 messaging, but can also refer to the literal `receiver_id` SQL field on the `messages` table which may be either the "other" person, or the user itself. - -Frequency ID - -Chat ID - A snowflake ID that refers to either a frequency ID or a receiver ID - -Signal - A currently open chat between 2 individual users ("DM") - -Session - A struct that helps with managing a single active connection, it contains the addr of the connection and has methods for reading/writing to the connection - -Unauthenticated Session - A session that has not yet been authenticated, so it doesn't have a User ID or public key yet, and has not been added to the server sessions map - -Authenticated Session - A session that is authenticated and attached to a user, it has a UserID and a public key and it has been mapped into the server's session map based on it's user ID. diff --git a/tools/check-ci.sh b/tools/check-ci.sh new file mode 100755 index 0000000..2baee8a --- /dev/null +++ b/tools/check-ci.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e + +trap 'echo "❌ Check failed"; exit 1' ERR + +test -z "$(go fmt ./...)" +staticcheck ./... +go test --cover ./... +gosec ./... + +echo "✅ All checks passed" diff --git a/tools/copyright.sh b/tools/copyright.sh new file mode 100755 index 0000000..cc3a612 --- /dev/null +++ b/tools/copyright.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +# AGPLv3 header template +START_YEAR=2025 +HEADER="// Eko: A terminal based social media platform +// Copyright (C) $START_YEAR Kyren223 +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see ." + +# List of paths to exclude (files or directories) +EXCLUDE_PATHS=("internal/data" "tools/test_rate_limit.go") + +# Check if .go files exist recursively +if ! find . -type f -name "*.go" | grep -q .; then + echo "No .go files found in the current directory or subdirectories." + exit 1 +fi + +# Get current year +CURRENT_YEAR=$(date +%Y) + +# Apply header to all .go files recursively, excluding specified paths +find . -type f -name "*.go" | while IFS= read -r file; do + # Check if file or its parent directories are in EXCLUDE_PATHS + skip=false + for exclude in "${EXCLUDE_PATHS[@]}"; do + if [[ "$file" == "./$exclude" || "$file" == ./"$exclude"/* ]]; then + skip=true + break + fi + done + + if [ "$skip" = true ]; then + echo "Skipped $file (in excluded path)" + continue + fi + + # Skip if file already has Copyright in the first 10 lines + if ! head -n 10 "$file" | grep -q "Copyright"; then + # Prepend header with a single newline, preserving original content + { echo "$HEADER"; echo; cat "$file"; } > "$file.tmp" && mv "$file.tmp" "$file" + echo "Added license header to $file" + else + # Update year in the header if needed and current year differs + if [ "$CURRENT_YEAR" != "$START_YEAR" ] && head -n 10 "$file" | grep -q "Copyright (C) $START_YEAR"; then + sed -i "1,10s/Copyright (C) $START_YEAR/Copyright (C) $START_YEAR-$CURRENT_YEAR/" "$file" + echo "Updated year in $file" + fi + fi +done -- cgit v1.3.1