about summary refs log tree commit diff stats
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* attention-flag - unittest - stub_uiDebXWoody2021-05-291-0/+20
|
* Display OMEMO device IDDebXWoody2021-05-281-0/+5
| | | | | Display the OMEMO device ID which has been generated, when the user generated OMEMO crytographic materials via /omemo gen.
* Add support to register with a roomMichael Vetter2021-03-251-0/+10
| | | | | | | | | | `/affiliation register` can now be used to register a nickname with a MUC. Tested with a server without forms. Couldn't find a server which supports forms yet. Implements https://github.com/profanity-im/profanity/issues/1210
* MUC: Add voice requestThorben Günther2021-03-121-0/+5
| | | | closes https://github.com/profanity-im/profanity/issues/1211
* Add command to change password of logged in userThorben Günther2021-03-111-0/+10
|
* Update ui_ask_password to support confirmationThorben Günther2021-03-111-1/+1
| | | | | Just prints a different string to console. Useful for changing passwords or account registration.
* Add mam test stubMichael Vetter2021-01-281-0/+4
|
* Fix old chlog reference in helpMichael Vetter2021-01-171-2/+2
| | | | Fixes https://github.com/profanity-im/profanity/issues/1470
* Remove log_reinit()Michael Vetter2020-12-111-4/+0
| | | | Not needed anymore.
* Add tests for format_call_external_argvWilliam Wennerström2020-12-073-2/+61
|
* Rework url to filenameWilliam Wennerström2020-12-061-17/+63
|
* Move unique_filename_from_url functions to commonWilliam Wennerström2020-12-046-79/+88
|
* Fix stubs and move some tests to http_commonWilliam Wennerström2020-11-167-28/+10
|
* Add stubsWilliam Wennerström2020-11-163-2/+39
|
* Run make format on rebaseWilliam Wennerström2020-11-165-162/+111
|
* Remove unsafe Conent-Disposition inferringWilliam Wennerström2020-11-163-84/+35
|
* Infer filename from content-disposition or URLWilliam Wennerström2020-11-165-10/+244
| | | | | The Content-Disposition inferring is probably a bad idea security wise, so I am going to remove it.
* Move file encryption function to public headerWilliam Wennerström2020-11-163-40/+12
|
* Initial /sendfile OMEMO encryptionWilliam Wennerström2020-11-162-0/+12
|
* Remove non existent functionsMichael Vetter2020-11-021-8/+0
|
* functest: Make char constMichael Vetter2020-10-152-9/+9
|
* Merge branch 'master' of github.com:profanity-im/profanityMichael Vetter2020-07-101-3/+16
|\
| * Adapt unittestsMichael Vetter2020-07-091-3/+16
| |
* | OX: XEP-0373: OpenPGP for XMPP - Version 0.5.0 (2020-06-19)DebXWoody2020-07-101-0/+10
|/ | | | | | | | | | | Discovering Public Keys via PEP * 4.3 Discovering Public Keys of a User * 4.4 Requesting Public Keys * Import Public Keys into GnuPG's local keyring. Issue: #1331
* Apply coding styleMichael Vetter2020-07-0766-2522/+4364
|
* Revert "Apply coding style"Michael Vetter2020-07-0766-4502/+2660
| | | | | | This reverts commit 9b55f2dec0ea27a9ce4856e303425e12f866cea2. Sorting the includes creates some problems.
* Apply coding styleMichael Vetter2020-07-0766-2660/+4502
| | | | Regards https://github.com/profanity-im/profanity/issues/1396
* Tests: Add ox_announce_public_key stubMichael Vetter2020-07-061-0/+9
|
* Remove prefs_free_string()Michael Vetter2020-07-023-15/+15
| | | | | It just does a free. Related to b580b9ef119045f142fa4baa9689a1c5ce8864ef
* Add OX test stubsMichael Vetter2020-06-292-0/+16
|
* Add option for legacy authenticationDmitry Podgorny2020-06-057-19/+21
| | | | | | | | New options: /connect <account> [auth default|legacy] /account <account> set auth default|legacy Fixes #1236.
* Add include for waitpid to functionaltestMichael Vetter2020-06-041-0/+1
|
* Initialize ProfWin.urls_ac to NULL to fix OpenBSD buildWilliam Wennerström2020-06-031-0/+6
|
* Fix clears_chat_sessions unittestMichael Vetter2020-05-282-1/+6
|
* Add cons_show_bookmarks_ignore stubMichael Vetter2020-05-241-0/+1
|
* Fix build on sr.htMichael Vetter2020-05-221-0/+1
| | | | | | | | | | | | | | | | Hopefully fixing: ``` cc1: warnings being treated as errors tests/unittests/test_cmd_otr.c: In function 'cmd_otr_start_sends_otr_query_message_to_current_recipeint': tests/unittests/test_cmd_otr.c:422: warning: 'window.urls_ac' is used uninitialized in this function gmake[2]: *** [Makefile:1913: tests/unittests/test_cmd_otr.o] Error 1 gmake[2]: Leaving directory '/home/build/profanity' gmake[1]: *** [Makefile:2442: check-am] Error 2 gmake[1]: Leaving directory '/home/build/profanity' gmake: *** [Makefile:2445: check] Error 2 ```
* Update bookmark test stubMichael Vetter2020-05-221-2/+2
|
* Add executable stubMichael Vetter2020-05-201-1/+1
|
* Fix http_upload stubMichael Vetter2020-04-171-0/+3
|
* Update database stubMichael Vetter2020-04-071-3/+1
|
* Remove chat_log_get_previous()Michael Vetter2020-04-061-5/+0
| | | | | | | | | | | | We now dont get the log files from the text files via chat_log_get_previous() anymore. We use the sql backend via log_database_get_previous_chat(). So far it just has the same behaviour like chat_log_get_previous(), except that in _chatwin_history() we don't pass the sender to win_print_history() which should be fixed in a commit soon. And log_database_get_previous_chat() can later easily be expanded to fix https://github.com/profanity-im/profanity/issues/205.
* Add log_database_add_*() test stubsMichael Vetter2020-04-061-1/+6
|
* Fix message_send_private unittest stubMichael Vetter2020-04-061-1/+6
|
* db: add database unit test stubMichael Vetter2020-04-061-0/+31
|
* Add slashguard featureMichael Vetter2020-03-181-0/+1
| | | | | New command `/slashguard` tries to protect against typing ` /quit` by not allowing a slash in the first 4 characters.
* Add cons_avatar_setting to unit test stubMichael Vetter2020-03-101-0/+1
|
* Fix log test stubMichael Vetter2020-02-211-4/+5
|
* Fix test stubMichael Vetter2020-02-211-1/+1
| | | | Change done in eb2fbdba2efb9c81275461bf3651215b9456e496
* Allow utf8 symbols as omemo/pgp/otr indicator charMichael Vetter2020-02-201-2/+2
| | | | Fix https://github.com/profanity-im/profanity/issues/1264
* Parse mentions and triggers in muc history if display is 'regular'Michael Vetter2020-02-202-3/+3
| | | | Fix https://github.com/profanity-im/profanity/issues/1261
@gbmor.dev> 2019-06-08 02:29:23 -0400 cleaned up error handling' href='/gbmor/getwtxt/commit/svc/cache.go?h=v0.4.12&id=6c1b09bbeb1a7268a0d590e0a20ab2d34b395c8f'>6c1b09b ^
2b0d4a5 ^
e9d4a6b ^
2b0d4a5 ^

