Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OF-2954: New feature: Spam Reporting #2661

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion distribution/src/database/openfire_db2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,35 @@ CREATE TABLE ofPubsubDefaultConf (
CONSTRAINT ofPubsubDefConf_pk PRIMARY KEY (serviceID, leaf)
);

CREATE TABLE ofSpamReport (
reportID BIGINT NOT NULL,
reporter VARCHAR(1024) NOT NULL,
reported VARCHAR(1024) NOT NULL,
reason VARCHAR(255) NOT NULL,
created BIGINT NOT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the db2 has the TIMESTAMP type. In other places of the file used char for date, which it very strange

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(as above: we currently never use a TIMESTAMP field, which is certainly something I'd like to improve on. If we do improve on that, we should do it consistently, everywhere).

context LONG VARCHAR NULL,
CONSTRAINT ofSpamReport PRIMARY KEY (reportID)
);
CREATE INDEX ofSpamReport_created_reporter_id ON ofSpamReport (created, reporter);
CREATE INDEX ofSpamReport_created_reported_id ON ofSpamReport (created, reported);

CREATE TABLE ofSpamStanza (
reportID INTEGER NOT NULL,
stanzaIDValue VARCHAR(1024) NOT NULL,
stanzaIDBy VARCHAR(1024) NOT NULL,
stanza LONG VARCHAR NULL
);
CREATE INDEX ofSpamStanza_reportID ON ofSpamStanza (reportID);

-- Finally, insert default table values
INSERT INTO ofID (idType, id) VALUES (18, 1);
INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);
INSERT INTO ofID (idType, id) VALUES (42, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 36);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 37);

-- Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
23 changes: 22 additions & 1 deletion distribution/src/database/openfire_hsqldb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,36 @@ CREATE TABLE ofPubsubDefaultConf (
CONSTRAINT ofPubsubDefaultConf_pk PRIMARY KEY (serviceID, leaf)
);

CREATE TABLE ofSpamReport (
reportID BIGINT NOT NULL,
reporter VARCHAR(1024) NOT NULL,
reported VARCHAR(1024) NOT NULL,
reason VARCHAR(255) NOT NULL,
created BIGINT NOT NULL,
context LONGVARCHAR NULL,
CONSTRAINT ofSpamReport PRIMARY KEY (reportID)
);
CREATE INDEX ofSpamReport_created_reporter_id ON ofSpamReport (created, reporter);
CREATE INDEX ofSpamReport_created_reported_id ON ofSpamReport (created, reported);

CREATE TABLE ofSpamStanza (
reportID BIGINT NOT NULL,
stanzaIDValue VARCHAR(1024) NOT NULL,
stanzaIDBy VARCHAR(1024) NOT NULL,
stanza LONGVARCHAR NULL
);
CREATE INDEX ofSpamStanza_reportID ON ofSpamStanza (reportID);

// Finally, insert default table values.

INSERT INTO ofID (idType, id) VALUES (18, 1);
INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);
INSERT INTO ofID (idType, id) VALUES (42, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 36);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 37);

// Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
23 changes: 22 additions & 1 deletion distribution/src/database/openfire_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,36 @@ CREATE TABLE ofPubsubDefaultConf (
PRIMARY KEY (serviceID, leaf)
);

CREATE TABLE ofSpamReport (
reportID BIGINT NOT NULL,
reporter VARCHAR(1024) NOT NULL,
reported VARCHAR(1024) NOT NULL,
reason VARCHAR(255) NOT NULL,
created BIGINT NOT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may use timestamp

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea, but not for now: We've had trouble before finding a consistent way to represent a timestamp in all of the databases that we support, which is why we use a number instead. I'm not sure if this is still as impossible as it was in 2004, by the way, but I'd like Openfire to be consistent.

If we do change number for timestamp (which would be a good thing), we should do it for all columns that currently use a number.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context TEXT NULL,
PRIMARY KEY (reportID),
INDEX ofSpamReport_created_reporter_id (created, reporter),
INDEX ofSpamReport_created_reported_id (created, reported)
);

CREATE TABLE ofSpamStanza (
reportID BIGINT NOT NULL,
stanzaIDValue VARCHAR(1024) NOT NULL,
stanzaIDBy VARCHAR(1024) NOT NULL,
stanza TEXT NULL,
INDEX ofSpamStanza_reportID (reportID)
);

