chat-cli: Properly support deleting local chats
Since the current implementation of ;leave is silently destroying state
instead of unsubscribing, we disallow running ;leave on local chats and
provide an explicit ;delete instead.
[%eval cord hoon] :: send #-message
::
[%create chat-security path (unit glyph)] :: create chat
+ [%delete path] :: delete chat
[%invite ?(%r %w %rw) path (set ship)] :: allow
[%banish ?(%r %w %rw) path (set ship)] :: disallow
::
security
;~(plug path (punt ;~(pfix ace glyph)))
==
- ;~((glue ace) (perk %invite ~) rw path ships)
- ;~((glue ace) (perk %banish ~) rw path ships)
+ ;~((glue ace) (tag %delete) path)
+ ;~((glue ace) (tag %invite) rw path ships)
+ ;~((glue ace) (tag %banish) rw path ships)
::
;~((glue ace) (tag %join) ;~(plug targ (punt ;~(pfix ace glyph))))
;~((glue ace) (tag %leave) targ)
%eval (eval +.job)
::
%create (create +.job)
+ %delete (delete +.job)
%invite (change-permission & +.job)
%banish (change-permission | +.job)
::
?(%channel %mailbox) ~
?(%village %journal) [our-self ~ ~]
==
+ :: +delete: delete local chats
+ ::
+ ++ delete
+ |= =path
+ ^- (quip move _this)
+ =- [[- ~] this]
+ %^ act %do-delete %chat-view
+ :- %chat-view-action
+ [%delete (target-to-path our-self path)]
:: +change-permission: modify permissions on a local chat
::
++ change-permission
[%add-synced target]
:: +leave: unsync & destroy mailbox
::
- ::TODO but if we leave our own circle, then it disappears for everyone?
+ ::TODO allow us to "mute" local chats using this
++ leave
|= =target
=- [[- ~] this]
+ ?: =(our-self ship.target)
+ %- print:sh-out
+ "can't ;leave local chats, maybe use ;delete instead"
%^ act %do-leave %chat-hook
:- %chat-hook-action
[%remove (target-to-path target)]