e9d4a6b ^
2b0d4a5 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
                                                      

        
               
                   
            
              
              

 








                                                           
                             





                          
                        




                                                                       

 

                                           

                     
                                 

                                      
                              
                                                                             
                 
                                                   


         

                     




                                                  
                             
                                         
                                       
                                                    
                                     
         
                               
 
                                   
                                                 
                                                                                                                  
         
                                     


                                      

 




                                               




                                                         
                       
 
                                                                 
                       
 
                              

                                        
                                

                                                 

                                       

                                         
 
                                  
                                                                                      
                                    
 
                                     

                                                          
                                       
         
 

                                             
                                                                     
                               
 
                                     

                                                      
                                       

         
package svc // import "github.com/getwtxt/getwtxt/svc"

import (
	"bytes"
	"io/ioutil"
	"os"
	"sync"
	"time"
)

// RemoteRegistries holds a list of remote registries to
// periodically scrape for new users. The remote registries
// must have been added via POST like a user.
type RemoteRegistries struct {
	Mu   sync.RWMutex
	List []string
}

type staticAssets struct {
	mu       sync.RWMutex
	index    []byte
	indexMod time.Time
	css      []byte
	cssMod   time.Time
}

func cacheTimer() bool {
	confObj.Mu.RLock()
	answer := time.Since(confObj.LastCache) > confObj.CacheInterval
	confObj.Mu.RUnlock()

	return answer
}

// Launched by init as a coroutine to watch
// for the update intervals to pass.
func cacheAndPush() {
	for {
		if cacheTimer() {
			refreshCache()
		}
		if dbTimer() {
			errLog("Error pushing cache to database: ", pushDB())
		}
		time.Sleep(1000 * time.Millisecond)
	}
}

func refreshCache() {

	// This clusterfuck of mutex read locks is
	// necessary to avoid deadlock. This mess
	// also avoids a panic that would occur
	// should twtxtCache be written to during
	// this loop.
	twtxtCache.Mu.RLock()
	for k := range twtxtCache.Users {
		twtxtCache.Mu.RUnlock()
		errLog("", twtxtCache.UpdateUser(k))
		twtxtCache.Mu.RLock()
	}
	twtxtCache.Mu.RUnlock()

	remoteRegistries.Mu.RLock()
	for _, v := range remoteRegistries.List {
		errLog("Error refreshing local copy of remote registry data: ", twtxtCache.CrawlRemoteRegistry(v))
	}
	remoteRegistries.Mu.RUnlock()
	confObj.Mu.Lock()
	confObj.LastCache = time.Now()
	confObj.Mu.Unlock()
}

// pingAssets checks if the local static assets
// need to be re-cached. If they do, they are
// pulled back into memory from disk.
func pingAssets() {

	confObj.Mu.RLock()
	assetsDir := confObj.AssetsDir
	confObj.Mu.RUnlock()

	cssStat, err := os.Stat(assetsDir + "/style.css")
	errLog("", err)

	indexStat, err := os.Stat(assetsDir + "/tmpl/index.html")
	errLog("", err)

	staticCache.mu.RLock()
	indexMod := staticCache.indexMod
	cssMod := staticCache.cssMod
	staticCache.mu.RUnlock()

	if !indexMod.Equal(indexStat.ModTime()) {
		tmpls = initTemplates()

		var b []byte
		buf := bytes.NewBuffer(b)

		confObj.Mu.RLock()
		errLog("", tmpls.ExecuteTemplate(buf, "index.html", confObj.Instance))
		confObj.Mu.RUnlock()

		staticCache.mu.Lock()
		staticCache.index = buf.Bytes()
		staticCache.indexMod = indexStat.ModTime()
		staticCache.mu.Unlock()
	}

	if !cssMod.Equal(cssStat.ModTime()) {

		css, err := ioutil.ReadFile(assetsDir + "/style.css")
		errLog("", err)

		staticCache.mu.Lock()
		staticCache.css = css
		staticCache.cssMod = cssStat.ModTime()
		staticCache.mu.Unlock()
	}
}