Skip to content

Add IRC URL validator and update communication channel format handling#638

Open
shreyadesai20042009 wants to merge 3 commits intooutreachy:masterfrom
shreyadesai20042009:irc-validator
Open

Add IRC URL validator and update communication channel format handling#638
shreyadesai20042009 wants to merge 3 commits intooutreachy:masterfrom
shreyadesai20042009:irc-validator

Conversation

@shreyadesai20042009
Copy link
Copy Markdown

🛠 Changes Made

  • Added a custom validator function validate_irc_url to validate IRC channel URLs
  • Enforced correct IRC format: irc://<host>[:port]/<channel>
  • Made channel part mandatory (no empty or missing channel allowed)
  • Added special validation for OFTC URLs:
    • Required format: https://webchat.oftc.net/?channels=#channel
  • Updated help text in CommunicationChannel model:
    • Changed [channel]<channel> (now required)
    • Added OFTC format guidance
  • Integrated the custom validator with the existing URLValidator (did not remove existing validation)

✅ Validation Covers

  • ❌ Missing channel (e.g., irc://irc.mozilla.org)
  • ❌ Incorrect protocol (e.g., http://freenode.net)
  • ❌ Incorrect OFTC format (e.g., irc://irc.oftc.net/qemu)
  • ❌ Non-IRC links (e.g., Slack, Discord, etc.)
  • ✅ Valid IRC URLs (freenode, mozilla, gnome)
  • ✅ Valid OFTC webchat URLs

🧪 Testing

Tested manually using:

  • Django Admin interface
  • Django shell using full_clean()

Valid cases:

  • irc://irc.freenode.net/#guix
  • irc://irc.mozilla.org:6697/webcompat
  • https://webchat.oftc.net/?channels=#qemu

Invalid cases:

  • http://freenode.net
  • irc://irc.mozilla.org
  • https://google.com
  • irc://irc.oftc.net/qemu

📌 Notes

  • Did not modify any other fields or logic
  • Kept existing validation intact and extended it safely
  • Ensured compatibility with existing model structure

🙌 Ready for Review

Please let me know if any changes or additional edge cases should be handled!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant