Commit 922eeb68 authored by David Byers's avatar David Byers
Browse files

More stuff on membership recommendataions.

First cut at automatically becoming member in recommended confs.
Note that the code DOES NOT QUITE WORK yet.
parent d212c418
2002-04-14 David Byers <david.byers@swipnet.se>
* lyskom-rest.el (lyskom-startup-check-recommended-memberships):
New function.
2002-04-13 David Byers <david.byers@swipnet.se>
Handle conference recommendations:
* lyskom-rest.el (lyskom-check-go-to-conf): Don't do stuff for
secret and passive memberships if we just rejected an invitation
(this was a bug). Record rejected invitations.
(lyskom-reject-invitation): New function.
(lyskom-invitation-already-rejected): New function.
* vars.el.in (lyskom-rejected-invitations): New variable.
New FAQ support:
* faqs.el: New file contains all FAQ-related stuff.
(lyskom-register-read-faq): New function.
......
......@@ -307,6 +307,10 @@ return non-nil if the item is to be included in the list."
(info . lyskom-aux-item-info)
(status-print . lyskom-print-elisp-client-read-faq))
(def-aux-item elisp-client-rejected-invitation 10001
(info . lyskom-aux-item-info)
(status-print . lyskom-print-elisp-client-rejected-invitation))
;;; ================================================================
......@@ -653,16 +657,26 @@ return non-nil if the item is to be included in the list."
(let ((conf-no (string-to-int (if (string-match " " (aux-item->data item))
(substring (aux-item->data item) 0 (match-beginning 0))
(aux-item->data item)))))
(lyskom-format-insert 'recommended-conf-aux conf-no)
(lyskom-aux-item-terminating-button item obj)))
(lyskom-format-insert 'recommended-conf-aux
conf-no
(lyskom-aux-item-terminating-button item obj))))
(defun lyskom-print-elisp-client-read-faq (item &optional obj)
(when (string-match "^\\([0-9]+\\) \\([0-9]+\\)" (aux-item->data item))
(let ((conf-no (string-to-int (match-string 1 (aux-item->data item))))
(text-no (string-to-int (match-string 2 (aux-item->data item)))))
(lyskom-format-insert 'status-read-aux-item
(lyskom-format-insert 'status-rejected-invitation-aux-item
conf-no
text-no
(lyskom-aux-item-terminating-button item obj)))))
(defun lyskom-print-elisp-client-rejected-invitation (item &optional obj)
(when (string-match "^\\([0-9]+\\) \\([0-9]+\\)" (aux-item->data item))
(let ((conf-no (string-to-int (match-string 1 (aux-item->data item))))
(pers-no (string-to-int (match-string 2 (aux-item->data item)))))
(lyskom-format-insert 'status-read-faq-aux-item
pers-no
conf-no
(lyskom-aux-item-terminating-button item obj)))))
(provide 'lyskom-aux-items)
......@@ -522,7 +522,9 @@ for person PERS-NO and send them into lyskom-try-add-member."
pers-stat
membership-type
&optional message-string
need-extra-information)
need-extra-information
use-priority
use-position)
"Add a member to a conference.
Args: CONF-CONF-STAT PERS-CONF-STAT PERS-STAT
CONF-CONF-STAT: the conf-stat of the conference the person is being added to
......@@ -534,30 +536,35 @@ Returns t if it was possible, otherwise nil.
If optional NEED-EXTRA-INFORMATION is non-nil, the return value will be
a list where the first element is the result of add-member and the second
is the position where the membership was placed."
is the position where the membership was placed.
If optional USE-PRIORITY is non-nil then use that as the priority.
If optional USE-POSITION is non-nil, then use that as the position.
"
(if (or (null conf-conf-stat)
(null pers-conf-stat))
nil ; We have some problem here.
(let ((priority
(if (/= lyskom-pers-no (conf-stat->conf-no pers-conf-stat))
(lyskom-read-num-range 0 255
(if (/= lyskom-pers-no (conf-stat->conf-no pers-conf-stat))
(lyskom-read-num-range 0 255
(lyskom-get-string 'priority-q)
nil 100)
(if (and (numberp kom-membership-default-priority)
(< kom-membership-default-priority 256)
(>= kom-membership-default-priority 0))
kom-membership-default-priority
(lyskom-read-num-range 0 255 (lyskom-get-string 'priority-q)))))
(if (and (numberp (or use-priority kom-membership-default-priority))
(< (or use-priority kom-membership-default-priority) 256)
(>= (or use-priority kom-membership-default-priority) 0))
(or use-priority kom-membership-default-priority)
(lyskom-read-num-range 0 255 (lyskom-get-string 'priority-q)))))
(where
(if (/= lyskom-pers-no (conf-stat->conf-no pers-conf-stat))
1 ; When adding someone else
(cond
((and (numberp kom-membership-default-placement)
(>= kom-membership-default-placement 0))
kom-membership-default-placement)
((eq kom-membership-default-placement 'first)
((and (numberp (or use-position kom-membership-default-placement))
(>= (or use-position kom-membership-default-placement) 0))
(or use-position kom-membership-default-placement))
((eq (or use-position kom-membership-default-placement) 'first)
0)
((eq kom-membership-default-placement 'last)
((eq (or use-position kom-membership-default-placement) 'last)
(length lyskom-membership))
(t
(lyskom-read-num-range
......
......@@ -2744,14 +2744,16 @@ to the first text that NEW is a comment or footnote to."
nil)
0
(mapconcat 'lyskom-format-object
(list (conf-stat->conf-no conf-stat)
priority
mship-type)
(delq nil
(list (conf-stat->conf-no conf-stat)
priority
mship-type))
" "))))
(lyskom-format-insert 'recommending-conf
conf-stat
priority
(lyskom-return-membership-type mship-type))
(and mship-type
(lyskom-return-membership-type mship-type)))
(lyskom-report-command-answer (blocking-do 'modify-server-info
nil
(list aux-item)))))
......@@ -601,7 +601,8 @@ Read all about it at http://www.lysator.liu.se/history/")
(status-aux-item . "Unknown auxiliary information: %11#1s%#3s (skapad av %#2M)\n")
(conf-mx-list-name . "Imported mailing list: %#1s %#2s\n")
(recommended-conf-aux . "Recommended conference: %#1M <%#1m> %#2s\n")
(status-read-aux-item . "Read FAQ: %15#2n for %#1?z%[%#1M <%#1m>%]%[the server%] %#3s\n")
(status-read-faq-aux-item . "Read FAQ: %15#2n for %#1?z%[%#1M <%#1m>%]%[the server%] %#3s\n")
(status-rejected-invitation-aux-item . "Rejected invitation to: %#2M %#1?z%[%by #1M%]%[created automatically%] %#3s\n")
(Everybody . "Everyone")
(show-members-list-also-q . "List members? ")
......
......@@ -591,14 +591,16 @@ If CONF is nil, check the first conf on the to-do list."
(progn
(let ((kom-unsubscribe-makes-passive nil))
(lyskom-sub-member (blocking-do 'get-pers-stat lyskom-pers-no)
conf-stat))
conf-stat)
(lyskom-reject-invitation (conf-stat->conf-no conf-stat)
(membership->created-by mship)))
(setq continue nil)
)))
(when (membership-type->secret type)
(when (and continue (membership-type->secret type))
(lyskom-format-insert-before-prompt 'bug-secret-mship conf-stat))
(when (membership-type->passive type)
(when (and continue (membership-type->passive type))
;;; Offer the user a chance to become an active member
;;; If the offer is refused, boot the user off the conference
(lyskom-format-insert 'enter-passive conf-stat)
......@@ -619,6 +621,91 @@ If CONF is nil, check the first conf on the to-do list."
;;; Return the result
continue))
(defun lyskom-reject-invitation (conf-no pers-no)
"Record that we have rejected an invitation to CONF-NO by PERS-NO"
(unless (lyskom-invitation-already-rejected conf-no pers-no)
(setq lyskom-rejected-invitations (cons (cons conf-no pers-no)
lyskom-rejected-invitations))
(initiate-modify-conf-info
'background
nil
lyskom-pers-no
nil
(list (lyskom-create-aux-item 0 10001 nil nil
(lyskom-create-aux-item-flags nil nil t nil
nil nil nil nil)
0
(format "%d %d" conf-no pers-no))))))
(defun lyskom-invitation-already-rejected (conf-no pers-no)
"Return non-nil if we have rejected an invitation to CONF-NO from PERS-NO."
(member (cons conf-no pers-no) lyskom-rejected-invitations))
(defun lyskom-update-rejected-invitations ()
"Update the list of rejected invitations"
(setq lyskom-rejected-invitations nil)
(let* ((conf-stat (blocking-do 'get-conf-stat lyskom-pers-no))
(aux-list (and conf-stat (lyskom-get-aux-item
(conf-stat->aux-items conf-stat)
10001))))
(lyskom-traverse item aux-list
(when (string-match "^\\([0-9]+\\) \\([0-9]+\\)" (aux-item->data item))
(setq lyskom-rejected-invitations
(cons (cons (string-to-int (match-string 1 (aux-item->data item)))
(string-to-int (match-string 2 (aux-item->data item))))
lyskom-rejected-invitations))))))
(defun lyskom-startup-check-recommended-memberships ()
"Create invitations for new membership recommendations"
(let ((recommendations
(filter-list
(lambda (rec)
(not (lyskom-invitation-already-rejected (car rec)
lyskom-pers-no)))
(mapcar (lambda (aux)
(when (string-match "^\\([0-9]+\\)\\( [0-9]+\\)?\\( [01]+\\)?" (aux-item->data aux))
(let* ((conf-no (string-to-int (match-string 1 (aux-item->data aux))))
(priority (and conf-no (match-string 2) (string-to-int (match-string 2 (aux-item->data aux)))))
(mship-type (and priority (match-string 3) (match-string 3 (aux-item->data aux)))))
(list conf-no priority mship-type))))
(lyskom-get-aux-item (server-info->aux-item-list
lyskom-server-info) 29))))
(collector (make-collector)))
;; At this point RECOMMENDATIONS contains a list with one element
;; per previously not rejected conference membership recommendations
;; (including the ones we are actually members of).
(lyskom-traverse rec recommendations
(initiate-query-read-texts 'main
'collector-push
lyskom-pers-no
(car rec)
collector))
(lyskom-wait-queue 'main)
;; Now delete recommendations that we are already members of
(lyskom-traverse mship (collector->value collector)
(when mship
(setq recommendations
(delq (assq (membership->conf-no mship) recommendations)
recommendations))))
;; At this point recommendations contains only the conferences
;; that we have not rejected and that we are not already members
;; of.
(blocking-do-multiple ((pers-stat (get-pers-stat lyskom-pers-no))
(pers-conf-stat (get-conf-stat lyskom-pers-no)))
(lyskom-traverse rec recommendations
(lyskom-try-add-member
(blocking-do 'get-conf-stat (car rec))
pers-conf-stat
pers-stat
(lyskom-create-membership-type t nil nil nil nil nil nil nil)
nil nil 255 0)))))
(defun lyskom-enter-conf (conf-stat read-info)
"Tell server which conf the user is reading.
Prints the name and amount of unread in the conference we just went to
......
......@@ -577,10 +577,12 @@ shown to other users."
(setq lyskom-is-new-user nil)
;; Do some FAQ handling
(unwind-protect
(lyskom-update-read-faqs)
(lyskom-startup-check-faqs)
nil)
(condition-case err
(progn (lyskom-update-read-faqs)
(lyskom-update-rejected-invitations)
(lyskom-startup-check-faqs)
(lyskom-startup-check-recommended-memberships))
(error nil))
(lyskom-end-of-command)))
......
......@@ -582,7 +582,8 @@ i svensk datorhistoria. L
(status-aux-item . "Oknd tillggsinformation: %15#1s%#3s (skapad av %#2M)\n")
(conf-mx-list-name . "Importerad mailinglista: %#1s %#2s\n")
(recommended-conf-aux . "Rekommenderat mte: %#1M <%#1m> %#2s\n")
(status-read-aux-item . "Lst FAQ: %15#2n fr %#1?z%[%#1M <%#1m>%]%[servern%] %#3s\n")
(status-read-faq-aux-item . "Lst FAQ: %15#2n fr %#1?z%[%#1M <%#1m>%]%[servern%] %#3s\n")
(status-rejected-invitation-aux-item . "Avvisad mtesinbjudan: %#2M %#1?z%[%by #1M%]%[skapad automatiskt%] %#3s\n")
(Everybody . "Alla")
(show-members-list-also-q . "Vill du se medlemslistan ocks? ")
......
......@@ -2585,6 +2585,10 @@ should be dynamically bound whenever it needs to be used.")
"List of FAQs that have been read."
inherited)
(def-kom-var lyskom-rejected-invitations nil
"List of invitations that have been rejected."
inherited)
(defvar lyskom-xface-cache (make-vector 29 0))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment