]> git.r.bdr.sh - rbdr/mobius/blob - hotline/access.go
Implement Don't Show Agreement permission
[rbdr/mobius] / hotline / access.go
1 package hotline
2
3 import (
4 "encoding/binary"
5 "math/big"
6 )
7
8 const (
9 // File System Maintenance
10 accessDeleteFile = 0
11 accessUploadFile = 1
12 accessDownloadFile = 2 // Can Download Files
13 accessRenameFile = 3
14 accessMoveFile = 4
15 accessCreateFolder = 5
16 accessDeleteFolder = 6
17 accessRenameFolder = 7
18 accessMoveFolder = 8
19 accessReadChat = 9
20 accessSendChat = 10
21 accessOpenChat = 11
22 // accessCloseChat = 12 // Documented but unused?
23 // accessShowInList = 13 // Documented but unused?
24 accessCreateUser = 14
25 accessDeleteUser = 15
26 accessOpenUser = 16
27 accessModifyUser = 17
28 // accessChangeOwnPass = 18 // Documented but unused?
29 // accessSendPrivMsg = 19 // This doesn't do what it seems like it should do. TODO: Investigate
30 accessNewsReadArt = 20
31 accessNewsPostArt = 21
32 accessDisconUser = 22 // Toggles red user name in user list
33 accessCannotBeDiscon = 23
34 accessGetClientInfo = 24
35 accessUploadAnywhere = 25
36 accessAnyName = 26
37 accessNoAgreement = 27
38 accessSetFileComment = 28
39 accessSetFolderComment = 29
40 accessViewDropBoxes = 30
41 accessMakeAlias = 31
42 accessBroadcast = 32
43 accessNewsDeleteArt = 33
44 accessNewsCreateCat = 34
45 // accessNewsDeleteCat = 35
46 accessNewsCreateFldr = 36
47 // accessNewsDeleteFldr = 37
48 )
49
50 type accessBitmap [8]byte
51
52 func (bits *accessBitmap) Set(i int) {
53 bits[i/8] |= 1 << uint(7-i%8)
54 }
55
56 // authorize checks if 64 bit access slice contain has accessBit set
57 // TODO: refactor to use accessBitmap type
58 func authorize(access *[]byte, accessBit int) bool {
59 bits := big.NewInt(int64(binary.BigEndian.Uint64(*access)))
60
61 return bits.Bit(63-accessBit) == 1
62 }