Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eta
gajim
Commits
c311183d
Commit
c311183d
authored
19 years ago
by
nkour
Browse files
Options
Downloads
Patches
Plain Diff
fix so we mark new jids if they are room as room-type
parent
7ad4ff28
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/migrate_logs_to_dot9_db.py
+4
-4
4 additions, 4 deletions
scripts/migrate_logs_to_dot9_db.py
src/common/logger.py
+20
-10
20 additions, 10 deletions
src/common/logger.py
with
24 additions
and
14 deletions
scripts/migrate_logs_to_dot9_db.py
+
4
−
4
View file @
c311183d
...
...
@@ -140,7 +140,7 @@ def visit(arg, dirname, filenames):
for
filename
in
filenames
:
# Don't take this file into account, this is dup info
# notifications are also in contact log file
if
filename
==
'
notify.log
'
:
if
filename
in
(
'
notify.log
'
,
'
readme
'
)
:
continue
filename
=
decode_string
(
filename
)
if
not
filename
:
...
...
@@ -150,14 +150,14 @@ def visit(arg, dirname, filenames):
continue
jid
=
get_jid
(
dirname
,
filename
)
if
filename
==
os
.
path
.
basename
(
dirname
):
# gajim@conf/gajim@conf then gajim@conf is type room
type
=
constants
.
JID_ROOM_TYPE
print
'
mark
ing jid
as
of type room
'
print
'
Process
ing
'
,
jid
,
'
of type room
'
else
:
type
=
constants
.
JID_NORMAL_TYPE
print
'
mark
ing jid
as
of type normal
'
print
'
Process
ing
'
,
jid
,
'
of type normal
'
print
'
Processing
'
,
jid
# jid is already in the DB, don't create a new row, just get his jid_id
if
jid
in
jids_already_in
:
cur
.
execute
(
'
SELECT jid_id FROM jids WHERE jid =
"
%s
"'
%
jid
)
...
...
This diff is collapsed.
Click to expand it.
src/common/logger.py
+
20
−
10
View file @
c311183d
...
...
@@ -118,25 +118,31 @@ class Logger:
(
possible_room_jid
,
constants
.
JID_ROOM_TYPE
))
row
=
cur
.
fetchone
()
if
row
is
not
None
:
print
'
PM!!
'
return
True
else
:
print
'
NO PM!!
'
return
False
def
get_jid_id
(
self
,
jid
):
def
get_jid_id
(
self
,
jid
,
typestr
=
None
):
'''
jids table has jid and jid_id
logs table has log_id, jid_id, contact_name, time, kind, show, message
so to ask logs we need jid_id that matches our jid in jids table
this method asks jid and returns the jid_id for later sql-ing on logs
'''
if
jid
.
find
(
'
/
'
)
!=
-
1
:
# if it has a /
is
_pm
=
self
.
jid_is_from_pm
(
jid
)
if
not
is
_pm
:
# it's normal jid with resource
jid_is_from
_pm
=
self
.
jid_is_from_pm
(
jid
)
if
not
jid_is_from
_pm
:
# it's normal jid with resource
jid
=
jid
.
split
(
'
/
'
,
1
)[
0
]
# remove the resource
if
jid
in
self
.
jids_already_in
:
# we already have jids in DB
cur
.
execute
(
'
SELECT jid_id FROM jids WHERE jid=
"
%s
"'
%
jid
)
jid_id
=
cur
.
fetchone
()[
0
]
else
:
# oh! a new jid :), we add it now
cur
.
execute
(
'
INSERT INTO jids (jid) VALUES (?)
'
,
(
jid
,))
if
typestr
==
'
ROOM
'
:
typ
=
constants
.
JID_ROOM_TYPE
else
:
typ
=
constants
.
JID_NORMAL_TYPE
cur
.
execute
(
'
INSERT INTO jids (jid, type) VALUES (?, ?)
'
,
(
jid
,
typ
))
con
.
commit
()
jid_id
=
cur
.
lastrowid
self
.
jids_already_in
.
append
(
jid
)
...
...
@@ -249,15 +255,17 @@ class Logger:
else
:
time_col
=
int
(
float
(
time
.
time
()))
jid_id
=
self
.
get_jid_id
(
jid
)
kind_col
,
show_col
=
self
.
convert_human_values_to_db_api_values
(
kind
,
show
)
kind_col
,
show_col
=
self
.
convert_human_values_to_db_api_values
(
kind
,
show
)
# now we may have need to do extra care for some values in columns
if
kind
==
'
status
'
:
# we store (not None) time, jid, show, msg
# status for roster items
if
show
is
None
:
show_col
=
constants
.
SHOW_ONLINE
jid_id
=
self
.
get_jid_id
(
jid
)
elif
kind
==
'
gcstatus
'
:
# status in ROOM (for pm status see status)
...
...
@@ -265,7 +273,7 @@ class Logger:
show_col
=
constants
.
SHOW_ONLINE
jid
,
nick
=
jid
.
split
(
'
/
'
,
1
)
jid_id
=
self
.
get_jid_id
(
jid
)
# re-get jid_id for the new jid
jid_id
=
self
.
get_jid_id
(
jid
,
'
ROOM
'
)
# re-get jid_id for the new jid
contact_name_col
=
nick
elif
kind
==
'
gc_msg
'
:
...
...
@@ -275,9 +283,11 @@ class Logger:
# it's server message f.e. error message
# when user tries to ban someone but he's not allowed to
nick
=
None
jid_id
=
self
.
get_jid_id
(
jid
)
# re-get jid_id for the new jid
jid_id
=
self
.
get_jid_id
(
jid
,
'
ROOM
'
)
# re-get jid_id for the new jid
contact_name_col
=
nick
else
:
jid_id
=
self
.
get_jid_id
(
jid
)
values
=
(
jid_id
,
contact_name_col
,
time_col
,
kind_col
,
show_col
,
message_col
,
subject_col
)
self
.
commit_to_db
(
values
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment