Browse Source

presence: set user agent db field to empty string if no value is found

Daniel-Constantin Mierla 7 năm trước cách đây
mục cha
commit
4654f8b4f3
1 tập tin đã thay đổi với 3 bổ sung1 xóa
  1. 3 1
      src/modules/presence/subscribe.c

+ 3 - 1
src/modules/presence/subscribe.c

@@ -191,6 +191,7 @@ int insert_subs_db(subs_t* s, int type)
 		contact_col, local_contact_col, version_col,socket_info_col,reason_col,
 		contact_col, local_contact_col, version_col,socket_info_col,reason_col,
 		watcher_user_col, watcher_domain_col, updated_col, updated_winfo_col,
 		watcher_user_col, watcher_domain_col, updated_col, updated_winfo_col,
 		user_agent_col, flags_col;
 		user_agent_col, flags_col;
+	str sval_empty = str_init("");
 
 
 	if(pa_dbf.use_table(pa_db, &active_watchers_table)< 0)
 	if(pa_dbf.use_table(pa_db, &active_watchers_table)< 0)
 	{
 	{
@@ -353,7 +354,8 @@ int insert_subs_db(subs_t* s, int type)
 	query_vals[updated_col].val.int_val = s->updated;
 	query_vals[updated_col].val.int_val = s->updated;
 	query_vals[updated_winfo_col].val.int_val = s->updated_winfo;
 	query_vals[updated_winfo_col].val.int_val = s->updated_winfo;
 	query_vals[flags_col].val.int_val = s->flags;
 	query_vals[flags_col].val.int_val = s->flags;
-	query_vals[user_agent_col].val.str_val= s->user_agent;
+	query_vals[user_agent_col].val.str_val=
+		(s->user_agent.s && s->user_agent.len>0)?s->user_agent:sval_empty;
 
 
 	if (pa_dbf.use_table(pa_db, &active_watchers_table) < 0)
 	if (pa_dbf.use_table(pa_db, &active_watchers_table) < 0)
 	{
 	{