# Finally, insert default table values.

INSERT INTO ofID (idType, id) VALUES (18, 1);
INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);
INSERT INTO ofID (idType, id) VALUES (42, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 36);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 37);

# Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
23 changes: 22 additions & 1 deletion distribution/src/database/openfire_oracle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,36 @@ CREATE TABLE ofPubsubDefaultConf (
CONSTRAINT ofPubsubDefaultConf_pk PRIMARY KEY (serviceID, leaf)
);

CREATE TABLE ofSpamReport (
reportID INTEGER NOT NULL,
reporter VARCHAR2(1024) NOT NULL,
reported VARCHAR2(1024) NOT NULL,
reason VARCHAR2(255) NOT NULL,
created INTEGER NOT NULL,
context CLOB NULL,
CONSTRAINT ofSpamReport_pk PRIMARY KEY (reportID)
);
CREATE INDEX ofSpamReport_created_reporter_id ON ofSpamReport (created, reporter);
CREATE INDEX ofSpamReport_created_reported_id ON ofSpamReport (created, reported);

CREATE TABLE ofSpamStanza (
reportID INTEGER NOT NULL,
stanzaIDValue VARCHAR2(1024) NOT NULL,
stanzaIDBy VARCHAR2(1024) NOT NULL,
stanza CLOB NULL
);
CREATE INDEX ofSpamStanza_reportID ON ofSpamStanza (reportID);

-- Finally, insert default table values.

INSERT INTO ofID (idType, id) VALUES (18, 1);
INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);
INSERT INTO ofID (idType, id) VALUES (42, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 36);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 37);

-- Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
23 changes: 22 additions & 1 deletion distribution/src/database/openfire_postgresql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,36 @@ CREATE TABLE ofPubsubDefaultConf (
CONSTRAINT ofPubsubDefaultConf_pk PRIMARY KEY (serviceID, leaf)
);

CREATE TABLE ofSpamReport (
reportID BIGINT NOT NULL,
reporter VARCHAR(1024) NOT NULL,
reported VARCHAR(1024) NOT NULL,
reason VARCHAR(255) NOT NULL,
created BIGINT NOT NULL,
context TEXT NULL,
CONSTRAINT ofSpamReport_pk PRIMARY KEY (reportID)
);
CREATE INDEX ofSpamReport_created_reporter_id ON ofSpamReport (created, reporter);
CREATE INDEX ofSpamReport_created_reported_id ON ofSpamReport (created, reported);

CREATE TABLE ofSpamStanza (
reportID BIGINT NOT NULL,
stanzaIDValue VARCHAR(1024) NOT NULL,
stanzaIDBy VARCHAR(1024) NOT NULL,
stanza TEXT NULL
);
CREATE INDEX ofSpamStanza_reportID ON ofSpamStanza (reportID);

-- Finally, insert default table values.

INSERT INTO ofID (idType, id) VALUES (18, 1);
INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);
INSERT INTO ofID (idType, id) VALUES (42, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 36);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 37);

-- Entry for admin user
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
23 changes: 22 additions & 1 deletion distribution/src/database/openfire_sqlserver.sql
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,36 @@ CREATE TABLE ofPubsubDefaultConf (
CONSTRAINT ofPubsubDefaultConf_pk PRIMARY KEY (serviceID, leaf)
);

CREATE TABLE ofSpamReport (
reportID BIGINT NOT NULL,
reporter VARCHAR(1024) NOT NULL,
reported VARCHAR(1024) NOT NULL,
reason VARCHAR(255) NOT NULL,
created BIGINT NOT NULL,
context NVARCHAR(MAX) NULL,
CONSTRAINT ofSpamReport_pk PRIMARY KEY (reportID)
);
CREATE INDEX ofSpamReport_created_reporter_id ON ofSpamReport (created, reporter);
CREATE INDEX ofSpamReport_created_reported_id ON ofSpamReport (created, reported);

CREATE TABLE ofSpamStanza (
reportID BIGINT NOT NULL,
stanzaIDValue VARCHAR(1024) NOT NULL,
stanzaIDBy VARCHAR(1024) NOT NULL,
stanza NVARCHAR(MAX) NULL
);
CREATE INDEX ofSpamStanza_reportID ON ofSpamStanza (reportID);

