Kaynağa Gözat

Auth로 재설정 안내 추가

잉여개발기 1 yıl önce
ebeveyn
işleme
e1c0fb984d

+ 3 - 3
route/bbs_w_post.py

@@ -105,7 +105,7 @@ async def bbs_w_post(bbs_num = '', post_num = ''):
                 curs.execute(db_change("insert into bbs_data (set_name, set_code, set_id, set_data) values ('comment_date', ?, ?, ?)"), [id_data, set_id, date])
                 curs.execute(db_change("insert into bbs_data (set_name, set_code, set_id, set_data) values ('comment_user_id', ?, ?, ?)"), [id_data, set_id, ip])
 
-                add_alarm(conn, temp_dict['user_id'], ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + id_data + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + id_data + '</a>')
+                add_alarm(temp_dict['user_id'], ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + id_data + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + id_data + '</a>')
 
                 return redirect(conn, '/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + id_data)
             else:
@@ -219,9 +219,9 @@ async def bbs_w_post(bbs_num = '', post_num = ''):
                     set_id += '-' if set_id != '' else ''
                     end_id = set_id + id_data
 
-                add_alarm(conn, temp_dict['user_id'], ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + end_id + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + end_id + '</a>')
+                add_alarm(temp_dict['user_id'], ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + end_id + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + end_id + '</a>')
                 if comment_user_name != '':
-                    add_alarm(conn, comment_user_name, ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + end_id + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + end_id + '</a>')
+                    add_alarm(comment_user_name, ip, 'BBS <a href="/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + end_id + '">' + html.escape(bbs_name) + ' - ' + html.escape(temp_dict['title']) + '#' + end_id + '</a>')
 
                 return redirect(conn, '/bbs/w/' + bbs_num_str + '/' + post_num_str + '#' + end_id)
             else:

+ 2 - 2
route/edit.py

@@ -226,7 +226,7 @@ def edit(name = 'Test', section = 0, do_type = ''):
         
                 curs.execute(db_change("select id from user_set where name = 'watchlist' and data = ?"), [name])
                 for scan_user in curs.fetchall():
-                    add_alarm(conn, scan_user[0], ip, '<a href="/w/' + url_pas(name) + '">' + html.escape(name) + '</a>')
+                    add_alarm(scan_user[0], ip, '<a href="/w/' + url_pas(name) + '">' + html.escape(name) + '</a>')
                         
                 history_plus(conn, 
                     name,
@@ -255,7 +255,7 @@ def edit(name = 'Test', section = 0, do_type = ''):
 
                 curs.execute(db_change("select id from user_set where name = 'watchlist' and data = ?"), [name])
                 for scan_user in curs.fetchall():
-                    add_alarm(conn, scan_user[0], ip, '<a href="/edit_request/' + url_pas(name) + '">' + html.escape(name) + '</a> edit_request')
+                    add_alarm(scan_user[0], ip, '<a href="/edit_request/' + url_pas(name) + '">' + html.escape(name) + '</a> edit_request')
             
                 return redirect(conn, '/edit_request_from/' + url_pas(name))
         else:

+ 1 - 1
route/edit_request.py

@@ -47,7 +47,7 @@ def edit_request(name = 'Test', do_type = ''):
             
             curs.execute(db_change("select id from user_set where name = 'watchlist' and data = ?"), [name])
             for scan_user in curs.fetchall():
-                add_alarm(conn, scan_user[0], edit_request_user, '<a href="/w/' + url_pas(name) + '">' + html.escape(name) + '</a>')
+                add_alarm(scan_user[0], edit_request_user, '<a href="/w/' + url_pas(name) + '">' + html.escape(name) + '</a>')
 
             if flask.request.form.get('check', '') == 'Y':
                 curs.execute(db_change("delete from data where title = ?"), [name])

+ 4 - 4
route/go_api_topic.py

@@ -79,12 +79,12 @@ def api_topic_thread_pre_render(conn, data, num, ip, topic_num = '', name = '',
             ip_data = curs.fetchall()
             if ip_data and ip_or_user(ip_data[0][0]) == 0:
                 if do_type == 'thread':
-                    add_alarm(conn, ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                    add_alarm(ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
                 else:
                     set_id = topic_num.split('-')
                     set_id = ['', ''] if len(set_id) < 2 else set_id
 
-                    add_alarm(conn, ip_data[0][0], ip, 'BBS <a href="/bbs/w/' + set_id[0] + '/' + set_id[1] + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                    add_alarm(ip_data[0][0], ip, 'BBS <a href="/bbs/w/' + set_id[0] + '/' + set_id[1] + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
 
             data = re.sub(call_thread_regex, rd_data[0] + '<topic_a_' + do_type + '>#' + view_data + '</topic_a_' + do_type + '>' + rd_data[3], data, 1)
 
@@ -109,10 +109,10 @@ def api_topic_thread_pre_render(conn, data, num, ip, topic_num = '', name = '',
 
             if ip_data and ip_or_user(ip_data[0][0]) == 0:
                 if do_type == 'thread':
-                    add_alarm(conn, ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                    add_alarm(ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
                 else:
                     set_id = topic_num.split('-')
-                    add_alarm(conn, ip_data[0][0], ip, 'BBS <a href="/bbs/w/' + set_id[0] + '/' + set_id[1] + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                    add_alarm(ip_data[0][0], ip, 'BBS <a href="/bbs/w/' + set_id[0] + '/' + set_id[1] + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
 
             data = re.sub(call_user_regex, rd_data[0] + '<topic_call>@' + rd_data[1] + '</topic_call>' + rd_data[2], data, 1)
 

+ 39 - 24
route/tool/func.py

@@ -746,6 +746,17 @@ def update(conn, ver_num, set_data):
     if ver_num < 20240513:
         curs.execute(db_change("update user_set set data = '☑️' where name = 'user_title' and data = '✅'"))
 
+    if ver_num < 20240732:
+        curs.execute(db_change("select distinct name from alist where acl = 'owner'"))
+        for for_a in curs.fetchall():
+            curs.execute(db_change("select distinct id from user_set where name = 'acl' and data = ?"), [for_a[0]])
+            for for_b in curs.fetchall():
+                lang_name = get_lang_name(conn, tool = 'inter')
+                if lang_name == 'ko-KR':
+                    add_alarm(for_b[0], 'tool:system', '메인 ACL이 권한으로 개편되면서 기존 설정 값이 날라갔으니 권한으로 재설정 해주세요.')
+                else:
+                    add_alarm(for_b[0], 'tool:system', 'As the main ACL has been reorganized into the auth, the existing setting values have been lost, so please reset it to the auth.')
+
     print('Update completed')
 
 def set_init_always(conn, ver_num, run_mode):
@@ -1145,11 +1156,10 @@ def pw_check(conn, data, data2, type_d = 'no', id_d = ''):
 def easy_minify(conn, data, tool = None):
     return data
 
-def get_lang(conn, data, safe = 0):
-    with class_temp_db() as m_conn:
-        m_curs = m_conn.cursor()
-        curs = conn.cursor()
+def get_lang_name(conn, tool = ''):
+    curs = conn.cursor()
 
+    if tool != 'inter':
         ip = ip_check()
         if ip_or_user(ip) == 0:
             curs.execute(db_change('select data from user_set where name = "lang" and id = ?'), [ip])
@@ -1159,16 +1169,27 @@ def get_lang(conn, data, safe = 0):
         else:
             curs.execute(db_change("select data from other where name = 'language'"))
             rep_data = curs.fetchall()
+    else:
+        curs.execute(db_change("select data from other where name = 'language'"))
+        rep_data = curs.fetchall()
 
-        if not rep_data or rep_data[0][0] in ('', 'default'):
-            curs.execute(db_change("select data from other where name = 'language'"))
-            rep_data = curs.fetchall()
+    if not rep_data or rep_data[0][0] in ('', 'default'):
+        curs.execute(db_change("select data from other where name = 'language'"))
+        rep_data = curs.fetchall()
 
-        if rep_data:
-            lang_name = rep_data[0][0]
-        else:
-            lang_name = 'en-US'
-            
+    if rep_data:
+        lang_name = rep_data[0][0]
+    else:
+        lang_name = 'en-US'
+
+    return lang_name
+
+def get_lang(conn, data, safe = 0):
+    with class_temp_db() as m_conn:
+        m_curs = m_conn.cursor()
+
+        lang_name = get_lang_name(conn)
+        
         m_curs.execute('select data from temp where name = ?', ['lang_' + lang_name + '_' + data])
         db_data = m_curs.fetchall()
         if db_data:
@@ -2145,20 +2166,14 @@ def do_reload_recent_thread(conn, topic_num, date, name = None, sub = None):
     else:
         curs.execute(db_change("insert into rd (title, sub, code, date, band, stop, agree, acl) values (?, ?, ?, ?, '', '', '', '')"), [name, sub, topic_num, date])
 
-def add_alarm(conn, to_user, from_user, context):
-    curs = conn.cursor()
-
-    if to_user != from_user:
-        context = from_user + ' | ' + context
+def add_alarm(to_user, from_user, context):
+    other_set = {}
+    other_set['to'] = to_user
+    other_set['from'] = from_user
+    other_set['data'] = context
 
-        count = '1'
-        curs.execute(db_change("select id from user_notice where name = ? order by id + 0 desc"), [to_user])
-        db_data = curs.fetchall()
-        if db_data:
-            count = str(int(db_data[0][0]) + 1)
+    python_to_golang_sync('api_func_alarm_post', other_set)
 
-        curs.execute(db_change('insert into user_notice (id, name, data, date, readme) values (?, ?, ?, ?, "")'), [count, to_user, context, get_time()])
-    
 def add_user(conn, user_name, user_pw, user_email = '', user_encode = ''):
     curs = conn.cursor()
 

+ 2 - 2
route/topic.py

@@ -98,12 +98,12 @@ def topic(topic_num = 0, do_type = '', doc_name = 'Test'):
                         y_check = 1
 
                 if y_check == 1:
-                    add_alarm(conn, match, ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                    add_alarm(match, ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
             
             curs.execute(db_change("select ip from topic where code = ? and id = '1'"), [topic_num])
             ip_data = curs.fetchall()
             if ip_data and ip_or_user(ip_data[0][0]) == 0:
-                add_alarm(conn, ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
+                add_alarm(ip_data[0][0], ip, '<a href="/thread/' + topic_num + '#' + num + '">' + html.escape(name) + ' - ' + html.escape(sub) + '#' + num + '</a>')
 
             data = api_topic_thread_pre_render(conn, data, num, ip, topic_num, name, sub)
 

BIN
route_go/bin/main.amd64.bin


BIN
route_go/bin/main.amd64.exe


BIN
route_go/bin/main.arm64.bin


BIN
route_go/bin/main.arm64.exe


+ 2 - 0
route_go/main.go

@@ -105,6 +105,8 @@ func main() {
 		route_data = route.Api_bbs_w_set(call_arg[1:])
 	} else if call_arg[0] == "api_bbs_w_set_put" {
 		route_data = route.Api_bbs_w_set_put(call_arg[1:])
+	} else if call_arg[0] == "api_func_alarm_post" {
+		route_data = route.Api_func_alarm_post(call_arg[1:])
 	} else {
 		log.Fatal(call_arg[0] + " is 404")
 	}

+ 25 - 0
route_go/route/api_func_alarm_post.go

@@ -0,0 +1,25 @@
+package route
+
+import (
+	"opennamu/route/tool"
+
+	jsoniter "github.com/json-iterator/go"
+)
+
+func Api_func_alarm_post(call_arg []string) string {
+	var json = jsoniter.ConfigCompatibleWithStandardLibrary
+
+	other_set := map[string]string{}
+	json.Unmarshal([]byte(call_arg[0]), &other_set)
+
+	db := tool.DB_connect()
+	defer db.Close()
+
+	tool.Send_alarm(db, other_set["from"], other_set["to"], other_set["data"])
+
+	return_data := make(map[string]interface{})
+	return_data["response"] = "ok"
+
+	json_data, _ := json.Marshal(return_data)
+	return string(json_data)
+}

+ 46 - 0
route_go/route/tool/alarm.go

@@ -0,0 +1,46 @@
+package tool
+
+import (
+	"database/sql"
+	"log"
+	"strconv"
+)
+
+func Send_alarm(db *sql.DB, from string, target string, data string) {
+	if from != target {
+		data = from + " | " + data
+
+		now_time := Get_time()
+
+		var count string
+
+		stmt, err := db.Prepare(DB_change("select id from user_notice where name = ? order by id + 0 desc limit 1"))
+		if err != nil {
+			log.Fatal(err)
+		}
+		defer stmt.Close()
+
+		err = stmt.QueryRow(target).Scan(&count)
+		if err != nil {
+			if err == sql.ErrNoRows {
+				count = "1"
+			} else {
+				log.Fatal(err)
+			}
+		}
+
+		count_int, _ := strconv.Atoi(count)
+		count_int += 1
+
+		stmt, err = db.Prepare(DB_change("insert into user_notice (id, name, data, date, readme) values (?, ?, ?, ?, '')"))
+		if err != nil {
+			log.Fatal(err)
+		}
+		defer stmt.Close()
+
+		_, err = stmt.Exec(count_int, target, data, now_time)
+		if err != nil {
+			log.Fatal(err)
+		}
+	}
+}

+ 1 - 1
version.json

@@ -1,7 +1,7 @@
 {
     "beta" : {
         "r_ver" : "v3.5.0-v179",
-        "c_ver" : "20240513",
+        "c_ver" : "20240732",
         "s_ver" : "20240426"
     }
 }