Browse Source

writeup, code: it's done! (mostly) also fix the bugs

- The writeup is done (modulo typos/final checking) now!
- We fixed a few bugs that caused the tests to fail. Yay!
master
eta 2 years ago
parent
commit
7e0b0c1f8c
  1. 52
      ircd.lisp
  2. 2
      timestamps.lisp
  3. 21
      writeup/6.2.1.txt
  4. 3387
      writeup/NEA writeup.lyx
  5. BIN
      writeup/pasted1.png
  6. BIN
      writeup/pasted10.png
  7. BIN
      writeup/pasted11.png
  8. BIN
      writeup/pasted12.png
  9. BIN
      writeup/pasted13.png
  10. BIN
      writeup/pasted14.png
  11. BIN
      writeup/pasted15.png
  12. BIN
      writeup/pasted16.png
  13. BIN
      writeup/pasted17.png
  14. BIN
      writeup/pasted18.png
  15. BIN
      writeup/pasted19.png
  16. BIN
      writeup/pasted2.png
  17. BIN
      writeup/pasted20.png
  18. BIN
      writeup/pasted21.png
  19. BIN
      writeup/pasted22.png
  20. BIN
      writeup/pasted23.png
  21. BIN
      writeup/pasted24.png
  22. BIN
      writeup/pasted25.png
  23. BIN
      writeup/pasted26.png
  24. BIN
      writeup/pasted27.png
  25. BIN
      writeup/pasted28.png
  26. BIN
      writeup/pasted29.png
  27. BIN
      writeup/pasted3.png
  28. BIN
      writeup/pasted30.png
  29. BIN
      writeup/pasted4.png
  30. BIN
      writeup/pasted5.png
  31. BIN
      writeup/pasted6.png
  32. BIN
      writeup/pasted7.png
  33. BIN
      writeup/pasted8.png
  34. BIN
      writeup/pasted9.png

52
ircd.lisp

@ -203,6 +203,8 @@ Stolen from https://stackoverflow.com/questions/59043375/lisp-chunking-a-vector"
(raise-user-error-with-text 'err-nosuchchannel "Channel does not exist"))
(unless (groupchat-member-p gcid (client-userid c))
(raise-user-error-with-text 'err-cannotsendtochan "You're not in that groupchat"))
(unless (check-groupchat-capability gcid (client-userid c) :send-message)
(raise-user-error-with-text 'err-cannotsendtochan "You can't speak in that groupchat"))
(insert-db-message (client-userid c) tags (car (last params))
:gcid-to gcid
:is-notice is-notice))
@ -313,6 +315,8 @@ If the operation is unrecognized (or too complex for this basic implementation),
(check-groupchat-member gcid uid)
(unless (groupchat-member-p gcid target)
(raise-user-error 'err-usernotinchannel))
(unless (check-groupchat-capability gcid uid :change-roles)
(raise-user-error 'err-chanoprivsneeded (get-groupchat-name gcid)))
(update-groupchat-membership gcid target new-role)
(insert-db-mode-message uid gcid (second params) target)
(notify-new-messages)))))))
@ -338,7 +342,7 @@ If the operation is unrecognized (or too complex for this basic implementation),
(notify-new-messages))))))
(defmethod handle-irc-message ((c registered-irc-client) (msg msg-names))
(with-accessors ((params message-parameters)) msg
(with-accessors ((params message-parameters)) msroles
(with-accessors ((uid client-userid)) c
(let ((gcid (get-groupchat-target (first params))))
(check-groupchat-member gcid uid)
@ -411,28 +415,34 @@ When they arrive, it delivers them to connected clients."
(pomo:with-transaction ()
(for-each-client (uid devid client)
(let* ((messages (pomo:query
(:select 'm.* :distinct
:from (:as 'messages 'm) (:as 'local_user_devices 'lud) (:as 'groupchat_memberships 'gcm)
:where (:and
(:= 'lud.id '$2)
(:< 'lud.highest_seq 'm.seq)
(:or
(:= 'm.user_to '$1)
(:and
(:= 'gcm.user_id '$1)
(:= 'gcm.groupchat_uuid 'm.groupchat_to)))))
(:order-by
(:select 'm.* :distinct
:from (:as 'messages 'm) (:as 'local_user_devices 'lud)
:left-join (:as 'groupchat_memberships 'gcm) :on (:= 'gcm.user_id '$1)
:where (:and
(:= 'lud.id '$2)
(:< 'lud.highest_seq 'm.seq)
(:or
(:= 'm.user_to '$1)
(:and
(:= 'gcm.user_id '$1)
(:= 'gcm.groupchat_uuid 'm.groupchat_to)))))
'seq)
uid devid (:dao db-message)))
(system-messages (pomo:query
(:select 'm.* :distinct
:from (:as 'system_messages 'm) (:as 'local_user_devices 'lud) (:as 'groupchat_memberships 'gcm)
:where (:and
(:= 'lud.id '$2)
(:< 'lud.highest_seq 'm.seq)
(:or
(:= 'm.target_user_ref '$1)
(:and
(:= 'gcm.user_id '$1)
(:= 'gcm.groupchat_uuid 'm.groupchat_ref)))))
(:order-by
(:select 'm.* :distinct
:from (:as 'system_messages 'm) (:as 'local_user_devices 'lud)
:left-join (:as 'groupchat_memberships 'gcm) :on (:= 'gcm.user_id '$1)
:where (:and
(:= 'lud.id '$2)
(:< 'lud.highest_seq 'm.seq)
(:or
(:= 'm.target_user_ref '$1)
(:and
(:= 'gcm.user_id '$1)
(:= 'gcm.groupchat_uuid 'm.groupchat_ref)))))
'seq)
uid devid (:dao db-system-message)))
(both-messages (nconc messages (mapcar #'parse-db-system-message system-messages)))
(seq (loop

2
timestamps.lisp

@ -37,3 +37,5 @@ For example, a message sent an hour ago might only show the time, whereas a mess
(return-from timestamp-to-human-time-prefix nil)
*human-time-format*)
*human-date-and-time-format*))))
(setf local-time:*default-timezone* local-time:+utc-zone+)

21
writeup/6.2.1.txt

@ -0,0 +1,21 @@
[eeeeeta@superare nea-2019]$ ./nea-ircd -n nea-ircd -U eeeeeta -D nea2 --new-username test --new-password password
Running NEA IRCd with server name 'nea-ircd'.
Connecting to database using: (nea2 eeeeeta localhost PORT 5432)
Creating new user...done.
[eeeeeta@superare nea-2019]$ ./nea-ircd -n nea-ircd -U eeeeeta -D nea2 --new-username test2 --new-password password
Running NEA IRCd with server name 'nea-ircd'.
Connecting to database using: (nea2 eeeeeta localhost PORT 5432)
Creating new user...done.
[eeeeeta@superare nea-2019]$ psql -d nea2
psql (12.1)
Type "help" for help.
nea2=# SELECT * FROM users;
id | username | server
----+----------+--------
1 | eta | 1
2 | test | 1
3 | test2 | 1
(3 rows)
nea2=# \q

3387
writeup/NEA writeup.lyx

File diff suppressed because it is too large

BIN
writeup/pasted1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

BIN
writeup/pasted10.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

BIN
writeup/pasted11.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

BIN
writeup/pasted12.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
writeup/pasted13.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

BIN
writeup/pasted14.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
writeup/pasted15.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
writeup/pasted16.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
writeup/pasted17.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
writeup/pasted18.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

BIN
writeup/pasted19.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
writeup/pasted2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
writeup/pasted20.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
writeup/pasted21.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
writeup/pasted22.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
writeup/pasted23.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

BIN
writeup/pasted24.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

BIN
writeup/pasted25.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

BIN
writeup/pasted26.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

BIN
writeup/pasted27.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
writeup/pasted28.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
writeup/pasted29.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
writeup/pasted3.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
writeup/pasted30.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
writeup/pasted4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
writeup/pasted5.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
writeup/pasted6.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
writeup/pasted7.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

BIN
writeup/pasted8.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
writeup/pasted9.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Loading…
Cancel
Save