/* Finally, insert default table values. */

INSERT INTO ofID (idType, id) VALUES (18, 1);
INSERT INTO ofID (idType, id) VALUES (19, 1);
INSERT INTO ofID (idType, id) VALUES (23, 1);
INSERT INTO ofID (idType, id) VALUES (26, 2);
INSERT INTO ofID (idType, id) VALUES (27, 1);
INSERT INTO ofID (idType, id) VALUES (42, 1);

INSERT INTO ofVersion (name, version) VALUES ('openfire', 36);
INSERT INTO ofVersion (name, version) VALUES ('openfire', 37);

/* Entry for admin user */
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
23 changes: 22 additions & 1 deletion distribution/src/database/openfire_sybase.sql
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,36 @@ CREATE TABLE ofPubsubDefaultConf (
CONSTRAINT ofPubsubDefaultConf_pk PRIMARY KEY (serviceID, leaf)
)

CREATE TABLE ofSpamReport (
reportID INTEGER NOT NULL,
reporter NVARCHAR(1024) NOT NULL,
reported NVARCHAR(1024) NOT NULL,
reason NVARCHAR(255) NOT NULL,
created INTEGER NOT NULL,
context LONG VARCHAR NULL,
CONSTRAINT ofSpamReport_pk PRIMARY KEY (reportID)
)
CREATE INDEX ofSpamReport_created_reporter_id ON ofSpamReport (created, reporter)
CREATE INDEX ofSpamReport_created_reported_id ON ofSpamReport (created, reported)

CREATE TABLE ofSpamStanza (
reportID INTEGER NOT NULL,
stanzaIDValue NVARCHAR(1024) NOT NULL,
stanzaIDBy NVARCHAR(1024) NOT NULL,
stanza LONG VARCHAR NULL
);
CREATE INDEX ofSpamStanza_reportID ON ofSpamStanza (reportID);

/* Finally, insert default table values. */

INSERT INTO ofID (idType, id) VALUES (18, 1)
INSERT INTO ofID (idType, id) VALUES (19, 1)
INSERT INTO ofID (idType, id) VALUES (23, 1)
INSERT INTO ofID (idType, id) VALUES (26, 2)
INSERT INTO ofID (idType, id) VALUES (27, 1)
INSERT INTO ofID (idType, id) VALUES (42, 1)

INSERT INTO ofVersion (name, version) VALUES ('openfire', 36)
INSERT INTO ofVersion (name, version) VALUES ('openfire', 37)

/* Entry for admin user */
INSERT INTO ofUser (username, plainPassword, name, email, creationDate, modificationDate)
Expand Down
24 changes: 24 additions & 0 deletions distribution/src/database/upgrade/37/openfire_db2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
CREATE TABLE ofSpamReport (
reportID INTEGER NOT NULL,
reporter VARCHAR(1024) NOT NULL,
reported VARCHAR(1024) NOT NULL,
reason VARCHAR(255) NOT NULL,
created BIGINT NOT NULL,
context LONG VARCHAR NULL,
CONSTRAINT ofSpamReport PRIMARY KEY (reportID)
);

CREATE INDEX ofSpamReport_created_reporter_id ON ofSpamReport (created, reporter);
CREATE INDEX ofSpamReport_created_reported_id ON ofSpamReport (created, reported);

CREATE TABLE ofSpamStanza (
reportID INTEGER NOT NULL,
stanzaIDValue VARCHAR(1024) NOT NULL,
stanzaIDBy VARCHAR(1024) NOT NULL,
stanza LONG VARCHAR NULL
);
CREATE INDEX ofSpamStanza_reportID ON ofSpamStanza (reportID);

INSERT INTO ofID (idType, id) VALUES (42, 1);

UPDATE ofVersion SET version = 37 WHERE name = 'openfire';
23 changes: 23 additions & 0 deletions distribution/src/database/upgrade/37/openfire_hsqldb.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE TABLE ofSpamReport (
reportID BIGINT NOT NULL,
reporter VARCHAR(1024) NOT NULL,
reported VARCHAR(1024) NOT NULL,
reason VARCHAR(255) NOT NULL,
created BIGINT NOT NULL,
context LONGVARCHAR NULL,
CONSTRAINT ofSpamReport PRIMARY KEY (reportID)
);
CREATE INDEX ofSpamReport_created_reporter_id ON ofSpamReport (created, reporter);
CREATE INDEX ofSpamReport_created_reported_id ON ofSpamReport (created, reported);

CREATE TABLE ofSpamStanza (
reportID BIGINT NOT NULL,
stanzaIDValue VARCHAR(1024) NOT NULL,
stanzaIDBy VARCHAR(1024) NOT NULL,
stanza LONGVARCHAR NULL
);
CREATE INDEX ofSpamStanza_reportID ON ofSpamStanza (reportID);

INSERT INTO ofID (idType, id) VALUES (42, 1);

UPDATE ofVersion SET version = 37 WHERE name = 'openfire';
23 changes: 23 additions & 0 deletions distribution/src/database/upgrade/37/openfire_mysql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE TABLE ofSpamReport (
reportID BIGINT NOT NULL,
reporter VARCHAR(1024) NOT NULL,
reported VARCHAR(1024) NOT NULL,
reason VARCHAR(255) NOT NULL,
created BIGINT NOT NULL,
context TEXT NULL,
PRIMARY KEY (reportID),
INDEX ofSpamReport_created_reporter_id (created, reporter),
INDEX ofSpamReport_created_reported_id (created, reported)
);

CREATE TABLE ofSpamStanza (
reportID BIGINT NOT NULL,
stanzaIDValue VARCHAR(1024) NOT NULL,
stanzaIDBy VARCHAR(1024) NOT NULL,
stanza TEXT NULL,
INDEX ofSpamStanza_reportID (reportID)
);

INSERT INTO ofID (idType, id) VALUES (42, 1);

UPDATE ofVersion SET version = 37 WHERE name = 'openfire';
23 changes: 23 additions & 0 deletions distribution/src/database/upgrade/37/openfire_oracle.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE TABLE ofSpamReport (
reportID INTEGER NOT NULL,
reporter VARCHAR2(1024) NOT NULL,
reported VARCHAR2(1024) NOT NULL,
reason VARCHAR2(255) NOT NULL,
created INTEGER NOT NULL,
context CLOB NULL,
CONSTRAINT ofSpamReport_pk PRIMARY KEY (reportID)
);
CREATE INDEX ofSpamReport_created_reporter_id ON ofSpamReport (created, reporter);
CREATE INDEX ofSpamReport_created_reported_id ON ofSpamReport (created, reported);

CREATE TABLE ofSpamStanza (
reportID INTEGER NOT NULL,
stanzaIDValue VARCHAR2(1024) NOT NULL,
stanzaIDBy VARCHAR2(1024) NOT NULL,
stanza CLOB NULL
);
CREATE INDEX ofSpamStanza_reportID ON ofSpamStanza (reportID);

INSERT INTO ofID (idType, id) VALUES (42, 1);

UPDATE ofVersion SET version = 37 WHERE name = 'openfire';
23 changes: 23 additions & 0 deletions distribution/src/database/upgrade/37/openfire_postgresql.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE TABLE ofSpamReport (
reportID BIGINT NOT NULL,
reporter VARCHAR(1024) NOT NULL,
reported VARCHAR(1024) NOT NULL,
reason VARCHAR(255) NOT NULL,
created BIGINT NOT NULL,
context TEXT NULL,
CONSTRAINT ofSpamReport_pk PRIMARY KEY (reportID)
);
CREATE INDEX ofSpamReport_created_reporter_id ON ofSpamReport (created, reporter);
CREATE INDEX ofSpamReport_created_reported_id ON ofSpamReport (created, reported);

CREATE TABLE ofSpamStanza (
reportID BIGINT NOT NULL,
stanzaIDValue VARCHAR(1024) NOT NULL,
stanzaIDBy VARCHAR(1024) NOT NULL,
stanza TEXT NULL
);
CREATE INDEX ofSpamStanza_reportID ON ofSpamStanza (reportID);

INSERT INTO ofID (idType, id) VALUES (42, 1);

UPDATE ofVersion SET version = 37 WHERE name = 'openfire';
Loading
Loading